Hi all,
I have the problem like this.
Basically i want to find my present location's latitude and
longitude .It is showing in emulator which is default one which points
to Sanjose,usa.But it is not finding my current location(i am in
Hyderabad,India).When i try to run the same application in My HTC
magic (Android os 1.5) it is showing NULL.It is Not finding my present
location.
What i have to do..is there need of Network provider like Mobile
network(Vodafone,airtel etc..)
I am sending my code,Please check it and send me the working code if
any body have,Please i need it urgently.
Please Help me regarding this.
Thanks,
Ram.P
the code is as follows:
------------------------------------------------------------------------
class WhereAmI extends Activity {
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
LocationManager locationManager;
locationManager = (LocationManager)getSystemService
(Context.LOCATION_SERVICE);
Location location = locationManager.getLastKnownLocation
(LocationManager.GPS_PROVIDER);
updateWithNewLocation(location);
}
/** Update UI with a new location */
private void updateWithNewLocation(Location location) {
TextView myLocationText = (TextView)findViewById
(R.id.myLocationText);
String latLongString;
if (location != null) {
double lat = location.getLatitude();
double lng = location.getLongitude();
latLongString = "Lat:" + lat + "\nLong:" + lng;
} else {
latLongString = "No location found";
}
myLocationText.setText("Your Current Position is:\n" +
latLongString);
}
}
-----------------------------------------
Manifest file is as follows:
----------------
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.paad.whereami">
<application android:icon="@drawable/icon">
<activity android:name=".GPS" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-permission
android:name="android.permission.ACCESS_FINE_LOCATION"/>
</manifest>
--------------------------------------
Please help me very urgently.......
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en