Welcome to the Android Central Forums Create Your Account or Ask a Question Answers in 5 minutes - no registration required!
Results 1 to 1 of 1
  1. Thread Author  Thread Author    #1  

    Default Android Alarm reset after reboot not working

    I have one class called StopAlarmReceiver and another BootHandler.
    The BootHandler resets the alarm after reboot, which was set before the boot. My problem is that the BootHandler sets the alarm but not getting fired.

    Entries in Manifest file.
    Code:
    <receiver
            android:name="com.sign.android.myscheduler.app.StopAlarmReceiver"
            android:enabled="true"
            android:exported="true" >
        </receiver>
    
        <receiver
            android:name="com.sign.android.myscheduler.app.BootHandler"
            android:enabled="true"
            android:exported="true" >
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED"/>
            </intent-filter>
        </receiver>
    Code in BootHandler.

    Code:
    AlarmManager mgr= (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
    Intent i = new Intent(context, StopAlarmReceiver.class);
    PendingIntent pi = PendingIntent.getService(context, 1, i, 0);
    
    long time = sharedPreferences.getLong("Old_time", 0);
    Log.e(TAG, "New time: " +new Date(SystemClock.elapsedRealtime() + time));
    
    mgr.setRepeating(AlarmManager.ELAPSED_REALTIME, SystemClock.elapsedRealtime() + time, 5000, pi);
    The above code runs without any problem immediately after reboot and I can see the log with the time. But the problem is that it should fire after each and every five seconds but it won't!

    I hold the below permission .
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>

    Please help!

Similar Threads

  1. Noir [Game, Free, Puzzle, Android 2.3+]
    By Serg Maneken in forum Games
    Replies: 2
    Last Post: 05-06-2014, 05:44 AM
  2. Do not want to restore...
    By RionDunn in forum Samsung Galaxy S5
    Replies: 5
    Last Post: 05-05-2014, 01:45 PM
  3. Grey WiFi bars after using Market Unlocker Pro...
    By daniel1303 in forum Android 4.1 / 4.2 / 4.3 Jelly Bean
    Replies: 1
    Last Post: 05-05-2014, 07:09 AM
  4. Which Android phone should i buy?
    By astoria0128 in forum General Android Device Chat
    Replies: 5
    Last Post: 05-05-2014, 03:03 AM

Posting Permissions