繁体   English   中英

如何通过单击通知打开带有进度的活动

[英]How to open an activity with its progress by clicking on the notification

Intent open = new Intent(this, WorkoutActivity.class);
PendingIntent openContent = PendingIntent.getActivity(this, 0, open, PendingIntent.FLAG_UPDATE_CURRENT);

String nDistance = Double.toString(lastDistance);
String nSpeed = String.valueOf(speed);
NotificationCompat.Builder notification = new NotificationCompat.Builder(this, CHANNEL_ID)
            .setSmallIcon(R.mipmap.icon_logo_round)
            .setContentTitle(sWorkoutName.getText())
            .setStyle(new NotificationCompat.BigTextStyle().bigText("Distance Covered : " + nDistance + " Kms" + '\n' + "Time : " + time + '\n' + "Speed : " + nSpeed + " km/hr"))
            .setOnlyAlertOnce(true)
            .setPriority(NotificationCompat.PRIORITY_DEFAULT)
            .setContentIntent(openContent);

notificationManager.notify(1, notification.build());

嗨,我是应用程序开发的初学者,我需要一些帮助。 当我点击通知时,我正在尝试打开锻炼活动。 但是当我这样做时,活动从头开始,它的所有进度都丢失了。 那么当我点击通知时,我该怎么做才能打开带有进度的活动?

使用清单文件中的当前进度更改要打开的特定活动的启动模式 在此处了解 Android 启动模式: https : //betterprogramming.pub/understanding-the-android-activity-launch-modes-49ec89ef79d2

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM