Android - 如何拦截 'Install application' Intent

标签 android android-intent google-play apk

好的,所以不完全确定这是可能的...

但尝试编写一个应用程序,以便我可以在执行以下任何 Activity 之前运行一些代码。

1) APK从网络下载,市场推出安装程序

2) 在安卓市场上按下安装按钮

是否可以拦截并提示这些事件,或者 Google 是否已将这些内容锁定得非常严密?

最佳答案

这本身不是答案,但我在这里找不到任何评论工具。对不起。 我也有这个问题。我希望能够检测到新的应用程序安装。我知道这是可能的 - 例如,当您安装新应用程序时,应用程序 Apps to SD 会发布一条通知,单击该应用程序会打开一个对话框,将新应用程序移动到 SD 卡。 到目前为止,我所能想到的是这样的: list .xml:

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

IntentReciever.java:

public class IntentReceiver extends BroadcastReceiver {
  @Override
  public void onReceive(Context context, Intent intent) {
    context.startService(new Intent(context, YourService.class));
  }
}

然后创建 YourService 并调用 onCreate(),然后调用 onStartCommand()。但是,我无法对此进行调试或成功显示来自服务类的任何通知,因此我不完全确定这是否有效。我已经让它适用于其他接收器,例如 android.intent.action.BOOT_COMPLETED。

关于Android - 如何拦截 'Install application' Intent ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3510544/

相关文章:

Android Studio 渲染错误

android - 跟踪电话通话时间

android - 使用 Intent 从图库中选择图像

android - 如果有一种方法可以在不上传的情况下在 google play 上检查设备兼容性

android - INSTALL_FAILED_TEST_ONLY 在 Android Studio 2.4 预览版 7

php - Retrofit v2.0.0-beta2 如何使用 RequestBody 上传文件

java - 带有删除和添加通知的自定义数组列表

android - Android 中 Onclick 上带有 bool 值的图像

android - 将 APK 上传到 Android Market 时出现 minSdkVersion 错误

android - Play 商店不接受我的带有 Flutter 的 AppBundle?