I want to create a Notification that, when clicked, opens my application on Android market.
I have tried several things, like below:
NotificationCompat.Builder builder = new NotificationCompat.Builder(application);
builder.setAutoCancel(true);
// (set titles, icon, ...)
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("market://details?id=com.android.example"));
builder.setContentIntent(PendingIntent.getActivity(application, 0, intent, 0));
Notification notification = builder.build();
NotificationManager manager = (NotificationManager) application.getSystemService(Context.NOTIFICATION_SERVICE);
manager.notify(0, notification);
However, when clicked, nothing happens. Anyone who knows how to get this to work?
If you seriously want to make a notification from your app to ask them to update (so that everyone gets the notification, whatever their Google play settings are, then you will have to make a web service which returns the number of the newest version. You can then compare that inside your app and post a notification.
So I solved like this: when you receive a notification and tap on it, the app will open (usually it opens the app main activity) and, in the extras, you can find some information about that notification. You can add key/value params to the notifications you're sending to registered devices.
A notification is a message that Android displays outside your app's UI to provide the user with reminders, communication from other people, or other timely information from your app. Users can tap the notification to open your app or take an action directly from the notification.
The code posted worked. I might have been having problems with the HTTP version of the market link. Like http://play.google.com/store/apps/details?id=<package_name>
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With