문제

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