click on notification to go current activity

后端 未结 5 1441
借酒劲吻你
借酒劲吻你 2020-12-03 08:18

i am using this solution : How to make notification intent resume rather than making a new intent?

I works fine when i run my app normally.. however my app has a sha

5条回答
  •  遥遥无期
    2020-12-03 08:43

        Notification.Builder mBuilder =
                new Notification.Builder(this)
                .setSmallIcon(R.drawable.cmplayer)
                .setContentTitle("CoderoMusicPlayer")
                .setContentText("PLayer0!");
    
        Intent resultIntent = new Intent(this, AndroidBuildingMusicPlayerActivity.class);
        resultIntent.setAction(Intent.ACTION_MAIN);
        resultIntent.addCategory(Intent.CATEGORY_LAUNCHER);
    
        PendingIntent pendingIntent = PendingIntent.getActivity(this, 0,
                resultIntent, 0);
    
        mBuilder.setContentIntent(pendingIntent);
        NotificationManager mNotificationManager =
            (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
        mNotificationManager.notify(1, mBuilder.build());
    

    Just Copy the code and paste it in your main launcher activity.

提交回复
热议问题