android后台service查看当前正在运行的应用的包名
ActivityManager activityManager = (ActivityManager) this.getSystemService(ACTIVITY_SERVICE); List<ActivityManager.RunningTaskInfo> taskInfo = activityManager.getRunningTasks(1); ComponentName componentInfo = taskInfo.get(0).topActivity; Log.d(tag, "当前应用:" + componentInfo.getPackageName());
记录一下
原文:http://my.oschina.net/enyo/blog/345834