activity-manager

ActivityManager.getRunningTasks is deprecated android

微笑、不失礼 提交于 2019-12-17 09:32:38
问题 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

How to use UsageStatsManager?

こ雲淡風輕ζ 提交于 2019-12-17 02:07:09
问题 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,

Got threadid=1: thread exiting with uncaught exception (group=0x41088930) on listview

南楼画角 提交于 2019-12-12 23:20:00
问题 i'm making an app that shows running apps icon on listview. there are no syntax problem (i think) but when i launch app and try to run activity, the app force closes and i got threadid=1: thread exiting with uncaught exception (group=0x41088930) and more error how can i fix this error? should i use Asynctask to load image to list view? or any solutions? (Logcat) 02-18 14:17:46.700: W/dalvikvm(18370): threadid=1: thread exiting with uncaught exception (group=0x41088930) 02-18 14:17:46.700: E

After notification button return to original activity

烈酒焚心 提交于 2019-12-11 13:27:28
问题 I wrote an app, that brings up a notification every certain time via an alarmIntent. The user clicks on the notification and gets into an activity. After doing something in this activity he should press a button to return to the original app he was in (like a browser, or the homescreen, etc.), before clicking on the notification. My problem is, that the user always returns to the main activity of my application. How can I change that? Thank you! 回答1: try adding this lines in your Activity

How to get all visible running applications package names?

霸气de小男生 提交于 2019-12-11 06:43:31
问题 I have a custom launcher which is always visible and it starts 3 different apps. Starting from Android N on each app icon click (on the custom launcher) I must check whether any of the 3 applications is currently running. If no app is running, the clicked icon should start the app normally. If any of them is currently running multi window mode must be turned on and show both of them. If 2 of them are running, the inactive one (which is in "onPause" state) should be replaced with the third.

Detect if another app is running

妖精的绣舞 提交于 2019-12-09 20:13:33
问题 Is it possible on Android to detect if another app is running? I need to trigger some action in my app when a Map application (like Waze or Google Maps) is running. 回答1: You can use ActivityManager class: final ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); final List<RunningTaskInfo> recentTasks = activityManager.getRunningTasks(Integer.MAX_VALUE); for (int i = 0; i < recentTasks.size(); i++) { Log.d("Executed app", "Application executed : "

clearApplicationUserData minimizes the app

[亡魂溺海] 提交于 2019-12-08 16:19:49
问题 I want to erase the data of my app programatically. I've found the method clearApplicationUserData. But when I run it, the app minimizes itself. That is, the app goes to background, like when it is pressed the home button. This is my code: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { ((ActivityManager)context.getSystemService(Context.ACTIVITY_SERVICE)) .clearApplicationUserData(); } else { // TODO } There is some way to erase data using this method without minimizing the app?

Android ActivityManager killBackgroundProcess not working

折月煮酒 提交于 2019-12-07 08:20:17
问题 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);

Is process name same as package name in android?

拜拜、爱过 提交于 2019-12-05 21:17:58
问题 By process I mean what we provide in android:process and by package I mean package in <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.osg.appkiller" android:versionCode="1" android:versionName="1.0" > More details Processes and Threads - Android Developer I wanted to get application names of all running apps. So this is what I did after looking at various sources (and it works). ActivityManager activityManager = (ActivityManager) getSystemService(Context

How to get the list of all non system apps in android

老子叫甜甜 提交于 2019-12-05 18:07:09
I am developing an application, in which i want to get the list of all non system apps. Here is my code part: TextView tv = new TextView(this); this.setContentView(tv); ActivityManager actvityManager = (ActivityManager) this.getSystemService( ACTIVITY_SERVICE ); PackageManager pm = this.getPackageManager(); List<PackageInfo> list =pm.getInstalledPackages(0); for(int i=0;i<list.size();i++) { System.out.println("list"+i+" "+list.get(i)); } for(PackageInfo pi : list) { try { ApplicationInfo ai=pm.getApplicationInfo(pi.packageName, 0); if (ai.sourceDir.startsWith("/data/app/")) { tv.setText(ai