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. OOT: Winphone 7 Bisa Akses AppStore

hehehehehe
canggih juga yak
http://gpgo.in/rz

-- 
*@yopiesuryadi*
www.gopego.com
http://about.me/yopie

-- 
===============
"

2. Qestion about Kernel Version Runing at Android2.2

HI Folks:
   I'm tring to bring up android2.2 and now the only available kernel is at
version 2.6.27
My question here is: what will be the problem if I using kernel2.6.27 +
android2.2?
  Thanks

Dennis

-- 

3. savedInstanceState null?

4. Asal Mula Maskot Hijau Android

5. Enter a number..

6. getThumbnails through droid incredible phoneStorage mount

7. Open tablet device? And whatever happened to the TI Blaze tablet?