Skip to content

Commit

Permalink
fix: Toast not shown when network is connected in MIUI (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
kaaass committed Sep 16, 2023
1 parent 432e9b4 commit 30d7f79
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />

<application
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -983,12 +983,16 @@ private boolean updateTunnelConfig(Network network) {
channel.setDescription(description);
this.notificationManager.createNotificationChannel(channel);
}
int pendingIntentFlag = PendingIntent.FLAG_UPDATE_CURRENT;
if (Build.VERSION.SDK_INT >= 23) {
pendingIntentFlag |= PendingIntent.FLAG_ONE_SHOT;
}
if (Build.VERSION.SDK_INT >= 31) {
pendingIntentFlag |= PendingIntent.FLAG_IMMUTABLE;
}
var pendingIntent =
PendingIntent.getActivity(this, 0,
new Intent(this, NetworkListActivity.class),
Build.VERSION.SDK_INT >= 23
? PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_UPDATE_CURRENT
: PendingIntent.FLAG_UPDATE_CURRENT);
new Intent(this, NetworkListActivity.class), pendingIntentFlag);
var notification = new NotificationCompat.Builder(this, Constants.CHANNEL_ID)
.setPriority(1)
.setOngoing(true)
Expand Down

0 comments on commit 30d7f79

Please sign in to comment.