How to know the caller of ContentProvider

by James Wang » Thu, 17 Dec 2009 18:31:27 GMT


Sponsored Links
 We are developing a ContentProvider which is supposed to serve for
specified packages. So we want to get the caller package name. Is
there any way to achieve that?

Thanks in advanced.

James

--



How to know the caller of ContentProvider

by James Wang » Fri, 18 Dec 2009 09:12:50 GMT


 We got a solution here:
int pid = Binder.getCallingPid();

And pass the pid to getProcessNameFromPid below:

private String getProcessNameFromPid(int givenPid) {
ActivityManager am = (ActivityManager)
getContext().getSystemService(Activity.ACTIVITY_SERVICE);

List<ActivityManager.RunningAppProcessInfo> lstAppInfo =
am.getRunningAppProcesses();

for(ActivityManager.RunningAppProcessInfo ai : lstAppInfo) {
if (ai.pid == givenPid) {

return ai.processName;
}
}
return null;
}

I wonder whether there is any other way to do it.

--


Sponsored Links


Other Threads

1. Paging adityo

Maaf numpang jalum
Bro tyo di hub nyaut

Hehehehe 
Gtalk ye

Thanks mods
Ch 
sent by jave aka jupe

-- 
"Indonesian Android Community [id-android]" 

2. OOT:alternatif IPad

moga2 tidak repost,
http://mashable.com/2010/01/27/9-upcoming-tablet-alternatives-to-the-apple-ipad/,
ada yang mau siap2 nabung mulai sekarang?
*tidur lagi ahhh*

-- 
"Indonesian Android Community [id-android]" 

3. permission denied on devce

4. SMSan di Android?

5. aPad/iRobot 2nd generatio

6. ask : download manager yang bagus

7. Help : Gmail amplop merah gak bisa save attachment