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. How to make the android source code and SDK successfully by cygwin?

Hi all:

     The code was downloaded successfully by cygwin. But when I make
it, the errors were as follows:
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=1.6
TARGET_PRODUCT=generic
TARGET_BUILD_VARIANT=eng
TARGET_SIMULATOR=
TARGET_BUILD_TYPE=release
TARGET_ARCH=arm
HOST_ARCH=x86
HOST_OS=windows
HOST_BUILD_TYPE=release
BUILD_ID=Donut
============================================
build/core/main.mk:359: sdk-only: javac available.
make: *** No rule to make target `/usr/lib/tools.jar', needed by `out/
target/com
mon/docs/offline-sdk-timestamp'.  Stop.


    I can make the NDK by cygwin and my tool chains are listed in the
following:
1. gcc version 3.4.4
2. GNU Make 3.81
3. java version "1.6.0_16

Dose anyone help me?
Thanks a lot!!

Chuck

--~--~---------~--~----~------------~-------~--~----~

2. How to caculator the time?

long startTime=System.currentTimeMillis();
// do something
long endTime=System.currentTimeMillis();
long spentTime=(endTime-startTime)/1000;

but if I change the system time in "//do something" , how to caculator
the spentTime?

the CPU running time?
--~--~---------~--~----~------------~-------~--~----~

3. Setting Focus

4. 802.1X configuration?

5. The application android has stopped unexpectedly

6. Need to know RPC design in android

7. How to build android source code and SDK correctly by cygwin?