cellurl wrote:
> I need location updates in a widget.
That will be difficult. You cannot fork threads from an
AppWidgetProvider, since it is a manifest-registered BroadcastReceiver,
and your AppWidgetProvider will be alive for milliseconds (I hope).
There is no clean way to have an AppWidgetProvider be around for the
tens of seconds necessary to get a GPS fix. Not to mention the fact that
you might never get a fix (e.g., user is in a parking garage).
> @Override
> public void onUpdate(Context context, AppWidgetManager
> appWidgetManager,
> int[] appWidgetIds) {
>
> final LocationManager lm=
> (LocationManager)context.getSystemService(Context.LOCATION_SERVICE);
>
> final LocationListener locationListener= new
> LocationListener() {
> public void onLocationChanged(Location newloc) {
> Log.d("TAG","onLocation Changed");
> }
> public void onProviderDisabled(String provider) {}
> public void onProviderEnabled(String provider) {}
> public void onStatusChanged(String provider, int status,
> Bundle extras) {}
> };
>
> Log.d("TAG","gets here");
>
> lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0,
> (float) 0.001, locationListener);
You cannot do that here. If you look at your logcat, you will probably
see an exception complaining about there being no looper.
--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy
Android Consulting/App Development: http://commonsware.com/consulting
--
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en