所以我创建了这个闹钟应用, 在Sony Xperia以外的所有设备上,所有设备均能正常运行,而该设备不会发出警报!我试图赋予它所有权限并删除耐力模式(如类似问题的建议),但仍然无法正常工作! 我设置了警报:
Intent alarmsIntent = new Intent("the.alarm.AlarmReceiver");
AlarmPI = PendingIntent.getBroadcast(this.context, 1, alarmsIntent, 0);
amAlarm.setExactAndAllowWhileIdle(AlarmManager.ELAPSED_REALTIME_WAKEUP,
SystemClock.elapsedRealtime() + buffer, AlarmPI);
这是清单的相关部分:
<uses-sdk
android:minSdkVersion="21"
android:targetSdkVersion="28" />
<uses-permission android:name="com.android.vending.BILLING" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.SET_ALARM"/>
<receiver android:name="the.alarm.AlarmReceiver" android:enabled="true" android:process=":remote">
<intent-filter android:priority="1000">
<action android:name="the.alarm.AlarmReceiver"></action>
</intent-filter>
</receiver>
notes:在我测试的6-7个android设备中,只有Sony Xperia无法正常工作