What Intent Filter can I use to capture intent calls to the permissions screen on the Android Market?

一曲冷凌霜 提交于 2019-12-25 05:15:38

问题


I am creating an app that warns users about strange permission requests before they download an app from the Android Market (such as a wallpaper app that requests to read a user's contact information). Is there a way to capture the intent called when a user presses the install button and is shown the list of uses-permissions?


回答1:


There's no way of doing this that I know of. You can show the user your dialog right after the user installs the app instead (in most cases, before they run it):

AndroidManifest.xml

<receiver android:name=".Receiver">
    <intent-filter>
        <action android:name="android.intent.action.PACKAGE_ADDED" />
        <action android:name="android.intent.action.PACKAGE_CHANGED"/>
        <data android:scheme="package"/>
    </intent-filter>
</receiver>

Receiver.java

public class Receiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
          try {
              PackageManager manager = this.getPackageManager();
              PackageInfo info = manager.getPackageInfo(
                  intent.getData().getSchemeSpecificPart(), 0);
              Toast.makeText(context, "Look at these suspicious permissions:"+
                  info.permissions, Toast.LENGTH_LONG).show();
          } catch (Exception e) {}
    }
}


来源:https://stackoverflow.com/questions/8040597/what-intent-filter-can-i-use-to-capture-intent-calls-to-the-permissions-screen-o

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!