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. Hardware considerations for application with media

HI all.
I have no experience in programming phones, but I have an idea for an
application for the Android platform,
and I would like to start implementing it with existing SDK and
emulator.
My application would probably need to contain a few  thousands
images, about the same number of very short audio files - quality of
sound and images should be acceptable, not brilliant.
I know that Android is not binded to a certain hardware, but judging
by the rest of the industry, do you think
that application like what I've described above will be reasonable to
run on a modern headset,
when considering disk space limitations, or would all these media
files take too much -
(I estimate it very roughly at possibly a few hundreds megabyte - does
it sound about right ?)
any thoughts on that would be very welcome,
Thanks
--~--~---------~--~----~------------~-------~--~----~

2. get key pressed actively

Hi all,
   Is there a way to get key pressed actively? Currently we just need
to override the method onKeyDown() method. Then Android OS will call
onKeyDown() to tell our program that a key has been pressed. Is there
a way to get the event if i don't override the onKeyDown() method? I
want to develop an application with hotkey functions. I mean if my
application is hiden. How to call it back to the front if i press some
shortcut key. Any Google guys can tell me please?

BR
Gibson
--~--~---------~--~----~------------~-------~--~----~

3. About error:Argument must not be null

4. About camera in android

5. question about adding external source folders to your project

6. How do I create a MediaPlayer for a resource without using the resId?

7. How to create my own menu?