![](/img/trans.png)
[英]How to open another activity other than the MainActivity when clicking on notification
[英]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.