I have a really simple appwidget (two text views and a button). I've tested it on a Touchpad, Droid 1, and a Droid Razr. It works on everything except the Razr. When I add the widget to the homescreen it doesn't display; it's just invisible. If I hold down on the spot where it would be it selects a widget and if I move it around I see other widgets move out of the way but it's completely invisible.
I put some Toasts in the onReceive
and onEnabled
methods and the Toast
displays all the right information (ie intent action and extras).
Anybody have any experience with this?
EDIT: Please keep in mind this is just for debugging and does not follow best practices
public class GoogleTalkWidget extends AppWidgetProvider {
Button sendMessage;
@Override
public void onReceive(Context context, Intent intent) {
Toast.makeText(context, "Received Intent Action = " +
intent.getAction(), Toast.LENGTH_SHORT).show();
if(intent.getAction().equals(Utils.RECEIVED_MESSAGE_WIDGET)){
RemoteViews views = new RemoteViews(context.getPackageName(),
R.layout.main_widget);
views.setTextViewText(R.id.widget_message,
(CharSequence)intent.getStringExtra("MESSAGE"));
views.setTextViewText(R.id.widget_sender,
(CharSequence)intent.getStringExtra("SENDER"));
Toast.makeText(context, "Received " +
intent.getStringExtra("MESSAGE") + " FROM " +
intent.getStringExtra("SENDER"), Toast.LENGTH_SHORT).show();
ComponentName cn = new ComponentName(context,
GoogleTalkWidget.class);
AppWidgetManager.getInstance(context).updateAppWidget(cn, views);
}
super.onReceive(context, intent);
}
@Override
public void onEnabled(final Context context){
super.onEnabled(context);
Toast.makeText(context, "Enabled", Toast.LENGTH_SHORT).show();
}
}