Identifying Stand-Alone Services on Android -


I'm trying to figure out whether a process is an app or standalone service. (Ie - not a local service, but one who is running in its own process)

I am using ActivityManager.getRunningAppProcesses to get the running application process and also using ActivityManager.getRunningServices Services to run (unfortunately, the getRunningTasks API has been deprecated).

When I compare the results of both, I think the same process name & amp; In both the ID (PID)

I, the services whose process name are also present in the list taken from RunningAppProcesses are in relation to those services that local services that live within the application process (I Let's know if I'm wrong in this, assumption).

The only way to find out is that the process is a single service, take both the list and then remove all the people from the service process list, whose PID matches the one in the app . List The result will serve me alone

Is this an easy way to get this information?

You should be able to get along with ActivityManager.getRunningServices . Here's a way to tell you that it's its own process in every RunningServiceInfo result (to avoid getting packageManager every time, it also passes in)

< Pre> Personal Boolean serviceHasDifferentProcess (PackageManager, RunningServiceInfo RSI) throws PackageManager.NameNotFoundException {ComponentName cn = rsi.service. String pn = cn.getPackageName (); PackageInfo pi = pm.getPackageInfo (pn, 0); ApplicationInfo ai = pi.applicationInfo; String service process name = rsi.process; String app process name = ai.processName; Return service process name (applicationprocessname); }

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -