Android - How to intercept the 'Install application' intent

后端 未结 2 1138
独厮守ぢ
独厮守ぢ 2020-11-30 03:12

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

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

2条回答
  •  没有蜡笔的小新
    2020-11-30 04:10

    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:

    ...
    
      
        
        
        
      
    
    ...
    

    IntentReciever.java:

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

    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.

提交回复
热议问题