widget question2

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

widget question2

Postby bqbqhahabq » Tue Dec 01, 2009 11:22 am

Hi, everyone.

Thank you for your attention. :D

I have a question for ya.

Is that possible to get that current location of user, and use location in widget?? (get Lat and Long. )

I searched for this, but it seems hard...

plz help me plz..
bqbqhahabq
Junior Developer
Junior Developer
 
Posts: 18
Joined: Tue Nov 17, 2009 6:57 am

Top

Re: widget question2

Postby jagtap.jj1 » Wed Dec 02, 2009 8:32 am

Yes surely, its Androids one of the imp feature
Use this pkg: http://developer.android.com/reference/ ... mmary.html

Here is sample code

private class LocationListener implements android.location.LocationListener
{
Location mLastLocation;
boolean mValid = false;
String mProvider;

public LocationListener(String provider)
{
mProvider = provider;
mLastLocation = new Location(mProvider);
}

public void onLocationChanged(Location newLocation)
{
if (newLocation.getLatitude() == 0.0 && newLocation.getLongitude() == 0.0)
{
// Hack to filter out 0.0,0.0 locations
return;
}
if (newLocation != null)
{
if(newLocation.getTime() == 0) newLocation.setTime(System.currentTimeMillis());

if(Config.DEBUG)
{
Log.i(TAG, "onLocationChanged in loc mgnr");
}
}
mLastLocation.set(newLocation);
mValid = true;
}

public void onProviderEnabled(String provider) {
}

public void onProviderDisabled(String provider)
{
mValid = false;
}

public void onStatusChanged(String provider, int status, Bundle extras)
{
if (status == LocationProvider.OUT_OF_SERVICE)
{
mValid = false;
}
}

public Location current()
{
return mValid ? mLastLocation : null;
}
};

bqbqhahabq wrote:Hi, everyone.

Thank you for your attention. :D

I have a question for ya.

Is that possible to get that current location of user, and use location in widget?? (get Lat and Long. )

I searched for this, but it seems hard...

plz help me plz..
java-android developer
User avatar
jagtap.jj1
Senior Developer
Senior Developer
 
Posts: 124
Joined: Fri Aug 22, 2008 11:52 am
Location: India(Mumbai)

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 6 guests