0

I want to be able to activate a broadcast receiver right when an app is installed from the play store. What is the best way to do this?

rgrasell
  • 99
  • 2
  • 11
  • do you want to receive broadcast only for your application installation or every application installation ? – rajpara Jun 30 '12 at 17:29
  • When you declare your BroadcastReceiver class in your app's manifest file then you already have what you want. – tiguchi Jun 30 '12 at 17:37
  • I want the broadcast receiver to be triggered right when the app that contains it is installed. – rgrasell Jun 30 '12 at 17:38
  • When your app is triggering that broadcast, then tough luck. The user has to start the app first. When you are talking about some system broadcast then your broadcast receiver gets called when that broadcast has been sent. – tiguchi Jun 30 '12 at 17:41

1 Answers1

1

I want to be able to activate a broadcast receiver right when an app is installed from the play store. What is the best way to do this?

This is not supported on any version of Android. And, on Android 3.1+, none of your BroadcastReceivers will run until something explicitly runs one of your components, such as the user launching an activity of yours from the home screen's launcher.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • @user1493324: AFAIK, it does not work on Android 3.1+ until the user runs the app manually. Plan B uses malware-style techniques, which were blocked by the changes in 3.1. – CommonsWare Jun 30 '12 at 17:55
  • That's too bad. Thanks though! – rgrasell Jun 30 '12 at 18:09
  • @CommonsWare: what about apps that signed with the system's signature? will they be able (similar to system privileged apps) to receive broadcast before explicitly started for the first time? – Tal Kanel Jul 27 '16 at 12:53
  • 1
    @TalKanel: I presume that there is a way for pre-installed apps to be pre-configured to be out of the stopped state. AFAIK, for apps installed by users, regardless of signature, the app is in the stopped state first. However, you're getting outside my area of expertise, as I do not deal with custom ROMs. – CommonsWare Jul 27 '16 at 12:56