私は現在このコードを使用しています:
ActivityManager am = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
List<ActivityManager.RunningTaskInfo> taskInfo = am.getRunningTasks(1);
if(taskInfo.get(0).topActivity.getPackageName().equalsIgnoreCase("com.android.settings")){
////Do Action
}
現在のアクティビティが com.android.settings (Android 設定ページ) であるかどうかを確認できます。パッケージcom.android.setting内の特定のクラスファイルに置き換えようとしています。
if(taskInfo.get(0).topActivity.getPackageName().equalsIgnoreCase("com.android.settings.LocationSettings") || taskInfo.get(0).topActivity.getPackageName().equalsIgnoreCase("com.android.settings/.LocationSettings")){
////Do Action
}
私の問題は、このコードが「LocationSettings」を検出しないことです。
ここでは Android のソース コードと Cyanogen のソースを参照しています。