Android Expects Intent - Alarm - Same Code Six (6) Applications

Yesterday I found something strange. When testing an application with localization versions (different applications - different packages, the same code), I found one interesting error - the application sets an alarm with AlarmManager and pending intent - when the broadcast starts, only one application is activated and executes the pending intent and all other applications (only in different languages) do not react at all. Is this an Android bug? I expect the set Alarm to trigger every application that has its own alarm, but does Android start or is the last active application triggered by broadcast or broadcast? How is the expected intention related to broadcasting from the system? How does the system know which application expects Broadcast and which .apk is for this? This may seem strange or difficult to understand, but I was also embarrassed.

public class AlarmSetter { public void SetAlarma(Context context){ Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(System.currentTimeMillis()); calendar.set(Calendar.SECOND, 57); calendar.set(Calendar.MINUTE, 59); calendar.set(Calendar.HOUR_OF_DAY, 23); calendar.add(Calendar.DAY_OF_MONTH, 0); Intent intent = new Intent(context, AlarmKicked.class); PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 1333333, intent, PendingIntent.FLAG_UPDATE_CURRENT); AlarmManager am =(AlarmManager)context.getSystemService(Context.ALARM_SERVICE); am.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(),AlarmManager.INTERVAL_DAY, pendingIntent); } } 
0
source share
1 answer

OK, waiting for error confirmation

OK finally !!!!

This is BUG: So the application is bg.google.myapppackage.apk .. nothing bad .. uses the LVL license - ServerManagedPolicy - configurable - google bcs says the developers are using an example.

In ServerManagedPolicy.java we have "private static final String DEFAULT_MAX_RETRIES =" 0 "; I just made" private static final String DEFAULT_MAX_RETRIES = "10"; This means that 10 times to start before blocking .. nothing new, the user can run the application before 10 checks have disappeared .. nice, isn't it?

BUT! the problem is in lats, every start is registered by the system in a very strange way .. how? simple: each start adds a number to the package, like this

03-17 00: 25: 45.318: I / PackageManager (59): / data / app / bg.google.myapppackage-1.apk changed; unpacking

03-17 00: 25: 45.318: I / PackageManager (59): / data / app / bg.google.myapppackage-2.apk changed; unpacking

03-17 00: 25: 45.318: I / PackageManager (59): / data / app / bg.google.myapppackage-3.apk changed; unpacking

those times when the application was launched ... OK is still nothing bad ... No, this is WRONG! If you run the action from the bg.google.myapppackage-1.apk package and this package sets Alarm with AlarmManager and you close the application, the alarm will be started later, but the receiver will no longer exist .. bcs if users close the application and run it again, then we have bg.google.myapppackage-2.apk, and the second package installs Alarm two, but when it is closed, the package no longer exists ... The system starts broadcasting, but is not a receiver there, and the application does not respond at all. it was a problem in my case. Testing the application and never received Broadcast or only the active application registered brodcast, while others did not ..

So, if you have an application that does some updating that AlarmManager starts, you should set "private static final String DEFAULT_MAX_RETRIES =" 0 "; to 0 otherwise your application will show a failure or missing functionality during retries // I think Google should fix this by changing the package name, and someone should publish a BUG ticket .. This thing cost me almost 3 days (days I study IT, and nights I work at home .. so sleep is what what I miss, and lose time, as it is not necessary ..)

03-14 18: 22: 51.860: D / PackageManager (199): a new package is installed in /data/app/bg.google.myapppackage-1.apk

03-17 00: 25: 45.348: D / installd (35): DexInv: --- BEGIN '/data/app/bg.google.myapppackage-1.apk' ---

03-17 00: 25: 47.599: D / installd (35): DexInv: --- END '/data/app/bg.google.myapppackage-1.apk' (success) ---

03-17 00: 25: 47.748: I / installd (35): move / data / dalvik-cache / data@app @ bg.google.myapppackage-1.apk@classes.dex → / data / dalvik -cache / data @ app @ bg.google.myapppackage -1.apk @ classes.dex

0
source

All Articles