Android-从通知点击恢复活动

时间:2018-08-13 15:49:07

标签: android

我想要做的是一项活动,该活动从抽屉流式传输音乐,而不是刷新,因为这会使同一首音乐播放两次。

        // Create an Intent for the activity you want to start
        Intent resultIntent = new Intent(this, SoundCloudActivity.class);
        // Create the TaskStackBuilder and add the intent, which inflates the back stack
        TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
        stackBuilder.addNextIntentWithParentStack(resultIntent);
        // Get the PendingIntent containing the entire back stack
        PendingIntent resultPendingIntent =
                stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);

NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(SoundCloudActivity.this, CHANNEL_ID)
                .setSmallIcon(R.drawable.video_icon_48)
                .setContentTitle("Music")
                .setContentText("Streaming....")
                .setColor(Color.parseColor("#009add"))
                .setAutoCancel(true)
                .setContentIntent(resultPendingIntent);

0 个答案:

没有答案