AlarmManager application for Xiaomi 2 S mobile phones

Source: Internet
Author: User

Recently, the project needs to use AlarmManager to wake up Baidu positioning when the cpu is sleeping. The following is an example of calling code:

-- Periodic broadcast locating

Public static void sendLocationBroadcastRepeat (Context ctx ){
Intent intent = new Intent (ctx, LocationBroadcast. class );
PendingIntent pendingIntent = PendingIntent. getBroadcast (ctx, 0,
Intent, 0 );

// Start time
Long firstime = SystemClock. elapsedRealtime ();

AlarmManager am = (AlarmManager) ctx
. GetSystemService (Context. ALARM_SERVICE );
Am. setRepeating (AlarmManager. ELAPSED_REALTIME_WAKEUP, firstime,
10*1000, pendingintent );

Log. I (TAG, "sendupdatebroadcastrepeat is start ");
}

Note: The 10-second loop call broadcast is set. During the running process, it is found that the broadcast is not called at the set time. I thought it was a code problem and there was no error in the code after troubleshooting. The test runs normally on the meizu 2 mobile phone (according to the settings ). Why didn't I run as set On Xiaomi's phone?

Repeated tests showed that Xiaomi mobile phones repeatedly call broadcast at intervals of 5 minutes:

Problem tracking:

  1. Call Xiaomi technical support by phone. The other party replies to refresh Xiaomi's latest miui (Development version). The refresh result remains the same;
  2. Refresh the latest stable version. The result is the same;
  3. ......

If you have any questions, please let us know. Thank you!

Solution:

  1. Set the firstime value to a value greater than or equal to 5 minutes (at present, Xiaomi miui is in this situation and we hope Xiaomi can solve this problem)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.