Open android app from PUSH notification

前端 未结 4 1395
独厮守ぢ
独厮守ぢ 2021-02-06 02:41

Got a little problem that\'s been bugging me..

I\'ve set up my application to receive PUSH notifications from Urban Airship and that all works fine, but when I tap on a

4条回答
  •  情话喂你
    2021-02-06 03:34

    Create a pending Intent to start the activity and set it in notification using setLatestEventInfo.

    Example:

      Context context = getApplicationContext();
    CharSequence contentTitle = "My notification";
    CharSequence contentText = "Hello World!";
    Intent notificationIntent = new Intent(this, MyClass.class);
    PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
    notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
    

    More info can be found here

提交回复
热议问题