I built an application with the possibility to add widgets to the home screen. The widget is working with my Nexus 6P and a Motorola Moto G3.
With Samsung Phones (Tested with S3 mini (4.1.2), S5, S6 (6.0.1)) the widget is not added at all or TouchWiz crashes.
With another launcher (Nova) the widget is also not created on the S3 mini.
In logcat I don't see any error message at all.
I tried to narrow the problem down as far as possible.
The widget gets created if I remove the android:configure="de.cliff.strichliste.widgets.WidgetConfigurationActivity"
from the counter_widget_info.xml. If I want to use a configuration activity TouchWiz crashes on the Samsung S3 mini.
<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:minWidth="40dp"
android:minHeight="40dp"
android:configure="de.cliff.strichliste.widgets.WidgetConfigurationActivity"
android:updatePeriodMillis="1800000"
android:initialLayout="@layout/widget_counter"
android:resizeMode="horizontal|vertical"
android:widgetCategory="home_screen"
android:previewImage="@drawable/widget_preview">
</appwidget-provider>
In the AndroidManifest.xml I register the widget with the following lines:
<receiver
android:name=".widgets.CounterWidgetProvider">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="@xml/counter_widget_info" />
</receiver>
On the Java side, I've got the following in the WidgetConfigurationActivity:
public class WidgetConfigurationActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
WidgetConfigurationBinding binding = DataBindingUtil.setContentView(this, R.layout.widget_configuration);
setResult(RESULT_OK);
}
}
And this in the WidgetProvider class:
public class CounterWidgetProvider extends AppWidgetProvider {
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
super.onUpdate(context, appWidgetManager, appWidgetIds);
Intent intent = new Intent(context, CounterWidgetProvider.class);
context.startService(intent);
}
}