mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-23 12:32:06 +01:00
[android-extensions] Mark pending intent immutable in ServerPingWithAlarmManager
This commit is contained in:
parent
34f490ff15
commit
e1cc1a4185
1 changed files with 6 additions and 1 deletions
|
@ -36,6 +36,7 @@ import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -174,7 +175,11 @@ public final class ServerPingWithAlarmManager extends Manager {
|
||||||
sContext = context;
|
sContext = context;
|
||||||
context.registerReceiver(ALARM_BROADCAST_RECEIVER, new IntentFilter(PING_ALARM_ACTION));
|
context.registerReceiver(ALARM_BROADCAST_RECEIVER, new IntentFilter(PING_ALARM_ACTION));
|
||||||
sAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
|
sAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
|
||||||
sPendingIntent = PendingIntent.getBroadcast(context, 0, new Intent(PING_ALARM_ACTION), 0);
|
int pendingIntentFlags = 0;
|
||||||
|
if (Build.VERSION.SDK_INT >= 23) {
|
||||||
|
pendingIntentFlags |= PendingIntent.FLAG_IMMUTABLE;
|
||||||
|
}
|
||||||
|
sPendingIntent = PendingIntent.getBroadcast(context, 0, new Intent(PING_ALARM_ACTION), pendingIntentFlags);
|
||||||
sAlarmManager.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,
|
sAlarmManager.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,
|
||||||
SystemClock.elapsedRealtime() + AlarmManager.INTERVAL_HALF_HOUR,
|
SystemClock.elapsedRealtime() + AlarmManager.INTERVAL_HALF_HOUR,
|
||||||
AlarmManager.INTERVAL_HALF_HOUR, sPendingIntent);
|
AlarmManager.INTERVAL_HALF_HOUR, sPendingIntent);
|
||||||
|
|
Loading…
Reference in a new issue