I am trying to update location data in a web database using BroadcastReceiver and Service .
However, I am having difficulty making it work with Android 3.2 on the Galaxy Tab 7.0 Plus.
The same application works fine on Android 2.3.6 Galaxy Note, but it does not work on the tablet. In fact, I am adding the RECEIVE_BOOT intent RECEIVE_BOOT to my recipient, but it is never created, i.e. O nReceive() never called after the download completes. I wonder if there are any updates to the system that trigger this action.
Here are my xml and receiver classes:
AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.tests.bootreceiver" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="10" android:targetSdkVersion="15" /> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.INTERNET" /> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" > <receiver android:name=".BootUpReceiver" android:enabled="true" android:permission="android.permission.RECEIVE_BOOT_COMPLETED" > <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </receiver> <service android:name=".MyService" > </service> </application>
BootUpReceiver.java
public class BootUpReceiver extends BroadcastReceiver { private static int INTERVAL = 1000*15; @Override public void onReceive(Context context, Intent intent) { AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); PendingIntent pi = PendingIntent.getService(context, 0, new Intent(context, MyService.class), PendingIntent.FLAG_UPDATE_CURRENT); am.setInexactRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), INTERVAL, pi); }
}
Is there a reason why the same piece of code works on one system and doesn't work on another?
Thanks!
source share