Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get uid of some other app whose package name I know in android?

Tags:

android

I want to get uid of whatsapp in android, and I know Whatsapp's package name. How can I do this? Thank you.

like image 870
codelyzer Avatar asked Jan 26 '17 08:01

codelyzer


People also ask

How do I find my app UID?

Use android. os. Process. myUid() to get the calling apps UID directly.

How do I find my UID on Android?

There are several ways to know your Android Device ID, 1- Enter *#*#8255#*#* in your phone dialer, you'll be shown your device ID (as 'aid') in GTalk Service Monitor. 2- Another way to find the ID is by going to the Menu >Settings > About Phone > Status.

Can two apps have same package name?

You can't do this. Each Android application has a package name, which effectively defines the Java/Dalvik namespace that its classes occupy. You cannot have two packages of the same name installed because it would create overlapping namespaces, which is why it always replaces the old one when you install a new one.

How do I find the package name of an app?

You can find an app's package name in the URL of your app's Google Play Store listing. For example, the URL of an app page is play.google.com/store/apps/details? id=com. example.


1 Answers

I found WhatsApp's uid with the following code

int uid = 0;
    try {
        uid = this.getPackageManager().getApplicationInfo("com.whatsapp", 0).uid;
    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
    }
like image 92
codelyzer Avatar answered Sep 23 '22 21:09

codelyzer