Hi,
I have a similar problem as this link mention (Problem with
getting GPS data when using CameraPreview:):
http://stackoverflow.com/questions/3950026/problem-with-getting-gps-data-when-using-camerapreview
The problem is: the GPS will stop receiving data if you turn on the
camera !!!!!!!!!!!!!!!!!
I wrote a simple code to test the conflict as follows:
package com.example.helloandroid;
import android.app.Activity;
import android.content.Context;
import android.hardware.Camera;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
public class HelloAndroid extends Activity
{
LocationManager mlocManager;
LocationListener mlocListener;
Camera camera;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
/* Use the LocationManager class to obtain GPS
locations */
mlocManager =
(LocationManager)getSystemService(Context.LOCATION_SERVICE);
mlocListener = new MyLocationListener();
mlocManager.requestLocationUpdates( LocationManager.GPS_PROVIDER, 0,
0, mlocListener);
camera = Camera.open();// This is just for test, if
you comment this line, the GPS will work!!!!
}
@Override
protected void onDestroy()
{
mlocManager.removeUpdates(mlocListener);
super.onDestroy();
}
/* Class My Location Listener */
public class MyLocationListener implements LocationListener
{
public void onLocationChanged(Location loc)
{
String Text = "My current location is:\n" +
"Latitud = " + loc.getLatitude() + "\nLongitud = " + loc.getLongitude()
+ "\nAccuracy = "+ loc.getAccuracy();
Toast.makeText(getApplicationContext(),Text,Toast.LENGTH_SHORT).show();
Log.d("GPS", "getSpeed = " + loc.getSpeed()+"
Latitud = " + loc.getLatitude()+" Longitud = " + loc.getLongitude());
}
public void onProviderDisabled(String provider)
{
Toast.makeText(getApplicationContext(),"Gps
Disabled",Toast.LENGTH_SHORT ).show();
}
public void onProviderEnabled(String provider)
{
Toast.makeText(getApplicationContext(),"Gps
Enabled",Toast.LENGTH_SHORT).show();
}
public void onStatusChanged(String provider, int
status, Bundle extras){}
}
}
Anyone have solution? I appreciate your help.
--
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