只需知道实施Google分析的正确方法,即可实时跟踪用户何时处于片段中这就是现在所做的事情
@Override
public void onResume() {
super.onResume();
Tracker myTracker = parentActivity.getTracker();
myTracker.setCustomMetric(1, (long) 1);
myTracker.sendView("Music View");
}
Run Code Online (Sandbox Code Playgroud)
getTracker类在我的主要活动中,只返回主活动中的跟踪器实例
任何帮助将非常感激!
我正在为我的Android应用程序创建一个测试套件并拥有这个setUp方法
private static final String TAG_NAME = "TESTING_SUITE";
public TestingMusicDAO musicDAO;
public List<Song> songs;
public Instrumentation instr;
MusicService musicService;
@Override
public void setUp() throws Exception {
instr = this.getInstrumentation();
Log.d(TAG_NAME, "Setting up testing songs");
musicDAO = new TestingMusicDAO(instr.getContext());
musicService = new MusicServiceImpl(musicDAO);
musicDAO.getAllSongsFromFile();
songs = musicDAO.getAllSongs();
for(Song song : songs)
Log.d( TAG_NAME, song.toString() );
}
Run Code Online (Sandbox Code Playgroud)
然后让这些测试由python工具从文本文件创建
public void test1() {
List<Song> testPlaylist;
String testArtist = ("The Beatles");
String actualArtist = ("TheBeatles");
testPlaylist = testingPlaySongsByKeyword(testArtist);
if(testPlaylist.isEmpty()){
fail("No Songs Were Found");
} …
Run Code Online (Sandbox Code Playgroud)