Я также использовал Alarm Service в своем проекте для подготовки к работе в течение 6 или 7 минут. И он работает нормально во всех телефонах.
я есть сделать службу сигнализации, как это:
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.SystemClock;
import android.util.Log;
public class MyAlarmService {
private static PendingIntent resetAlarm;
private static String TAG="CellPoliceChildGPSAlarmService";
private static AlarmManager am;
public static void start(Context context) {
try {
// We want the alarm to go off 30 seconds from now.
long firstTime = SystemClock.elapsedRealtime();
// Create an IntentSender that will launch our service, to be scheduled with the alarm manager.
//resetAlarm = PendingIntent.getService(context, 0, new Intent(context, Get_NonRootDetails.class), 0);
resetAlarm = PendingIntent.getService(context, 0, new Intent(context, CallNonRBackgroundService.class), 0);
// Schedule the alarm!
am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
Log.i(TAG, firstTime+"");
am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, firstTime, 10*1000*60, resetAlarm);
}
catch (Exception e) {
Log.v("CellInfo", "Exception while start the MyAlarmService at: " + e.getMessage());
}
}
public static void stop(Context context) {
try {
// When interval going to change from web services
am.cancel(resetAlarm);
}
catch (Exception e) {
Log.v("CellInfo", "Exception while start the MyAlarmService at: " + e.getMessage());
}
}
}
я назвал или начать, как это;
MyAlarmService.start(SplashActivity.this);
Учитывая разрешение в манифесте:
<uses-permission android:name="android.permission.WAKE_LOCK">
<service
android:name="com.secure.DataCountService"
android:enabled="true" >
<intent-filter>
<action android:name="com.secure.MyService" />
</intent-filter>
</service>
Для уведомлений я также используются в ожидании намерения, как;
Intent notificationIntent = new Intent(context, DashBoardActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);
notification.setLatestEventInfo(context, contentTitle, PushNotificationUtils.notiMsg, pendingIntent);
notification.flags |= notification.FLAG_AUTO_CANCEL;
сигнал тревоги, означающий ожидающее намерения, не вызывается после истечения срока действия таймера? Что говорит логарифм после истечения срока действия тревоги? можете ли вы публиковать журналы. – Meher
Да, его истинное, ожидающее намерения не называется. Я могу предоставить журналы, но позже (у меня нет телефона). – 5er
Для версий выше API 19: я запускаю Alarm с 'setExact', а затем, когда выполняется, я снова запускаю будильник с помощью' setExact' ... Кажется, что он работает ... Попробует и опубликует решение. – 5er