I set an Android:process=":XX" for my particular activity to make it run in a separate process. However when the new activity/process init, it will call my Application:onCreate() which contains some application level initialization.
I'm thinking of avoiding duplication initialization by checking current process name.
So is there an API available?
Thanks.
The ability to view running processes in Android is found in the Developer Options. In order to do that, open the Settings app and locate About Phone. In the About Phone section, locate Build Number (Figure A). The Build Number of your device lists the date your version of Android was built.
Your Android application (process) can be killed at any time if it's in paused or stopped state . The state of your Activities, Fragments and Views will be saved.
Android Automatically Manages Processes When Android needs more system resources, it will start killing the least important processes first. Android will start to kill empty and background processes to free up memory if you're running low.
A process is considered to be in the foreground if any of the following conditions hold: It is running an Activity at the top of the screen that the user is interacting with (its onResume() method has been called). It has a BroadcastReceiver that is currently running (its BroadcastReceiver.
Full code is
String currentProcName = ""; int pid = android.os.Process.myPid(); ActivityManager manager = (ActivityManager) this.getSystemService(Context.ACTIVITY_SERVICE); for (RunningAppProcessInfo processInfo : manager.getRunningAppProcesses()) { if (processInfo.pid == pid) { currentProcName = processInfo.processName; return; } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With