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. My apps not visible on Market

Hi

I have  a HTC desire running 2.2 and a nexus1 running 2.2.1. Some of
the apps that appear in market on nexus are not visible on desire.
Due to this i am not able to install apps from market on my HTC
desire.

I checked on some of the forums. It seems a lot of people have faced
the same problem. It suggested one reason could be that my device
fingerprint is not registered with google. but i wrote to HTC and have
not received a answer.
Could this be because of some other issue?

Can any one please help me solve this problem.


Thanks

-- 

2. Installation error: INSTALL_PARSE_FAILED_NO_CERTIFICATES

I've been working with my Eclipse/ADT Android project for weeks now,
and all of a sudden, for no reason that I can determine, I have
started getting this error whenever I try to run my app:

Installation error: INSTALL_PARSE_FAILED_NO_CERTIFICATES

The only further clue found in logcat is this:

04-03 14:07:40.116: ERROR/PackageParser(51): Package
com.mypackage.myapp has no certificates at entry res/color/
text_light_gray.xml; ignoring!

I found the same error in the issue database:

http://code.google.com/p/android/issues/detail?id=830

But, what I haven't found is a workaround. Here's what I have tried so
far:

emulator -wipe-data
rm -rf ~/.android
installing using adb (same error code)
rebooting my dev machine
restoring my source code to a known good state (from source control)
deleting my eclipse project and rebuilding it with known good source

The only thing left I can think of is re-installing ADT, and then re-
installing Eclipse. Anybody know another workaround before I resort to
that?

Thanks!

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

3. Issue with reading contacts and calendar events on HTC HD 2

4. open picture file under drawable

5. Android 2.0 Contact List View

6. opencore and 64-bit file/streaming support

7. required: Architect/Developer