activity-manager

Android ActivityManager killBackgroundProcess not working

為{幸葍}努か 提交于 2019-12-05 12:39:34
I am using eclipse. I am trying to kill a process in my application. However, in eclipse it does not seem to know the hint for killBackgroundProcess from the ActivityManager and it will not let me proceed. I read that you have to have permissions to kill background processes and already added the permission which it did not recognize either from the manifest. Here is the code that I am trying to use: ActivityManager activityManager = (ActivityManager)this.getSystemService(ACTIVITY_SERVICE); activityManager.killBackgroundProcess(myProcessId); Make sure you are targeting API level 8, as that

Android: UsageStatsManager not returning correct daily results

瘦欲@ 提交于 2019-12-03 13:54:29
问题 I'm attempting to query UsageStats from UsageStatsManager , with the aim of returning all app packages that were used daily and for how long. The Code: public static List<UsageStats> getUsageStatsList(Context context){ UsageStatsManager usm = getUsageStatsManager(context); Calendar calendar = Calendar.getInstance(); long endTime = calendar.getTimeInMillis(); calendar.add(Calendar.DAY_OF_YEAR, -1); long startTime = calendar.getTimeInMillis(); List<UsageStats> usageStatsList = usm

Get (real) foreground process using activityManager.getRunningAppProcesses()

…衆ロ難τιáo~ 提交于 2019-12-03 10:56:59
I am trying to determine the currently visible application for the user. To do so, I use the activityManager.getRunningAppProcesses() method. I know that the method is not supported as off Android 5.1.1 - this is ok. In the beginning it worked like charm, I am iterating through the list of RunningAppProcessInfos and check for the importance. tl;dr What is the correct method to get current foreground process and prevent false postives? How is the order of the list done - the API says it is not specified. Is there a way to order them correctly? What I have done: Unfortunately the list returned

Android: UsageStatsManager not returning correct daily results

♀尐吖头ヾ 提交于 2019-12-03 03:12:02
I'm attempting to query UsageStats from UsageStatsManager , with the aim of returning all app packages that were used daily and for how long. The Code: public static List<UsageStats> getUsageStatsList(Context context){ UsageStatsManager usm = getUsageStatsManager(context); Calendar calendar = Calendar.getInstance(); long endTime = calendar.getTimeInMillis(); calendar.add(Calendar.DAY_OF_YEAR, -1); long startTime = calendar.getTimeInMillis(); List<UsageStats> usageStatsList = usm.queryUsageStats(UsageStatsManager.INTERVAL_DAILY,startTime, endTime); return usageStatsList; } I have an alarm that

How to get all the tasks that are running currently

你离开我真会死。 提交于 2019-12-01 17:24:26
I want to get all the tasks that are running in android.I found getRunningTasks in ActivityManager but from android-5.0 the getRunningTasks may not give all the tasks (in my case it's give the home screen and my application). In addition is it possible to find the task that the user is currently interacting with? Any help would be greatly appreciated. Thanks. Edit : I am using the following piece of code.But it's giving me only one process (that's my app).Even if i open other apps it's not showing them.I am running this on One Plus2. @Override protected void onHandleIntent(Intent intent) { new

How to get all the tasks that are running currently

喜夏-厌秋 提交于 2019-12-01 16:35:46
问题 I want to get all the tasks that are running in android.I found getRunningTasks in ActivityManager but from android-5.0 the getRunningTasks may not give all the tasks (in my case it's give the home screen and my application). In addition is it possible to find the task that the user is currently interacting with? Any help would be greatly appreciated. Thanks. Edit : I am using the following piece of code.But it's giving me only one process (that's my app).Even if i open other apps it's not

Android M: How can I get the current foreground activity package name(from a service)

大憨熊 提交于 2019-11-30 20:57:05
It is easy to get a list of running tasks from the ActivityManager service on Android L, and the current active task is returned first. But it don't work on Android M any more, the return list only contains my app task. Is there any way to settle it? My code: List<ActivityManager.RunningAppProcessInfo> runningAppProcessInfos = activityManager.getRunningAppProcesses(); for (int i = 0; i < runningAppProcessInfos.size(); i++) { ActivityManager.RunningAppProcessInfo runningAppProcessInfo = runningAppProcessInfos.get(i); if (runningAppProcessInfo.importance == ActivityManager.RunningAppProcessInfo

List of all of the activities in our application that are running on the device

眉间皱痕 提交于 2019-11-30 08:46:25
How to get the list of all activities in our application that are running on the device. For example: pdf generation and email activities included. I can check for activities with the code like: ActivityManager am = (ActivityManager) this.getSystemService(ACTIVITY_SERVICE); // get the info from the currently running task List< ActivityManager.RunningTaskInfo > taskInfo = am.getRunningTasks(1); Log.d("topActivity", "CURRENT Activity ::" + taskInfo.get(0).topActivity.getClassName()); ComponentName componentInfo = taskInfo.get(0).topActivity; componentInfo.getPackageName(); This will however give

Dealing with Samsung SPCM killer

吃可爱长大的小学妹 提交于 2019-11-28 20:58:35
Lately we acquired a new Galaxy S6 with Android 5.1.1 and we are having some troubles with the new Samsung SPCM memory manager that comes with it. It is aggressively closing our app's background service, which even though is set to START_STICKY, it is not being restarted. Additionally, the service takes no more than 5MB of RAM, but still somehow we end up with the lowest score of the SPCM algorithm and gets chosen to be killed. This is our service: Public class IncomingService extends Service { @Override public int onStartCommand(Intent intent, int flags, int startId) { super.onStartCommand

Cannot get foreground activity name in Android Lollipop 5.0 only

℡╲_俬逩灬. 提交于 2019-11-27 11:42:42
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.getRunningTasks(1).get(0); // get // list // of // running // tasks String foregroundTaskAppName = null;