Widget problems with android 2.2

110 views
Skip to first unread message

Paul Ishenin

unread,
Sep 8, 2010, 10:03:17 AM9/8/10
to android-appwidget-extensions
Hi.

Every time I reinstal a scrollable widget it loses the listview which
we create using scrollable widget API. This did not happen with
android 2.1 and happen both in emulator and phone with android 2.2.

The steps to reproduce are the next (I'm using launcherPro for testing
but checked ADW and it has the same problem):
1. open example scrollable widget in eclipse and run it as android
application on emulator or phone
2. add widget to the launcher
3. clean project in eclipse and run it after again as android
application

As result widget shows "loading" forever. Same happens for my widget
too.

Ander Web

unread,
Sep 8, 2010, 1:45:10 PM9/8/10
to android-appwid...@googlegroups.com

Yeah, seems our current implementation misses something when upgrading a scrollable widget apk...
Maybe we forgot to broadcast the action_ready after a widget upgrade?

Paul Ishenin

unread,
Sep 8, 2010, 7:25:15 PM9/8/10
to android-appwidget-extensions
> Maybe we forgot to broadcast the action_ready after a widget upgrade?

Well, action_ready is not broadcasted after an upgrade but as I said
this works fine with android 2.1.

Mark Eggenstein

unread,
Feb 16, 2011, 5:10:22 PM2/16/11
to android-appwid...@googlegroups.com
When will this be fixed? This happens in ADWLauncher and LauncherPro.

Ander Web

unread,
Feb 16, 2011, 5:12:45 PM2/16/11
to android-appwid...@googlegroups.com

Can you submit a patch?

Mark Eggenstein

unread,
Feb 16, 2011, 5:29:52 PM2/16/11
to android-appwid...@googlegroups.com
Me? I am just struggling enough to write a scrollable widget.
As the OP wrote it used to work so please fix it.
I can reproduce the following with ADW:
1.6 stock android: widget doesn't switch to clean layout, but also
doesn't update it's content
2.2/2.3 with CyanogenMod: widget refreshes and then stays clean. The
appwidget_update comes, but no query to the DataProvider and then not
action_finish.

Mark

Florian Sundermann

unread,
Feb 17, 2011, 1:40:05 AM2/17/11
to android-appwid...@googlegroups.com
If you can reproduce it with ADW standalone then send me a test widget
and / or a detailed description on how to reproduce and i will have a
look at it...

2011/2/16 Mark Eggenstein <mark.eg...@gmail.com>

Mark Eggenstein

unread,
Feb 17, 2011, 3:48:11 PM2/17/11
to android-appwid...@googlegroups.com
You can take one of these
http://code.google.com/p/simplescrollablewidget/
http://code.google.com/p/scrollablecontacts/
install it, scroll a bit,
make a change to the code, intall the new version (from eclipse),
notice that the widget refreshes to its initial layout when no
scolling is supported,
no more scrolling possible, no content displayed.

Looking at the events, the APPWIDGET_UPDATE comes after the update,
but the DataProvider does not get queried and no ACTION_FINISH is
coming either (which both occur when you place a new widget on the
homescreen).

The same happens when I update with "adb install -r".
So I guess when a user updates to a new version through the market,
the widget would stop working (till he replaces it or reboots).

Mark

Florian Sundermann

unread,
Feb 17, 2011, 5:05:13 PM2/17/11
to android-appwid...@googlegroups.com
Ahh ok... the Action_ready intent is not send after the app is
reinstalled / updated.

Rotating should work to get the widget working again. Hope I find some
time to fix this tomorrow...


2011/2/17 Mark Eggenstein <mark.eg...@gmail.com>:

Mark Eggenstein

unread,
Mar 8, 2011, 4:11:02 PM3/8/11
to android-appwid...@googlegroups.com
I wonder if there is a wordaround. I don't think the other scrollable
widgets just stay blank after an upgrade. How do you do it, guys?

Thirachart Rahong

unread,
Mar 31, 2011, 11:56:34 PM3/31/11
to android-appwidget-extensions
I have issue like you,It alway show empty screen when
1. update new version
2. change widget layout at runtime
Ex.
if(grid)
widgetViews = new
SimpleRemoteViews(R.layout.widget_dummy_gridview);
else
widgetViews = new
SimpleRemoteViews(R.layout.widget_dummy_listview);

TODAY
I look at launcher code, I found workaround solution for issue number
2
I have to call resetWidget() evertime after finish config widget
setting

