Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Notification to open Android Market

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?

like image 648
foens Avatar asked Jan 26 '13 20:01

foens


People also ask

How do I notify people of an Android app update?

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.

How do I see open app notifications Android?

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.

What are general notifications on Android?

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.


1 Answers

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>.

like image 165
foens Avatar answered Sep 30 '22 07:09

foens