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 local cities don't have e911. Can the phone display gps coordinates when calling 91

Long story short, I just learned that the city I in and the
surrounding cities don have the capability to receive e911 data.
Even though all modern phones are e911 capable, 911 operators can
pickup on this data. Apparently it cost millions to upgrade their
equipment and theye fighting budget cuts and lay offs and the idea
of spending millions on new equipment to replace old equipment is too
much.

Anyways, I realize that most modern phones have GPS chips and know
their coordinates. Ie even seen some apps that can determine your
ddressby your GPS coordinates (compass). Do you think it be
possible that when you call 911 it has the ability to read the GPS
coordinates and could inject audio into the call and read off the GPS
coordinates to the 911 operator. I was thinking of when you call 911
there be a button that shows up that the caller could hit and it
inject audio at that time. If injecting audio isn possible, maybe
when 911 is called, the phone could display the GPS coordinates on the
screen, even better, maybe It can display the nearest street address,
this way the caller can at least see it and read it off to the 911
operator.

-- 

2. French character encoding issues

Hi all,

I'm wondering if I found a bug in Android.  When I run this code on my
laptop:

     String myData = "hockey,march,football";
     byte[] rawData;
 rawData = myData.getBytes("UTF-8");

System.out.println("UTF-8 decoded: "+new String(rawData,"UTF-8"));
      System.out.println("Default decoded: "+new String(rawData));

I get the output:

*UTF-8 decoded: hockey,march,football*
*Default decoded: hockey,march,football*

However, when I run the same code in an Android application and view the
output it "adb logcat" I get:

*D/FileUtils(  485): UTF-8 decoded: hockey,marchfootball*
*D/FileUtils(  485): Default decoded: hockey,marchfootball*

I get the same issue if I change the locale of my phone to French (Canada)
as well.  It doesn't seem like French characters are getting encoded
properly.

Any thoughts?

Simon Mac Donald
http://hi.im/simonmacdonald

-- 

3. The onConfigurationChanged is not getting called when changing the orientation from portrait to landscape

4. Mod: Member ID-Android Tembus Angka 5000

5. Is it a UNIT Test or an Integration test?

6. Failed to fetch URL: https://dl-ssl.google.com/android/repository/repository.xml

7. Download finished with wrong size