I'm using a SherlockFragmentActivity as a widget configure activity:

<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
    android:configure="com.tahanot.activities.MyActivity"
    ...

Why I create a new widget, the activity opens, but when it ends, no widget is created although I make it return an OK result:

Intent resultValue = new Intent();
resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, widgetId);
setResult(RESULT_OK, resultValue);
finish();

It used to work when I had a different (non-Sherlock) configure activity, and I can't figure out why it doesn't work with this one. Maybe a SherlockFragmentActivity cannot act as a configure activity? Or am I missing something else?

有帮助吗?

解决方案

So it turns out that Sherlock was innocent, my problem was something else altogether.

Apparently, a widget configuration activity cannot have android:launchMode="singleInstance". A singleInstance activity just never creates a widget! So I changed it to singleTop and now it works.

This is also referred to in this question: Android AppWidget Configuration - Start in new task

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top