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. How to install Maps in android 2.0

I everyone,
In Android 2.0 there isn't Maps Application,How can I install it?
I'm buildind a Maps application,but I have this error:

[2009-11-11 15:50:06 - Maps]Installation error:
INSTALL_FAILED_MISSING_SHARED_LIBRARY
[2009-11-11 15:50:06 - Maps]Please check logcat output for more
details.
[2009-11-11 15:50:06 - Maps]Launch canceled!

How can I solve it?

-- 

2. Lemme try this again...

I didn't get a definitive response last time I posted this question
(there were a lot of "I'm pretty sure"s and some arguments between
posters), and bumping topics doesn't really work on these boards, so
I'll ask again.

Let's say I get a T-Mobile G1 used off eBay (so assume it could have
any version of Android ever officially put on G1s). Will I be able to
test my apps on it WITHOUT:

-Loading a leaked or otherwise illegal OS
-Buying any sort of voice plan whatsoever*
-Buying any sort of data plan whatsoever*

The asterisks are there because if there was some sort of one-time
purchase under $50 I could make (prepaid SIM or whatever) and then be
able to use the phone for testing all I wanted after that without ever
paying again, that would be perfectly acceptable.

Definitive responses would be very much appreciated.

--

3. apk with only service

4. Size of .apk file for Emulator

5. How can i update ADC2 Round2 Application

6. Regarding top command in adb shell

7. Kenapa ?