在代码里满足条件的时候跳转第三方apk。
然后在此条件下判断top activity是不是这个apk。
是的就不再跳转。
试了几个方法还是只能打印自己的activity,其他apk信息实在不知道怎么办了。
1修改AndroidManifest.xml,添加权限;2检测并引导用户开启权限;3使用UsageStatsManager来获取当前运行的app
参考:https://blog.csdn.net/yishifu/article/details/52104129
参考:http://developer.android.com/reference/android/app/usage/UsageStatsManager.html
在Android5.0,即Lollipop(api level 21)之前,大家都幸福的使用如下代码来获得当前运行的app,即所谓的top Activity:
ActivityManager activityManager = (ActivityManager) this.getSystemService(Context.ACTIVITY_SERVICE);
ComponentName cn = activityManager.getRunningTasks(1).get(0).topActivity;
参考:http://developer.android.com/reference/android/app/usage/UsageStatsManager.html
在Android5.0,即Lollipop(api level 21)之前,大家都幸福的使用如下代码来获得当前运行的app,即所谓的top Activity:
ActivityManager activityManager = (ActivityManager) this.getSystemService(Context.ACTIVITY_SERVICE);
ComponentName cn = activityManager.getRunningTasks(1).get(0).topActivity;