Refactor: Use FLAG_ACTIVITY_SINGLE_TOP for MainActivity intents (#2022)

This commit is contained in:
James Rich 2025-06-04 14:20:30 -05:00 committed by GitHub
parent a05c48479d
commit 6153cfdab1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 6 deletions

View file

@ -224,7 +224,9 @@ class MainActivity : AppCompatActivity(), Logging {
val startActivityIntent = Intent(
Intent.ACTION_VIEW, deepLink.toUri(),
this, MainActivity::class.java
)
).apply {
flags = Intent.FLAG_ACTIVITY_SINGLE_TOP
}
val resultPendingIntent: PendingIntent? = TaskStackBuilder.create(this).run {
addNextIntentWithParentStack(startActivityIntent)
@ -234,11 +236,13 @@ class MainActivity : AppCompatActivity(), Logging {
}
private fun createSettingsIntent(): PendingIntent {
val deepLink = "$DEEP_LINK_BASE_URI/settings"
val deepLink = "$DEEP_LINK_BASE_URI/connections"
val startActivityIntent = Intent(
Intent.ACTION_VIEW, deepLink.toUri(),
this, MainActivity::class.java
)
).apply {
flags = Intent.FLAG_ACTIVITY_SINGLE_TOP
}
val resultPendingIntent: PendingIntent? = TaskStackBuilder.create(this).run {
addNextIntentWithParentStack(startActivityIntent)
@ -387,7 +391,6 @@ class MainActivity : AppCompatActivity(), Logging {
override fun onStart() {
super.onStart()
bluetoothViewModel.enabled.observe(this) { enabled ->
if (!enabled && !requestedEnable && model.selectedBluetooth) {
requestedEnable = true