0

My widget gives a problem loading the widget and it doesn't work.

This is the output I receive in logcat output but I'm not sure what it means.

W/de.vogella.android.widget.example(1613): onUpdate method called
W/AppWidgetHostView(412): updateAppWidget couldn't find any view, using error view
W/AppWidgetHostView(412):   at android.appwidget.AppWidgetHostView.updateAppWidget(AppWidgetHostView.java:394)
W/AppWidgetHostView(412):   at com.android.launcher2.LauncherAppWidgetHostView.updateAppWidget(LauncherAppWidgetHostView.java:54)
W/AppWidgetHostView(412):   at android.appwidget.AppWidgetHost.updateAppWidgetView(AppWidgetHost.java:376)
W/AppWidgetHostView(412):   at android.appwidget.AppWidgetHost$UpdateHandler.handleMessage(AppWidgetHost.java:101)
W/de.vogella.android.widget.example(1664): onUpdate method called
W/de.vogella.android.widget.example(1664): onUpdate method called
W/de.vogella.android.widget.example(1664): onUpdate method called
W/de.vogella.android.widget.example(1705): onUpdate method called
W/de.vogella.android.widget.example(1744): onUpdate method called
W/AppWidgetHostView(412): updateAppWidget couldn't find any view, using error view
W/AppWidgetHostView(412):   at android.appwidget.AppWidgetHostView.updateAppWidget(AppWidgetHostView.java:394)
W/AppWidgetHostView(412):   at com.android.launcher2.LauncherAppWidgetHostView.updateAppWidget(LauncherAppWidgetHostView.java:54)
W/AppWidgetHostView(412):   at android.appwidget.AppWidgetHost.updateAppWidgetView(AppWidgetHost.java:376)
W/AppWidgetHostView(412):   at android.appwidget.AppWidgetHost$UpdateHandler.handleMessage(AppWidgetHost.java:101)
W/de.vogella.android.widget.example(1744): onUpdate method called
W/AppWidgetHostView(412): updateAppWidget couldn't find any view, using error view
W/AppWidgetHostView(412):   at android.appwidget.AppWidgetHostView.updateAppWidget(AppWidgetHostView.java:394)
W/AppWidgetHostView(412):   at com.android.launcher2.LauncherAppWidgetHostView.updateAppWidget(LauncherAppWidgetHostView.java:54)
W/AppWidgetHostView(412):   at android.appwidget.AppWidgetHost.updateAppWidgetView(AppWidgetHost.java:376)
W/AppWidgetHostView(412):   at android.appwidget.AppWidgetHost$UpdateHandler.handleMessage(AppWidgetHost.java:101)

OnUpdate() method is triggered using the services. I have posted the service content below:

public void onUpdate(Context context, AppWidgetManager appWidgetManager,
      int[] appWidgetIds) {

    Log.w(LOG, "onUpdate method called");
    // Get all ids
    ComponentName thisWidget = new ComponentName(context,
        MyWidgetProvider.class);
    int[] allWidgetIds = appWidgetManager.getAppWidgetIds(thisWidget);

    // Build the intent to call the service
    Intent intent = new Intent(context.getApplicationContext(),
        UpdateWidgetService.class);
    intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, allWidgetIds);

    // Update the widgets via the service
    context.startService(intent);
  }

I think the problem is from the layout. If I want to change it to be marquee text, then i get this problem. The layout is :

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/layout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_margin="8dip"
    android:background="@drawable/myshape" >

    <TextView
        android:id="@+id/update"
        android:layout_width="200dp"
        android:duplicateParentState="true"
        android:ellipsize="marquee"
        android:focusable="true"
        android:focusableInTouchMode="true"
        android:marqueeRepeatLimit="marquee_forever"
        android:scrollHorizontally="true"
        android:singleLine="true"
        android:text="Loading... More text to see if it spans or not and want more" >

        <requestFocus
            android:duplicateParentState="true"
            android:focusable="true"
            android:focusableInTouchMode="true" />
    </TextView>

</LinearLayout>

What does the error message mean and why isn't my widget loading?

kaderud
  • 5,457
  • 2
  • 36
  • 49

1 Answers1

0

I think this might be useful for others.

Usually, to let the marquee run, in an activity, we set TextView.setSelected(true). In widgets, that should be done inside the xml file, using the tag requestfocus. Just in case, i have posted the working xml file.

<TextView
    android:id="@+id/update"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:ellipsize="marquee"
    android:focusable="true"
    android:focusableInTouchMode="true"
    android:freezesText="true"
    android:marqueeRepeatLimit="marquee_forever"
    android:paddingLeft="15dip"
    android:paddingRight="15dip"
    android:scrollHorizontally="true"
    android:singleLine="true" >

    <requestFocus
        android:duplicateParentState="true"
        android:focusable="true"
        android:focusableInTouchMode="true" />
</TextView>

Cheers.