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. Title of dialog

Hi,

Is it possible for the title of the Dialog to go onto two lines?

thanks

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

2. jymsg implementation on android

Hi All,
I understand that there are some of the members here have tried to use jymsg
api on android, I have tried it also since a few days ago but I can't login
(failed: login timed out) and always receive this error on adb logcat:

I/global  (  723): Default buffer size used in BufferedInputStream
constructor. It would be better to be explicit if an 8k buffer is required.
W/System.err(  723): Error loading resource file: challenge.bin (I think
this is what caused the problem..)
W/System.err(  723): java.lang.Exception: Data too short?
W/System.err(  723):    at
ymsg.network.ChallengeResponseV10.<clinit>(ChallengeResponseV10.java:74)
W/System.err(  723):    at
ymsg.network.Session.receiveAuth(Session.java:1109)
W/System.err(  723):    at
ymsg.network.Session$InputThread.process(Session.java:2314)
W/System.err(  723):    at
ymsg.network.Session$InputThread.run(Session.java:2285)
W/ActivityManager(  567): Launch timeout has expired, giving up wake lock!
W/ActivityManager(  567): Activity idle timeout for HistoryRecord{435fa458
{com.xglite.client.android.yahooclient/com.xglite.client.android.yahooclient.Yah
D/dalvikvm(  635): GC freed 2686 objects / 153504 bytes in 224ms
D/dalvikvm(  655): GC freed 2946 objects / 179816 bytes in 232ms
D/dalvikvm(  666): GC freed 1309 objects / 81920 bytes in 224ms
D/dalvikvm(  610): GC freed 1976 objects / 111904 bytes in 181ms
D/dalvikvm(  723): threadid=19 wakeup: interrupted
W/System.err(  723): java.io.InterruptedIOException: Login timed out
W/System.err(  723):    at ymsg.network.Session.login(Session.java:136)
W/System.err(  723):    at
com.xglite.client.android.yahooclient.YahooClient.onCreate(YahooClient.java:24)
W/System.err(  723):    at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
W/System.err(  723):    at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2231)
W/System.err(  723):    at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2284)
W/System.err(  723):    at
android.app.ActivityThread.access$1800(ActivityThread.java:112)
W/System.err(  723):    at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1692)
W/System.err(  723):    at
android.os.Handler.dispatchMessage(Handler.java:99)
W/System.err(  723):    at android.os.Looper.loop(Looper.java:123)
W/System.err(  723):    at
android.app.ActivityThread.main(ActivityThread.java:3948)
W/System.err(  723):    at java.lang.reflect.Method.invokeNative(Native
Method)
W/System.err(  723):    at java.lang.reflect.Method.invoke(Method.java:521)
W/System.err(  723):    at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:782)
W/System.err(  723):    at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
W/System.err(  723):    at dalvik.system.NativeStart.main(Native Method)
I/ActivityManager(  567): Displayed activity
com.xglite.client.android.yahooclient/.YahooClient: 62495 ms

Does anyone can help me out on this? I'm really curious to make this work on
android..
Thank you, I really appreciate it.

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

3. AudioRecord , buffer overflow issue.

4. Sms Broadcasts and Logs

5. How to "Find" and navigate to a string in a local WebView web page....

6. how to mark the location of google map

7. Alter Pitch In Music Player