Skip to content

Commit

Permalink
Fix quick setting tile running alarm isolate
Browse files Browse the repository at this point in the history
  • Loading branch information
AhsanSarwar45 committed Mar 31, 2024
1 parent 2b8489c commit c29cb7e
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Handler;
import android.util.Log;
Expand Down Expand Up @@ -147,7 +148,18 @@ private static void scheduleAlarm(
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S && !manager.canScheduleExactAlarms()) {
Log.e(TAG, "Can`t schedule exact alarm due to revoked SCHEDULE_EXACT_ALARM permission");
} else {
AlarmManagerCompat.setAlarmClock(manager, startMillis, pendingIntent, pendingIntent);
PackageManager packageManager = context.getPackageManager();
String appId = context.getPackageName();
Intent launchIntent = packageManager.getLaunchIntentForPackage(appId);
launchIntent.putExtra("id", requestCode);
launchIntent.putExtra("params", params == null ? null : params.toString());
PendingIntent showPendingIntent = PendingIntent.getActivity(
context,
requestCode,
launchIntent,
(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M ? PendingIntent.FLAG_IMMUTABLE : 0)
| PendingIntent.FLAG_UPDATE_CURRENT);
AlarmManagerCompat.setAlarmClock(manager, startMillis, showPendingIntent, pendingIntent);
}
return;
}
Expand Down

0 comments on commit c29cb7e

Please sign in to comment.