Skip to content Skip to sidebar Skip to footer

Android Appwidget Not Receiving Appwidget_enabled Intent

I'm trying to create my first AppWidget using the AlarmManager class so that I can update more frequently than every 30 minutes. I followed this tutorial as a basis for setting up

Solution 1:

There is an error in your manifest. Action name in this element:

<actionandroid:name="@string/appwidget_markettiming_updateintent" />

should be replaced by actual string, not the reference. So it should be something like this:

<actionandroid:name="com.myapp.android.appwidget.action.MARKETTIMING_UPDATE" />

or whatever you have in your values/something.xml inside the <string name="appwidget_markettiming_updateintent"> element.

The problem is that the BroadcastReceiver does not receives the broadcasts from AlarmManager. I've created a project with your code, replaced only this string in manifest (and added the appropriate value to values/strings.xml of course) and all works fine.

In addition, you may want to replace the second parameter of alarmManager.setRepeating() by just System.currentTimeMillis() + 1000 and remove all those extra Calendar-related stuff.

Solution 2:

Apparently uninstalling it from the emulator and then re-installing it did the trick. Now when I add a widget the APPWIDGET_ENABLE intent is received, and when I remove it the APPWIDGET_DISABLED intent is fired like I would expect. I'm still having an issue where the alarm manager does not actually fire off my custom Intent like I expect, but that's a separate issue I'll need to research.

Post a Comment for "Android Appwidget Not Receiving Appwidget_enabled Intent"