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. Intent for sending email

Hi,

I want to be able to send an email in my application, however I'm not
interested in the user entering their mail details/SMTP server. I
would like to forward the user off to another application that handles
email/contact selection.

It seems I should be able to use the Intent.ACTION_SEND.

                        Intent sendIntent = new Intent(Intent.ACTION_SEND);
                        sendIntent.putExtra(Intent.EXTRA_TEXT, "email text");
                        sendIntent.putExtra(Intent.EXTRA_SUBJECT, "subject");

                        startActivity(Intent.createChooser(sendIntent, "Chooser 
Title:"));

But the emulator tells me "No applications can perform this action."

Will the G1 with an email client and GMail potentially handle this
intent correctly?

Is it possible to get the GMail app installed on the emulator?

Thanks!

Daniel

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

2. GPRS configuration

Hi,

I remember on other phones there are some settings associated with
GPRS/packet data connections, such as gateway, number, may be login,
proxy etc., I hope it rings a bell. Is there something like this on
Android? Can it be read/modified using API?

Thanks.

Denis
--~--~---------~--~----~------------~-------~--~----~

3. MAC address?

4. no icon in menu after install apk files to /data/app in target board

5. Trying to download Android source - repo sync connection reset

6. MediaPlayer output monochrome video

7. About Android Mobile Programming