Hi im having a very weird problem with my android widget, ive looked extensivly in many places but I cant seem to figure out whats wrong. basically im calling a pendingintent broadcast in my widget and in sucessfully catching that intent in the onrecivie method.
However in the onRecive method, when I try to set the text using RemoteViews for my component, the text does not update nor is any error called. I have attached my code below, any help would be great.
Thanks, M
package com.android.FirstWidget;import android.app.PendingIntent;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ImageButton;
import android.widget.RemoteViews;
public class ExampleAppWidgetProvider extends AppWidgetProvider {
@Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
Log.e("ds",intent.getAction());
Log.e("f","f");
if(intent.getAction().contains("1")){
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.wid);
views.setTextViewText(R.id.textView1,"heyheyhey");
Log.e("fssss","sssf");
}
super.onReceive(context, intent);
}
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] 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];
// Create an Intent to launch ExampleActivity
Intent intent = new Intent(context, ExampleAppWidgetProvider.class);
intent.setAction("1");
PendingIntent pendingIntent = PendingIntent.getBroadcast(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.wid);
views.setOnClickPendingIntent(R.id.arrowLeft, pendingIntent);
views.setOnClickPendingIntent(R.id.arrowRight, pendingIntent);
//views.set
// Tell the AppWidgetManager to perform an update on the current app widget
appWidgetManager.updateAppWidget(appWidgetId, views);
}
}
}