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) {}
}
}