Horyun Lee
Horyun Lee

Reputation: 1093

how to get an uid from application's own pamameter?

I would like to know an uid from application's own pamameter. I know how to get an uid from PackageManager with package name, however I have noticed that an application can send a fake package name or context which is created with fake package name. How can I create an API to determine exactly an uid from any app's own parameter? Or how to check this app is system app?

Upvotes: 1

Views: 1427

Answers (1)

Simon
Simon

Reputation: 11190

Sounds like you want to get the current app id. This should do the trick. Get the result of http://developer.android.com/reference/android/os/Process.html#myUid() and give it to http://developer.android.com/reference/android/content/pm/PackageManager.html#getPackagesForUid(int)

Upvotes: 1

Related Questions