Arun
Arun

Reputation: 99

How to get installed applications permissions

I need to develop an android application to detect malwares.

I am looking to develop this based on permissions used by all the applications installed. Please let me know how to identify the permissions used by other applications

Upvotes: 9

Views: 15375

Answers (2)

orcaman
orcaman

Reputation: 6561

You can use this REST API to get details about an app, including permissions required by the app. For instance, to see what permissions WhatsApp is requiring, locate the "permissions" node in the response from this GET request: http://playstore-api.herokuapp.com/playstore/apps/com.whatsapp

More notes about how to make API calls for this could be found on the GitHub page.

Upvotes: -1

evilone
evilone

Reputation: 22740

You can get all installed applications permissions like this.

  • Get all installed applications
  • Iterate over the applications
  • Get each application permissions list
  • Iterate over the each permission
PackageManager pm = getPackageManager();
List<ApplicationInfo> packages = pm.getInstalledApplications(PackageManager.GET_META_DATA);

for (ApplicationInfo applicationInfo : packages) {
   Log.d("test", "App: " + applicationInfo.name + " Package: " + applicationInfo.packageName);

   try {
      PackageInfo packageInfo = pm.getPackageInfo(applicationInfo.packageName, PackageManager.GET_PERMISSIONS);

      //Get Permissions
      String[] requestedPermissions = packageInfo.requestedPermissions;

      if(requestedPermissions != null) {
         for (int i = 0; i < requestedPermissions.length; i++) {
            Log.d("test", requestedPermissions[i]);
         }
      }
   } catch (NameNotFoundException e) {
      e.printStackTrace();
   }
}

Upvotes: 26

Related Questions