How to automatically Open the app without user action on receiving a push on Android

后端 未结 3 1823
轻奢々
轻奢々 2021-01-15 16:42

I am trying to open an app when a push notification is received.

Code:

public class GCMIntentService extends GCMBaseIntentService {

    public GCMIn         


        
3条回答
  •  遥遥无期
    2021-01-15 17:18

    public void getnotification(View view) {

           NotificationManager notificationmgr =(NotificationManager)getSystemService(NOTIFICATION_SERVICE);
           Intent intent = new Intent(this,resultpage.class);
           PendingIntent p = PendingIntent.getService(this,(int) System.currentTimeMillis(),intent,0);
    
    
           Notification n = null;
           if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) {
               n = new Builder(this)
                                    .setSmallIcon(R.mipmap.ic_launcher)
                                   .setContentTitle("Hello android user here")
                                   .setContentText("welcome to notification serrvice")
                                   .setContentIntent(p)
                                   .build();
    
               notificationmgr.notify(0,n);
    
           }
    

提交回复
热议问题