Good afternoon, the android has a panel of running processes (with a long press on the system button), if you select a process that is running, it will be deployed. How to implement the same behavior programmatically? In my case, there is a notification that pops up when a push message is received, I want to check when the user clicks on it, if the application process is running, and if so, deploy a new session if not. How can I do it?
- oneThis is not a panel of running processes, but a list of recent applications. Some of the applications in this list (if not all) are usually not running - lsillarionov 6:58 pm
- True, but nonetheless. Is there a way to check if the process is running and restore the application if yes? - iamthevoid
- check the static instance of some Activity. If it exists, then the application is running. - Vladyslav Matviienko
- see my answer below - iamthevoid
|
1 answer
Apparently, where HomeActivity is the main activity:
NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); Notification notification = new Notification(icon, message, when); Intent notificationIntent = new Intent(context, HomeActivity.class); notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent intent = PendingIntent.getActivity(context, 0, notificationIntent, 0); notification.setLatestEventInfo(context, title, message, intent); notification.flags |= Notification.FLAG_AUTO_CANCEL; notificationManager.notify(0, notification); - This code restarts the application if it functions, and I need it to unfold in this case - iamthevoid
- @iamthevoid and look here - stackoverflow.com/q/31448840/1159507 - anber
|