Widget not showing in widget list had a similar question, and there are many other questions where the answer is basically: reboot, start app, wait, etc.
After the app install, it shows the widget on a Android 2.3 device. So the code is fine. But it never shows up on a 4.3 device. So 4.3 is looking for something that is not there.
Does anyone have any additional tips?
AndroidManifest.xml
<receiver
android:name=".WidgetProvider"
android:label="@string/widget_name">
<intent-filter>
<action
android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="@xml/widget_info" />
</receiver>
widget_info.xml
<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android" >
android:minWidth="208dp"
android:minHeight="56dp"
android:minResizeHeight="48dp"
android:minResizeWidth="48dp"
android:updatePeriodMillis="86400000"
android:previewImage="@drawable/ic_launcher"
android:resizeMode="horizontal|vertical"
android:widgetCategory="home_screen"
android:configure=""
android:initialLayout="@layout/widget_layout"
</appwidget-provider>
WidgetProvider.java
public class WidgetProviderextends AppWidgetProvider {
DateFormat df = new SimpleDateFormat("hh:mm:ss");
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
final int N = appWidgetIds.length;
Log.i("ExampleWidget", "Updating widgets " + Arrays.asList(appWidgetIds));
// Perform this loop procedure for each App Widget that belongs to this
// provider
for (int i = 0; i < N; i++) {
int appWidgetId = appWidgetIds[i];
// Create an Intent to launch ExampleActivity
Intent intent = new Intent(context, ExampleActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
// Get the layout for the App Widget and attach an on-click listener
// to the button
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_layout);
views.setOnClickPendingIntent(R.id.new_post, pendingIntent);
// To update a label
views.setTextViewText(R.id.blogname, df.format(new Date()));
// Tell the AppWidgetManager to perform an update on the current app
// widget
appWidgetManager.updateAppWidget(appWidgetId, views);
}
}
All the code above is mostly example code for testing, and it works fine on Android 2.3 just not on 4.3... There are no errors when running the debug build in the logcat output.