Android的 - 如何拦截“安装应用程序的意图意图、应用程序、Android

2023-09-12 04:08:37 作者:butterfly knot 蝴蝶结

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

OK, so not entirely sure this is possible...

但是,试图写一个应用程序,这样我可以运行一些code之前任何下列活动进行。

But trying to write an application so that I can run some code before any of the following activities are performed.

1),APK是从网络和市场下载安装程序启动

1) APK is downloaded from web and market launches installer

2)安装按钮是pssed Android电子市场中$ P $

2) Install button is pressed on android market

是否有可能拦截并提示这些事件,或者有谷歌锁定的东西倒也颇紧?

Is it possible to intercept and prompt on these events, or has Google locked that stuff down quite tightly?

推荐答案

这是不是一个答案本身,但我找不到任何注释工具在这里。抱歉。 我在和这个问题。我希望能够发现新的应用程序安装。我知道这是可能的 - 例如,应用程序,应用程序到SD岗位,当你安装一个新的应用程序,点击后打开一个对话框来移动新的应用程序到SD卡的通知。 到目前为止,我已经能够计算是这样的: manifest.xml的:

This isn't an answer per se, but I can't find any commenting tool here. Sorry. I'm having this issue as well. I would like to be able to detect new application installs. I know it is possible - for example, the app Apps to SD posts a notification when you install a new app that when clicked opens a dialog to move that new app to the sd card. So far, all I've been able to figure is like this: manifest.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:

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。

YourService is then created and calls onCreate() then onStartCommand(). However, I haven't been able to debug this or successfully display any notifications from the service class, so I'm not entirely sure this works. I have gotten this to work for other Receivers like android.intent.action.BOOT_COMPLETED.