How to get permission for the application for each application? How to do it programmatically on Android?

How to get detailed permission information for each application? how to do it programmatically?

I want to display "Application Permission Information for Each Application" in a TextView. But I try, but not good ??

Hello.java

import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.ListView; import android.content.Intent; import android.content.Context; import android.content.pm.*; import android.widget.TextView; import java.util.*; public class HelloSakez extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null); mainIntent.addCategory(Intent.CATEGORY_LAUNCHER); final ListView lw = (ListView) findViewById(R.id.listView1); final List<ResolveInfo> pkglist = lw.getContext().getPackageManager().queryIntentActivities(mainIntent, 0); final TextView tw = (TextView) findViewById(R.id.textView1); Iterator it = pkglist.iterator(); while(it.hasNext()){ ResolveInfo rf = (ResolveInfo)it.next(); tw.append(rf.toString()); } } } 

main.xml

 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <Button android:text="Button" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button> <ListView android:id="@+id/listView1" android:layout_height="wrap_content" android:layout_width="fill_parent"></ListView> <TextView android:text="TextView" android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView> </LinearLayout> 
+9
android
source share
4 answers

You need to use the PackageManager GET_PERMISSIONS flag .

Check this question .

+4
source share

Use the following code in your action:

I created StringBuffer appNameAndPermissions = new StringBuffer(); to add all applications and permissions.

It is working fine. I already tested it. If you have any questions, please let me know.

 StringBuffer appNameAndPermissions = new StringBuffer(); 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); appNameAndPermissions.append(packageInfo.packageName+"*******:\n"); //Get Permissions String[] requestedPermissions = packageInfo.requestedPermissions; if(requestedPermissions != null) { for (int i = 0; i < requestedPermissions.length; i++) { Log.d("test", requestedPermissions[i]); appNameAndPermissions.append(requestedPermissions[i]+"\n"); } appNameAndPermissions.append("\n"); } catch (NameNotFoundException e) { e.printStackTrace(); } 

Use the following permissions in the AndroidManifest.xml file:

<uses-permission android:name="android.permission.GET_TASKS"/>

+14
source share

Joker

To uninstall the application, use the code below

 Intent i = new Intent(Intent.ACTION_DELETE); i.setData(Uri.parse("package:com.package name")); startActivity(i); 

And to get permissions use getInstalledPackages (int) with the GET_PERMISSIONS flag

0
source share
  • To enable the application, go to the manifest file and see.

2. To uninstall the application, follow these steps: -

but. go to setup b. then open Application c. then open Application Management e. then select the application you want to uninstall. e. then click Uninstall and uninstall the application.

-3
source share

All Articles