如何获得应用程序的权限为每个应用程序?如何以编程方式做到这一点在Android? [英] How to get App's Permission for each app? how to do it programmatically on Android?

查看:107
本文介绍了如何获得应用程序的权限为每个应用程序?如何以编程方式做到这一点在Android?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何获得应用程序的权限的详细信息为每个应用程序?如何做到这一点编程?

How to get App's Permission Detail for each app? how to do it programmatically?

照片: http://f.anyhub.net/2eKL

我要显示的应用程序的权限的详细信息为每个应用程序上的TextView。 但我尝试,但不正常?

I want to display "App's Permission Detail for each app" on TextView. But I try it but Not Ok??

============= Hello.java ===========

=============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中========================

============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>

=========================================

=========================================

推荐答案

您需要使用PackageManager的的 GET_PERMISSIONS 标志。

You need to use PackageManager's GET_PERMISSIONS flag.

检查这个问题

这篇关于如何获得应用程序的权限为每个应用程序?如何以编程方式做到这一点在Android?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