Set mutability flag for download service
CHANGELOG.md
9 | 9 | ||
10 | 10 | ### Bug Fixes | |
11 | 11 | ||
12 | + | * Dictionary download crashed on Android 12+. | |
12 | 13 | * Dictionaries are now downloaded in app data instead of cache | |
13 | 14 | * Dictionary update no longer marks the dictionary as not downloaded | |
14 | 15 |
app/src/main/java/eu/lepiller/nani/DictionaryDownloadService.java
3 | 3 | import android.app.PendingIntent; | |
4 | 4 | import android.app.Service; | |
5 | 5 | import android.content.Intent; | |
6 | + | import android.os.Build; | |
6 | 7 | import android.os.Handler; | |
7 | 8 | import android.os.IBinder; | |
8 | 9 | import android.os.Looper; | |
… | |||
103 | 104 | PendingIntent pendingIntent; | |
104 | 105 | if(name == null) { | |
105 | 106 | Intent notificationIntent = new Intent(this, DictionaryActivity.class); | |
106 | - | pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); | |
107 | + | pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, | |
108 | + | (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)? PendingIntent.FLAG_IMMUTABLE: 0); | |
107 | 109 | builder.setContentTitle(getString(R.string.downloading)); | |
108 | 110 | } else { | |
109 | 111 | Intent notificationIntent = new Intent(this, DictionaryDownloadActivity.class); | |
110 | 112 | notificationIntent.putExtra(DictionaryDownloadActivity.EXTRA_DICTIONARY, name); | |
111 | - | pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); | |
113 | + | pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, | |
114 | + | (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)? PendingIntent.FLAG_IMMUTABLE: 0); | |
112 | 115 | builder.setContentTitle(name); | |
113 | 116 | } | |
114 | 117 |