2012-06-22 162 views

回答

0

當系統設置啓動時,不播放意圖。但是你可以創建一個服務並查看活動堆棧中的頂級活動,如下所示:

ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); 
List<ActivityManager.RunningTaskInfo> processes = activityManager.getRunningTasks(1); 
ComponentName componentInfo = processes.get(0).topActivity; 
String className = componentInfo.getClassName();  
String packageName = componentInfo.getPackageName(); 
if(className.equalsIgnoreCase("com.android.settings.Settings")) 
{ 
    // DO YOUR JOB HERE 
} 
+0

謝謝@Andrey !!! :-) –

相關問題