I have a samsung tablet.

I have a test widget.

When I change orientation the widget disappears, but is actually still
there (I can long press to remove it).

in my res directory, I have

res\drawable
res\drawable-hdpi
res\drawable-ldpi
res\drawable-mdpi
res\layout
res\layout-land
res\layout-large-land

With valid values in all of these areas, but the widget just will not
appear when I go into landscape mode.

Ideas?

tia

TestWidgetProvider.java
----
package com.test.widget;

import android.app.PendingIntent;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.Context;
import android.content.Intent;
import android.widget.RemoteViews;

public class TestWidgetProvider extends AppWidgetProvider {

    @Override
    public void onUpdate(Context context, AppWidgetManager
appWidgetManager, int[] appWidgetIds) {
        super.onUpdate(context, appWidgetManager, appWidgetIds);

        final int N = appWidgetIds.length;

        // Perform this loop procedure for each App Widget that
belongs to this provider
        for (int i=0; i<N; i++) {
            int appWidgetId = appWidgetIds[i];

            Intent intent = new Intent(context, TestWidget.class);
            PendingIntent pendingIntent =
PendingIntent.getActivity(context, 0, intent, 0);

            // Get the layout for the App Widget and attach an on-
click listener to the button
            RemoteViews views = new
RemoteViews(context.getPackageName(), R.layout.appwidget);
            views.setOnClickPendingIntent(R.id.StartupIdleView,
pendingIntent);
            views.setOnClickPendingIntent(R.id.StartupLogo,
pendingIntent);

            // Tell the AppWidgetManager to perform an update on the
current App Widget
            appWidgetManager.updateAppWidget(appWidgetId, views);
        }
    }

    @Override
    public void onDeleted(Context context, int[] appWidgetIds) {
        super.onDeleted(context, appWidgetIds);
    }

    @Override
    public void onEnabled(Context context) {
        super.onEnabled(context);
    }

    @Override
    public void onDisabled(Context context) {
        super.onDisabled(context);
    }

    @Override
    public void onReceive(Context context, Intent intent) {
        // taken from:
        // 
http://groups.google.com/group/android-developers/msg/e405ca19df2170e2
        final String action = intent.getAction();
        if (AppWidgetManager.ACTION_APPWIDGET_DELETED.equals(action))
{
            final int appWidgetId =
intent.getExtras().getInt(AppWidgetManager.EXTRA_APPWIDGET_ID,
AppWidgetManager.INVALID_APPWIDGET_ID);
            if (appWidgetId != AppWidgetManager.INVALID_APPWIDGET_ID)
{
                this.onDeleted(context, new int[] { appWidgetId });
            }
        } else {
            super.onReceive(context, intent);
        }
    }

        public String getClassName() {
                String className = this.getClass().getSimpleName();
                return className;
        }
}

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to