I'm stuck in this trouble and I can't figure it out. I googled a lot, but nothing gave me an answer.
I explain:
I have a BroadCastReceiver which runs in a different process (android:process=":anotherProcess"
)
I want to get this process name inside my BroadcastReceiver.
In this case for example, it could be: com.my.package:anotherProcess
Is it possible? How can I do it?
I've found a way. For anyone who will need this:
int id = Process.myPid();
String myProcessName =context.getPackageName();
ActivityManager actvityManager = (ActivityManager)context.getSystemService( context.ACTIVITY_SERVICE );
List<RunningAppProcessInfo> procInfos = actvityManager.getRunningAppProcesses();
for(RunningAppProcessInfo procInfo : procInfos) {
if (id == procInfo.pid)
{
myProcessName = procInfo.processName;
}
}
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