android-recents

Disable recent tasks button on Android 5.0

天大地大妈咪最大 提交于 2020-11-29 11:01:59
问题 I am working on an application that needs to suppress the recent apps button as it is done in the Toddler Lock application. What I want is user should not be able to exit my application by pressing the recent apps button. In toddler lock (https://play.google.com/store/apps/details?id=marcone.toddlerlock&hl=en) whenever you press the recent apps button the screen flashes a bit but the app return to its own activity. Even if we press the recent apps button multiple times in quick succession and

Disable recent tasks button on Android 5.0

人走茶凉 提交于 2020-11-29 11:00:06
问题 I am working on an application that needs to suppress the recent apps button as it is done in the Toddler Lock application. What I want is user should not be able to exit my application by pressing the recent apps button. In toddler lock (https://play.google.com/store/apps/details?id=marcone.toddlerlock&hl=en) whenever you press the recent apps button the screen flashes a bit but the app return to its own activity. Even if we press the recent apps button multiple times in quick succession and

How to exclude from recents an exported activity?

半世苍凉 提交于 2020-02-20 08:18:21
问题 I have an app with an exported activity that can be invoked from other apps (Specifically the sharing action - android.intent.action.SEND ) How can an exported activity be excluded from recents? I don't see a way to set the FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS flag, because it is invoked from the outside. The reason I want to do this is because this intent becomes the last one in my activity stack, thus when clicking on the recents, a file is being re-shared instead of the main activity to pop

How to exclude from recents an exported activity?

心已入冬 提交于 2020-02-20 08:17:48
问题 I have an app with an exported activity that can be invoked from other apps (Specifically the sharing action - android.intent.action.SEND ) How can an exported activity be excluded from recents? I don't see a way to set the FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS flag, because it is invoked from the outside. The reason I want to do this is because this intent becomes the last one in my activity stack, thus when clicking on the recents, a file is being re-shared instead of the main activity to pop

Handle app closing event from Launcher's menu

纵然是瞬间 提交于 2020-01-02 07:49:48
问题 What I want to do is to know when user closes the app from Android Launcher's menu, which gets opened on home button long click: I want to do some operations when user closes the app. Actually, I want user to logout each time he leaves the app, but as long as he can close app in this was too, I have to handle this event and then make my operations. I've tried to google this one, but I couldn't find anything considering this. I don't want to override onStop() or onDestroy(), as long as the

How to not show app on recent apps list in ICS? excludeFromRecents doesn't work

泪湿孤枕 提交于 2020-01-02 04:07:08
问题 I know it should be achievable be either android:excludeFromRecents="true" in android manifest or Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS Intent flag. Problem is, that doesn't work if application is currently being shown - when Recent Apps button is clicked, application is always shown in the first place, allowing for quick killing of the application (by swiping it). Not good for an alarm clock app. Music Service keeps on playing fortunately and user can get back to finishing alarm by the

How to get list of recent apps with Android API 21 Lollipop?

末鹿安然 提交于 2019-12-18 04:19:19
问题 I'm creating a home launcher and I want to have a compatibility with the Android 5.0, Lollipop. I want to get a list of recent apps on the launcher. But since ActivityManager.getRecentTasks() no longer works in API 21, how can I do this ? 回答1: String topPackageName ; if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { UsageStatsManager mUsageStatsManager = (UsageStatsManager)getSystemService("usagestats"); long time = System.currentTimeMillis(); // We get usage stats for the last 10

How to check if “android.permission.PACKAGE_USAGE_STATS” permission is given?

六月ゝ 毕业季﹏ 提交于 2019-12-17 05:03:10
问题 Background I'm trying to get app-launched statistics, and on Lollipop it's possible by using the UsageStatsManager class, as such (original post here): manifest: <uses-permission android:name="android.permission.PACKAGE_USAGE_STATS" tools:ignore="ProtectedPermissions"/> opening the activity that will let the user confirm giving you this permission: startActivity(new Intent(Settings.ACTION_USAGE_ACCESS_SETTINGS)); getting the stats, aggregated : private static final String USAGE_STATS_SERVICE

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,

Detect when app is killed from recent apps list in android O and P

我是研究僧i 提交于 2019-12-10 17:42:28
问题 Use case is I have to send logout request to server when app get killed from recent lists. I use onTaskRemoved to handle that however in Android O and P I get notification bar saying "app is running" that I want to avoid. Here is how I run foreground service: if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); channelId = "my_service_channel_id"; String