Check whether the application is enabled or disabled using the package

I want to check if the user is enabled or disabled by the user.

The only thing I know is that I can get this int

 int appstate= this.getPackageManager().getApplicationEnabledSetting("com.example.app"); 

How can I use this int to check if the application is enabled or disabled?

Example

 if(......){//is enabled } else{ //disabled } 
+6
source share
2 answers
 ApplicationInfo ai = getActivity().getPackageManager().getApplicationInfo("your_package",0); boolean appStatus = ai.enabled; 

Thanks Amir

+25
source

you can also use these constants according to the developer documentation - http://developer.android.com/reference/android/content/pm/PackageManager.html#getApplicationEnabledSetting(java.lang.String)

Returns the current resolved state for the component. It can be one of COMPONENT_ENABLED_STATE_ENABLED , COMPONENT_ENABLED_STATE_DISABLED or COMPONENT_ENABLED_STATE_DEFAULT . The latter means that the application state is enabled based on the initial information in the manifest, as shown in ComponentInfo.

+4
source

Source: https://habr.com/ru/post/973902/


All Articles