Skip to content

Commit

Permalink
try to restart app if updated
Browse files Browse the repository at this point in the history
  • Loading branch information
greenart7c3 committed Jul 3, 2024
1 parent 68bbc46 commit 8d8d75d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<queries>
<package android:name="com.greenart7c3.nostrsigner.debug"/>
<package android:name="com.greenart7c3.nostrsigner"/>
</queries>

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

<application
Expand All @@ -26,8 +31,10 @@
android:enabled="true"
android:exported="false"
android:permission="android.permission.RECEIVE_BOOT_COMPLETED">

<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.MY_PACKAGE_REPLACED" />

<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,15 @@ class BootReceiver : BroadcastReceiver() {
),
)
}

if (intent.action == Intent.ACTION_MY_PACKAGE_REPLACED) {
val packageManager = context.packageManager
val intent2 = packageManager.getLaunchIntentForPackage("com.greenart7c3.nostrsigner.debug")
if (intent2 != null) {
intent2.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK)
context.startActivity(intent2)
Runtime.getRuntime().exit(0)
}
}
}
}

0 comments on commit 8d8d75d

Please sign in to comment.