Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid Apps Cannot Find Location After Installed in Device
    primarykey
    data
    text
    <p>I have a problem. </p> <p>I want to develop simple LBS apps using Android SDK which could determine my current location. I already made one, and tried it using emulator in eclipse. </p> <p>As I know I have to use DDMS to send Latitude and Longitude value to Emulator, and yes it works. Now, I'd like to install it on my Android Device to determine whether it works or not in my mobile phone. But, It couldn't get my location. </p> <p>I wonder what's wrong with it. Does internet or my cellphone provider determine my location (in exchange of using DDMS in eclipse) ? Or I need to add some lines of code to make it works or another configuration ? </p> <p>This is my code : </p> <pre><code>public class PilihFitur extends Activity implements OnClickListener { private double mylat = 0.0; private double mylon = 0.0; private LocationManager locationManager = null; private Location location = null; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.pilihfitur); View goToMapsButton = findViewById(R.id.toMapsButton); goToMapsButton.setOnClickListener(this); View goToOrderButton = findViewById(R.id.toOrderButton); goToOrderButton.setOnClickListener(this); } @Override public void onClick(View v) { // TODO Auto-generated method stub switch (v.getId()) { case R.id.toMapsButton: onChangeLocation(); break; default: break; } } private void onChangeLocation(){ locationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE); locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 100, 10, new myLocationListener()); location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); if(location != null){ mylat = location.getLatitude(); mylon = location.getLongitude(); Toast.makeText(PilihFitur.this, "Lokasi Anda: \nLat: "+mylat+" Lon: "+mylon, Toast.LENGTH_LONG).show(); } else Toast.makeText(PilihFitur.this, "Lokasi Tidak Ditemukan", Toast.LENGTH_SHORT).show(); } //Location Listener private class myLocationListener implements LocationListener{ @Override public void onLocationChanged(Location arg0) { // TODO Auto-generated method stub } @Override public void onProviderDisabled(String arg0) { // TODO Auto-generated method stub } @Override public void onProviderEnabled(String arg0) { // TODO Auto-generated method stub } @Override public void onStatusChanged(String arg0, int arg1, Bundle arg2) { // TODO Auto-generated method stub } } } </code></pre> <p>It works on emulator, I wonder how to make it work on my mobile phone. Thank you. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload