noircc
noircc

Reputation: 640

How do i retrieve my own app-uri programmatically in android?

Is there a way to get it through the context file or the package-manager? Have searched for it but didn't find anything.

Upvotes: 0

Views: 344

Answers (1)

Raghav Sood
Raghav Sood

Reputation: 82563

Just call getPackageName() on your context. You can call this in any Activity, Service, or basically anything that inherits from Context.

Other than that, if you want to access it somewhere without a context, just create a separate class to hold preknown values like this:

public class MyConstants {
    public static final String PACKAGE_NAME = "com.my.package";
}

and then access it anywhere in your app using MyConstants.PACKAGE_NAME wherever you need it.

Upvotes: 2

Related Questions