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 color code individual rows of a list view?

How can I color code individual rows in a ListView exactly like it is
done in the native MESSAGING app? I do NOT want to simply do
alternating rows, but I want to copy the format used in the MESSAGING
app, where message rows have a different background color based on the
username of the message.

FYI:
I am currently extending SimpleAdapter and overriding getView(int
position, View convertView, ViewGroup parent) . In this method I am
trying to calculate setting the background color based on the position
as compared to a list of 'positions to highlight' that I am
maintaining each time I update the list, but so far this is only
working the first time the list is updated.

Thank you for any guidance you can offer!

-- 

2. WAT: Folder Management

Hi all,

Newbie neh di android system. Biasa pakai bb,

Neh saya ada buat folder, kalau di bb, mau susun applikasi, kan bisa move to
folder gitu, apa android juga bisa?

Terus telanjur buat folder, tp kecarian option untk rename folder & delete
folder.

Mohon bantuan.

Sorry for being a noob :)

-- 
"Indonesian Android Community [id-android]" 

3. Motorola Backflip for AT&T unboxing and hands-on

4. Problems when using GridView in Gallery

5. sd card access

6. OOT salam kenal

7. Fungsi Market Enabler Tuh Buat Apa sih?