5

I would like to add a Status Bar Notification for my Android App. This notification should be shown on the Status Bar after the App is installed. I have a background service for the App which is where I could put the notification code. How do I trigger the Notification only after the App is installed?

Any insight to solve this problem will be very helpful.

Thanks.

Jonas
  • 97,987
  • 90
  • 271
  • 355
Aakash
  • 2,829
  • 6
  • 40
  • 71

2 Answers2

9

There is a (major) exception to this rule. If your app was installed from the Android Market, the Market app will send an com.android.vending.INSTALL_REFERRER intent to your app upon installation. For example, AnySoftKeyboard displays a custom notification after it is installed:

enter image description here

It makes a lot of sense for a keyboard to display a notification because new keyboards are disabled by default, so a notification can prompt users to enable it. Otherwise most users would assume the install failed when their keyboard wasn't on the list of input devices (followed by angry support emails, or even worse -- BAD RATINGS AND REFUNDS!).

Refer to this page for more information: Get referrer after installing app from Android Market. I also found this code in the AnySoftKeyboard manifest file (located at http://softkeyboard.googlecode.com):

    <receiver android:name="com.anysoftkeyboard.receivers.AnySoftKeyboardInstalledReceiver" android:exported="true">
        <intent-filter>
            <action android:name="com.android.vending.INSTALL_REFERRER" />
        </intent-filter>
    </receiver>

I hope this helps,

Barry

Community
  • 1
  • 1
Barry Fruitman
  • 11,209
  • 10
  • 64
  • 121
3

How do I trigger the Notification only after the App is installed?

You cannot do this. None of your code will run immediately upon install.

CommonsWare
  • 910,778
  • 176
  • 2,215
  • 2,253
  • Thanks for the reply. So I checked My Verizon App one more time and the notification for that App triggers when the App is opened the first time...so I guess that can be a workaround solution. So lets say my first activity is abc.java. I should be able to put the notification code in there, right? – Aakash Jan 29 '11 at 21:12
  • @Aakash: Yes. Though, really, there should be a point to having the notification. Putting an icon in the status bar should have a purpose *for the user*. For example, if you have a service that the user will perceive (e.g., a music player), putting up a notification via `startForeground()` makes sense, both so the user can quickly return to your app to make it stop, and so the service will not be killed quite so quickly. But do not just put up a notification because you feel like it -- have an honest, valid value proposition for the user. – CommonsWare Jan 29 '11 at 21:18
  • My intent of putting the notification is that I want the user to know that the App comes with an AppWidget which is an integral part of the App and they should at this point put it on their screen. I totally understand what you are saying and I would not do it without a valid requirement. – Aakash Jan 29 '11 at 21:21
  • @Aakash: That is **not** a valid requirement, IMHO. That is little better than your saying that you want the status bar icon there because you think you have a cute logo. If you want to let the user know about this feature, tell them in your application (e.g., tip of the day when launching the app). – CommonsWare Jan 29 '11 at 21:23
  • I have that Tip already in the App. Is there a better in making sure that the AppWidget is put on the screen by the User. I really appreciate your help. – Aakash Jan 29 '11 at 21:28
  • @CommonsWare What about Barry Fruitman answer? It proves that code can run upon installation. – M.ES Jul 04 '12 at 11:16
  • @CommonsWare I tried Barry Fruitman's answer on a 4.0.3 emulator and it worked!! :) – M.ES Jul 05 '12 at 10:07