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. For X10i User. Ada yang pernah install update service nya X10i

Jawabannya kalau sudah konek : anda menggunakan the latest version :-)

Mohammad Jaedi
Fri, May 14, 2010 - 06:34:32 
-----Original Message-----
From: Reza Iransah <logay.pek...@gmail.com>
Date: Wed, 12 May 2010 21:17:45 
To: Indonesian Android Community [id-android]<id-android@googlegroups.com>
Subject: [id-android] Re: [WTA] For X10i User. Ada yang pernah install update 
        service nya X10i?

Gagal aja, tiap kali di sambungin USB antara Handset sama PC, PC nya
nge hank....coba di laptop juga sama....

dia minta di matiin handset terus cabut batere,setelah itu masukin
batere lagi,lalu di sambungkan ke PC sambil tombol BACK terus di
tekan....

tapi nunggu sampe kapan ga masuk-masuk....sampe panas JEMPOL gw
nih....

aples aples....

dan diakhiri dengan PC ato Laptop Nge-hank...

siapa tau ada yang bisa kasih tutorial nih....











> Join:

2. (ASK) Cara install di phone memory kalo ud app2sd?

Kok ga ada ya pilihan move? Saya ud pake eclair nih.

Best Regards
David Haryanto
david.harya...@gmail.com
*sent from my white spica




AFAIK..klo pk ROM Eclair, coba cek di bagian manage
applications...dikau bisa "Move" dr SD ke internal :D





http://my.wisestamp.com/link?u=jfrmb6tgjfdhvxxb&site=www.wisestamp.co...>.
http://my.wisestamp.com/link?u=jfrmb6tgjfdhvxxb&site=www.wisestamp.co...>

> Join:

3. <SHARE> Software Camera

4. usb hub not picking up- android on beagle

5. How to get activity to restart every time the app is launched from the command line

6. playback suddenly stopping...

7. building android in debug mode for native debugging