Question

When app need: SCHEDULE_EXACT_ALARM and USE_EXACT_ALARM android permissions

In app manifest I have:

<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM"/>
<uses-permission android:name="android.permission.USE_EXACT_ALARM"/>

But google now asks me to set if app is calendar or alarm app.
But this app is not any of these.
I think it was added because you can start something in the app and local notification is scheduled to fire notification at specified time 5 min before times out and when something times out.

  • In this situation are those permissions required?

  • And how to deploy app now to remove these permissions when google doesn't allow me to deploy build?

And because this is already on the store I can't just remove and upload but I don't want to categorize app as alarm or calendar but now I can't deploy changes.

UPDATE

I removed both permission but can't deploy as I am still getting error:

Google Api Error: Invalid request - You must let us know whether your app uses any exact alarm permissions

 3  400  3
1 Jan 1970

Solution

 0

As per new android 14 update Schedule exact alarms are denied by default.


As Google says :

Exact alarms are meant for user-intentioned notifications or actions that need to happen at a precise time.

SCHEDULE_EXACT_ALARM is only intended for use by apps that rely on exact alarms for their core functionality.

Being sensitive permission, app stores enforces policies to audit/review the use of this permission. May involve removal from the app store if they found you to be misusing permission.

Exact alarm should be used only if you are using any set*exact* method to trigger an alarm at exact specified date-time. Otherwise "schedule" methods are enough, letting system choose proper nearest date-time to trigger alarm accordingly to system factors.


SCHEDULE_EXACT_ALARM, the permission introduced in Android 12 for apps to schedule exact alarms, is no longer being pre-granted to most newly installed apps targeting Android 13 and higher (will be set to denied by default).

In reference from .

Calendar or alarm clock apps need to send calendar reminders, wake-up alarms, or alerts when the app is no longer running. These apps can request the USE_EXACT_ALARM normal permission. The USE_EXACT_ALARM permission will be granted on install, and apps holding this permission will be able to schedule exact alarms just like apps with the SCHEDULE_EXACT_ALARM permission.

What you can do

Check the usage of following functions :

  1. setExact()

  2. setExactAndAllowWhileIdle()

  3. setAlarmClock()


Make changes for AndroidManifest.xml :

<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM"
    android:maxSdkVersion="32" />
<uses-permission android:name="android.permission.USE_EXACT_ALARM" />

Note :

  • Identify exact alarm usage: Exclude any code you are unwilling to give up, and then identify the sections that utilize setExact(), setExactAndAllowWhileIdle(), or setAlarmClock() methods in the AlarmManager class.

  • Replace with inexact alarms: Instead of the above-mentioned techniques, setWindow() method in alarm class or setTriggerAtMillis() is more preferable. It enables one to set alarms with a particular delay (margin of time) instead of a definite time. The power of the tolerance is adjustable in accordance with the necessities of the application.

  • If the exact alarm is set using an OnAlarmListener object, like in the setExact API, the SCHEDULE_EXACT_ALARM permission isn't required.


Update 1

Regarding publishing on Google Play.

Can you check the bundle which you uploaded must be still active now in any of the testing track like closed open alpha or you have not done 100% rollout of production latest version. Updating the track with latest version will fix this warning as that bundle still has the permission. You can replace them with the updated build then this error will be fixed.

2024-07-02
Bob

Solution

 0

AndroidManifest.xml Declare both permissions, with SCHEDULE_EXACT_ALARM limited to a max SDK version to ensure backward compatibility:

<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" android:maxSdkVersion="32" />
<uses-permission android:name="android.permission.USE_EXACT_ALARM" />

MainActivity.java (or MainActivity.kt)

Handle the permissions in your activity by checking which Android version is running and requesting the appropriate permission:

import android.app.AlarmManager;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.provider.Settings;
import android.util.Log;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        AlarmManager manager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
        if (manager != null) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { // Android 13 and above
                if (!manager.canScheduleExactAlarms()) {
                    Intent intent = new Intent(Settings.ACTION_REQUEST_SCHEDULE_EXACT_ALARM);
                    intent.setData(Uri.parse("package:" + getPackageName()));
                    startActivity(intent);
                } else {
                    Log.d("MainActivity", "onCreate: can schedule exact alarms (USE_EXACT_ALARM)");
                }
            } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { // Android 12
                if (!manager.canScheduleExactAlarms()) {
                    Intent intent = new Intent(Settings.ACTION_REQUEST_SCHEDULE_EXACT_ALARM);
                    startActivity(intent);
                } else {
                    Log.d("MainActivity", "onCreate: can schedule exact alarms (SCHEDULE_EXACT_ALARM)");
                }
            }
        }
    }
}

Hope this will help you...

2024-07-11
Vinay Upadhyay

Solution

 0

I had the same mistake. I also deleted the permission, tried again and also got the error again.

The problem is with the Google Api, apparently some kind of bug, I just uploaded the build without USE_EXACT_ALARM permission (SCHEDULE_EXACT_ALARM can stay) manually in the Google Play Console and it successfully passed the review. After that, the declaration about USE_EXACT_ALARM disappeared from the App content tab.

2024-07-12
Arsen Tatraev

Solution

 0

My solution was to remove USE_EXACT_ALARM from both test and production parts. If you delete only for the production it still gave the same error but if you update for example closed test then you will see the google not gave you the error message and you can able to publish your application.

2024-07-16
TheAnswer