Open application after clicking on Notification

后端 未结 11 2015
南笙
南笙 2020-11-22 13:52

I have a notification in my app with the following code:

//Notification Start

   notificationManager = (NotificationManager) getSystemService(Context.NOTIFI         


        
11条回答
  •  情话喂你
    2020-11-22 14:42

    public void addNotification()
    {
        NotificationCompat.Builder mBuilder=new NotificationCompat.Builder(MainActivity.this);
        mBuilder.setSmallIcon(R.drawable.email);
        mBuilder.setContentTitle("Notification Alert, Click Me!");
        mBuilder.setContentText("Hi,This notification for you let me check");
        Intent notificationIntent = new Intent(this,MainActivity.class);
        PendingIntent conPendingIntent = PendingIntent.getActivity(this,0,notificationIntent,PendingIntent.FLAG_UPDATE_CURRENT);
    
        mBuilder.setContentIntent(conPendingIntent);
    
        NotificationManager manager=(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
        manager.notify(0,mBuilder.build());
        Toast.makeText(MainActivity.this, "Notification", Toast.LENGTH_SHORT).show();
    
    }
    

提交回复
热议问题