mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-12-25 03:57:58 +01:00
[android-extensions] Set RECEIVER_NOT_EXPORTED in ServerPingWithAlarmManager
Set RECEIVER_NOT_EXPORTED when registering the receiver in ServerPingWithAlarmManager, as otherwise this will throw an exception if the application targets Android API level 34 or higher. This requires raising the minimum Android API level to 26 for registerReceiver() with flags.
This commit is contained in:
parent
072761a0ad
commit
5dd08fc215
4 changed files with 10 additions and 4 deletions
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
|
@ -56,7 +56,7 @@ jobs:
|
|||
uses: android-actions/setup-android@v3
|
||||
- name: Install Android SDK
|
||||
run: |
|
||||
sdkmanager "platforms;android-23"
|
||||
sdkmanager "platforms;android-26"
|
||||
|
||||
# Testing
|
||||
- name: Gradle Check
|
||||
|
|
|
@ -3,7 +3,7 @@ plugins {
|
|||
id 'org.igniterealtime.smack.global-conventions'
|
||||
}
|
||||
dependencies {
|
||||
signature "net.sf.androidscents.signature:android-api-level-${smackMinAndroidSdk}:6.0_r3@signature"
|
||||
signature "net.sf.androidscents.signature:android-api-level-${smackMinAndroidSdk}:8.0.0_r2@signature"
|
||||
}
|
||||
animalsniffer {
|
||||
sourceSets = [sourceSets.main]
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
ext {
|
||||
javaVersion = JavaVersion.VERSION_11
|
||||
javaMajor = javaVersion.getMajorVersion()
|
||||
smackMinAndroidSdk = 23
|
||||
smackMinAndroidSdk = 26
|
||||
|
||||
androidBootClasspath = { getAndroidRuntimeJar() }
|
||||
}
|
||||
|
|
|
@ -173,7 +173,13 @@ public final class ServerPingWithAlarmManager extends Manager {
|
|||
*/
|
||||
public static void onCreate(Context context) {
|
||||
sContext = context;
|
||||
context.registerReceiver(ALARM_BROADCAST_RECEIVER, new IntentFilter(PING_ALARM_ACTION));
|
||||
|
||||
int receiverFlags = 0;
|
||||
if (Build.VERSION.SDK_INT >= 34) {
|
||||
receiverFlags |= 4; // RECEIVER_NOT_EXPORTED
|
||||
}
|
||||
context.registerReceiver(ALARM_BROADCAST_RECEIVER, new IntentFilter(PING_ALARM_ACTION), receiverFlags);
|
||||
|
||||
sAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
|
||||
int pendingIntentFlags = 0;
|
||||
if (Build.VERSION.SDK_INT >= 23) {
|
||||
|
|
Loading…
Reference in a new issue