appwidget setOnClickPendingIntent not always working

by biokys » Fri, 20 May 2011 18:13:12 GMT


Sponsored Links
 Hi, I have an issue with my appwidget. It has really strange behaviour, 
because when I add widget to desktop it *not always* become clickable, even 
i defined setOnClickPendingIntent. On different phones it has different 
"successfull install ratio".

Thank you for your help

public class BasicWidget extends AppWidgetProvider {


private static final String LOG_TAG = "WalletWidget";

@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, 
int[] appWidgetIds) {
Log.d(LOG_TAG, "onUpdate(): ");
context.startService(new Intent(context, UpdateService.class));
 }
 
public static class UpdateService extends Service {
@Override
public void onStart(Intent intent, int startId) {
RemoteViews updateViews = buildUpdate(this);

ComponentName thisWidget = new ComponentName(this, BasicWidget.class);
AppWidgetManager manager = AppWidgetManager.getInstance(this);
manager.updateAppWidget(thisWidget, updateViews);
}

public RemoteViews buildUpdate(Context context) {
RemoteViews updateViews = null;
Intent intent = new Intent(context, RecordActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 
PendingIntent.FLAG_UPDATE_CURRENT);
updateViews = new RemoteViews(context.getPackageName(), 
R.layout.widget_layout);
updateViews.setOnClickPendingIntent(R.id.layout_widget, pendingIntent);

new UpdateWidgetTask(context).execute();

return updateViews;
}

@Override
public void onConfigurationChanged(Configuration newConfig)
{
RemoteViews updateViews = buildUpdate(this);

ComponentName thisWidget = new ComponentName(this, BasicWidget.class);
AppWidgetManager manager = AppWidgetManager.getInstance(this);
manager.updateAppWidget(thisWidget, updateViews);
}

@Override
public IBinder onBind(Intent intent) {
// We don't need to bind to this service
return null;
}
}
 @Override
public void onDeleted(final Context ctx, final int[] aiAppWidgetIds)
{
super.onDeleted(ctx, aiAppWidgetIds);
ctx.stopService(new Intent(ctx, UpdateService.class));
}

-- 



Other Threads

1. webview will not follow links on some pages, why?

This was not a {*filter*}e. The default webclient doesn't load some
pages. Not sure why/what the algorithm. I over-rode with a custom
webclient and it works now.

Thanks,
TimJowers





--~--~---------~--~----~------------~-------~--~----~

2. Cannot Retrieve Latitude and Longitude without Internet Connection

Hi all,

I am having problem in getting the latitude and longitude on my
phone..

So i create an application that only display the "Toast" once i
request it to. using the LocationManager.NETWORK_PROVIDER, instead of
gps.

And I try it on my G1.. I found out that if the G1 is connected to my
WiFi, i can get the coordinate of my position, without any problem..
once i turn off the WiFi of the phone. The onLocationChanged() is not
triggered anymore, instead, onStatusChanged() is triggered.. And I get
TEMPORARILY_UNAVAILABLE error..

So what i want to ask is :Is internet connection required to retrieve
the coordinate ONLY?

Note that I dont use any maps or visual representation of my location.
All I do was to get the latitude and longitude.

Or do i need to add any extra stuff?

As for the permission these are the ones I used, even though I doubt
that the INTERNET permission is needed..

android.permission.ACCESS_FINE_LOCATION
android.permission.ACCESS_COARSE_LOCATION
android.permission.INTERNET

--~--~---------~--~----~------------~-------~--~----~

3. Is there any SIM Card contacts API, the same as i get from the PhonBook Content Provider.

4. Update: new ADT Eclipse plugin 0.9.1 available

5. Where can I found the SMS that is just arrived?

6. Sending Email from Myapplication in androidEmulator

7. Android on Eten glofiish series