Skip to content

Instantly share code, notes, and snippets.

@amsterdatech
Created July 13, 2016 03:10
Show Gist options
  • Save amsterdatech/05761dde91d739fb1a2695e2913226ee to your computer and use it in GitHub Desktop.
Save amsterdatech/05761dde91d739fb1a2695e2913226ee to your computer and use it in GitHub Desktop.
final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
final List pkgAppsList = context.getPackageManager().queryIntentActivities( mainIntent, 0);
or
final PackageManager pm = getPackageManager();
//get a list of installed apps.
List<ApplicationInfo> packages = pm.getInstalledApplications(PackageManager.GET_META_DATA);
for (ApplicationInfo packageInfo : packages) {
Log.d(TAG, "Installed package :" + packageInfo.packageName);
Log.d(TAG, "Source dir : " + packageInfo.sourceDir);
Log.d(TAG, "Launch Activity :" + pm.getLaunchIntentForPackage(packageInfo.packageName));
}
//To know the permissions
PackageManager p = this.getPackageManager();
final List <PackageInfo> appinstall=p.getInstalledPackages(PackageManager.GET_PERMISSIONS|PackageManager.GET_RECEIVERS|
PackageManager.GET_SERVICES|PackageManager.GET_PROVIDERS);
for(PackageInfo pInfo:appinstall){
//PermissionInfo[] permission=pInfo.permissions;
String[] reqPermission=pInfo.requestedPermissions;
ServiceInfo[] services=pInfo.services;
ProviderInfo[] providers=pInfo.providers;
int versionCode=pInfo.versionCode;
Log.d("versionCode-package ",Integer.toString(versionCode));
Log.d("Installed Applications", pInfo.applicationInfo
.loadLabel(pm).toString());
Log.d("packegename",pInfo.packageName.
toString());
if(reqPermission!=null)
for(int i=0;i<reqPermission.length;i++)
Log.d("permission list",reqPermission[i]);
//Ask Android to handle a remove
Uri packageURI = Uri.parse("package:"+"your.packagename.here");
Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, packageURI);
startActivity(uninstallIntent);
//Or just disable the app component - name is the name of Component as in the manifest : MainActivity, SignInService, MediaProvider
packageManager.setComponentEnabledSetting(
getComponentName(packageName, name),
PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
PackageManager.DONT_KILL_APP);
//References
//http://stackoverflow.com/questions/15679601/how-to-hide-the-application-from-the-installed-application-list
//http://stackoverflow.com/questions/891141/is-it-possible-to-programmatically-uninstall-a-package-in-android
//http://stackoverflow.com/questions/4461504/determine-list-of-permissions-used-by-an-installed-application-in-android
//http://stackoverflow.com/questions/2695746/how-to-get-a-list-of-installed-android-applications-and-pick-one-to-run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment