Opening a direct notification URL

3

I want to launch an app to open URLs that are redirected to the Play Store and I want it to just load the direct URL into the notification without opening any layout, and that appears in the android intent filter, Ex: (Finish this action using: Chrome, Browser, Redirect Browser). But I do not know how to do it. I started creating the code:

public class MainActivity  extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);


        public void alerta (View v) {

        Notification.Builder notification = new Notification.Builder(this);
        notification.setContentTitle("Carregando página da Web...");
        notification.setContentText("A Play Store se abrira ao concluir");
        notification.setSmallIcon((R.drawable.ic_launcherrb));
        notification.setSound(Uri.parse("/system/media/audio/notifications/Argon.ogg"));


        notification.build();

        NotificationManager nm = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
        int NOTIFICATION_ID = 0;
        nm.notify(NOTIFICATION_ID, notification.build());

}}

Can anyone help me?

    
asked by anonymous 10.12.2016 / 20:44

1 answer

4

You should create a PendingIntent as follows:

Intent intent= new Intent(Intent.ACTION_VIEW,Uri.parse(A_Sua_URL));
PendingIntent pIntent = PendingIntent.getActivity(MainActivity.this, 0, intent, 0);

and add it to the notification like this:

notification.setContentIntent(pIntent);
    
10.12.2016 / 22:38