activity-manager

ActivityManager.getRunningTasks is deprecated android

蹲街弑〆低调 提交于 2019-11-27 07:40:00
I am working on push notification in android where i am using a below method to show notification, but the problem is that now ActivityManager.getRunningTasks(1); is being deprecated. From one stackoverflow question i read that: " you can use getAppTasks() returning a List<AppTask> where you can get the RecentTaskInfo with getTaskInfo " but i can't figure it out how to use it. Please help me out here in this regard. private void postNotification(Context ctx, Intent intent) { try { if (intent == null) { Log.d(TAG, "Receiver intent null"); } else { String action = intent.getAction(); if (action

Cannot get foreground activity name in Android Lollipop 5.0 only

情到浓时终转凉″ 提交于 2019-11-26 15:41:50
问题 I use the following code to get the activity name of the foreground app in the variable foregroundTaskPackageName . It works on all OS versions between 4.1 to 4.4, but does not work in Android 5.0 Lollipop. Can anyone help with what has changed in 5.0 Lollipop? In Lollipop - the text I get for foregroundTaskPackageName is just 'Launcher3'. I am using the Genymotion Emulator. ActivityManager am = (ActivityManager) getSystemService(ACTIVITY_SERVICE); RunningTaskInfo foregroundTaskInfo = am

How to use UsageStatsManager?

微笑、不失礼 提交于 2019-11-26 11:10:36
Background Google has deprecated the function " getRecentTasks " of "ActivityManager" class. Now all it does is to get the list of apps that the current app has opened. I've even written a post about it here on StackOverflow , but I noticed it's impossible. The problem I've made a post about it ( here , and another, similar one created by someone else, here ) and requested to re-consider it, and Google decided to make a new class, that seem to provide a similar functionality (more like statistics, but might also be useful), but I can't find out how to use it. The class is called "