GPS WORKING ON Emulator But Not on actual device(PLZ Help!!)

Put problem concerning MapActivities, MapViews, Overlays and GPS in this forum.

GPS WORKING ON Emulator But Not on actual device(PLZ Help!!)

Postby vipulshah2010 » Sat Feb 27, 2010 11:34 am

i have written a small code to display latitude and longitude.
it is working correctly in emulator.but not at all working on actual device.
what could be the issue
plz hlp me :cry:
Last edited by vipulshah2010 on Fri Mar 05, 2010 11:01 am, edited 1 time in total.
vipulshah2010
Junior Developer
Junior Developer
 
Posts: 14
Joined: Tue Feb 09, 2010 7:50 am
Location: India

Top

Postby MrAdam » Thu Mar 04, 2010 10:32 pm

Why don't you post the code you are having trouble with?

A little hard to help when we can't see the code :)
MrAdam
Freshman
Freshman
 
Posts: 8
Joined: Mon Mar 01, 2010 1:24 am

GPS WORKING ON Emulator Not on actual device(code Attached)

Postby vipulshah2010 » Fri Mar 05, 2010 9:23 am

package org.GPS;

import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.widget.Toast;

public class GPS extends Activity implements LocationListener
{

@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Intent i = new Intent();
ComponentName comp = new ComponentName("com.android.settings",
"com.android.settings.SecuritySettings");
i.setComponent(comp);
startActivity(i);
LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER,1, 1,this);
Location currentLocation = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER);
if(currentLocation != null)
{
double Latitude = currentLocation.getLatitude();
double Longitude = currentLocation.getLongitude();
Toast.makeText(GPS.this,"Latitude="+Latitude+"\nLongitude"+Longitude,Toast.LENGTH_LONG).show();
}
else
{
Toast.makeText(GPS.this,"No GPS 1",Toast.LENGTH_LONG).show();
}

}

@Override
public void onLocationChanged(Location location)
{
if (location != null)
{
double longitude = location.getLongitude();
double latitude = location.getLatitude();
Toast.makeText(GPS.this,"Longiude="+longitude+"\nLatitude="+latitude,Toast.LENGTH_LONG).show();

}
else
{
Toast.makeText(GPS.this,"No GPS 2",Toast.LENGTH_LONG).show();
}

}

@Override
public void onProviderDisabled(String provider)
{
// TODO Auto-generated method stub

}

@Override
public void onProviderEnabled(String provider)
{
// TODO Auto-generated method stub

}

@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
// TODO Auto-generated method stub

}
}
vipulshah2010
Junior Developer
Junior Developer
 
Posts: 14
Joined: Tue Feb 09, 2010 7:50 am
Location: India

Top

Return to Map Problems

Who is online

Users browsing this forum: No registered users and 4 guests