Workaround solution for issue number 1, Is possible to add source to
send this Broadcast every time if detected new installed or update
application


This is my code

protected void resetWidget(){
AppWidgetManager mAppWidgetManager =
AppWidgetManager.getInstance(this);
final AppWidgetProviderInfo appWidgetInfo = mAppWidgetManager
.getAppWidgetInfo(mAppWidgetId);
appwidgetReadyBroadcast(mAppWidgetId, appWidgetInfo.provider);
}
protected void appwidgetReadyBroadcast(int appWidgetId, ComponentName
cname) {
Log.d("appwidgetReadyBroadcast", cname.getPackageName());
Intent ready = new
Intent(LauncherIntent.Action.ACTION_READY).putExtra(
LauncherIntent.Extra.EXTRA_APPWIDGET_ID,
appWidgetId).putExtra(
AppWidgetManager.EXTRA_APPWIDGET_ID,
appWidgetId).putExtra(
LauncherIntent.Extra.EXTRA_API_VERSION, 2).
setComponent(cname);
sendBroadcast(ready);
}

Vincent Seguí

unread,
Oct 4, 2011, 3:53:05 AM10/4/11
to android-appwid...@googlegroups.com
Hi Florian,
  I'm sorry I think I sent a message to you personally instead of sending it to the group. Anyway, I'm having the same problem as the opening post, do you have any bug fix or workaround for the issue? Does the workaround posted in this thread below work? If so, how do I call those functions when my widget is reinstalled?

Cheers,
  V. Segui
Message has been deleted

Vincent Seguí

unread,
Oct 5, 2011, 2:41:22 PM10/5/11
to android-appwid...@googlegroups.com

Hi Mark,
 Did you manage to make this work? I'm having the same problem with ADW and Go Launcher, with my widget and with the sample scrollablecontacts. I'm stuck right now with this.

Cheers,
  V: Seguí

roee shlomo

unread,
Oct 5, 2011, 2:53:35 PM10/5/11
to android-appwid...@googlegroups.com
The widget's onUpdate method is called after reinstall/update.
Use it.

Vincent Seguí

unread,
Oct 5, 2011, 5:12:12 PM10/5/11
to android-appwid...@googlegroups.com
Hello roe888,
  It seems to be working right now! I had tried doing that from nearly everywhere (even in response to a PACKAGE_REPLACED to no avail). Thanks a lot on the tip and sorry for nagging the list so much.

For the record this is my code:

public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
Log.i(TAG, "onUpdate");
Intent intent = new Intent(context.getApplicationContext(), UpdateService.class);
// for (int i : appWidgetIds)
// Log.i(TAG, Integer.toString(i));
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, appWidgetIds);
                //start data update service
context.startService(intent);

// Construct views
                 ....
// Setup refresh on click

// If no specific widgets requested, collect list of all
if (appWidgetIds == null) {
appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(context, TheWidget.class));
}
// Tell the widget manager
final int N = appWidgetIds.length;
for (int i = 0; i < N; i++) {
int appWidgetId = appWidgetIds[i];
appWidgetManager.updateAppWidget(appWidgetId, views);
//forces the widget to recreate the listview. Especially
//important when reinstalling the app
resetWidget(context, appWidgetId);
}
}
 
protected void resetWidget(Context context, int mAppWidgetId) {
AppWidgetManager mAppWidgetManager = AppWidgetManager.getInstance(context);
final AppWidgetProviderInfo appWidgetInfo = mAppWidgetManager.getAppWidgetInfo(mAppWidgetId);
appwidgetReadyBroadcast(context, mAppWidgetId, appWidgetInfo.provider);
}

protected void appwidgetReadyBroadcast(Context context, int appWidgetId, ComponentName cname) {
Log.d("appwidgetReadyBroadcast: ", cname.getPackageName() + "to widget #"+appWidgetId);
Intent ready = new Intent(LauncherIntent.Action.ACTION_READY)
.putExtra(LauncherIntent.Extra.EXTRA_APPWIDGET_ID, appWidgetId)
.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId)
.putExtra(LauncherIntent.Extra.EXTRA_API_VERSION, 2).setComponent(cname);
context.sendBroadcast(ready);
}


Again thanks for the tip. 

  Cheers,
  V. Segui

P.S.: The scrollable-contacts widget seems to suffer from this issue too, should I open an issue and try to send a patch?
Reply all
Reply to author
Forward
0 new messages