Note that there are some explanatory texts on larger screens.

plurals
  1. PONot getting the current GPS values
    primarykey
    data
    text
    <p>I am Doing a small app which requires the current GPS values. For this i read many tutorials and i tried using this <a href="http://androidcompetencycenter.com/wp-content/uploads/GPSApp.zip" rel="nofollow">sample code</a>. but i am not getting the values. when i run the code it forcibly closing the application. Here is my logcat.</p> <pre><code>03-27 12:57:49.881: E/AndroidRuntime(604): FATAL EXCEPTION: main 03-27 12:57:49.881: E/AndroidRuntime(604): java.lang.UnsatisfiedLinkError: onCreate 03-27 12:57:49.881: E/AndroidRuntime(604): at com.google.android.maps.MapActivity.onCreate(Native Method) 03-27 12:57:49.881: E/AndroidRuntime(604): at com.android.and.AndActivity.onCreate(AndActivity.java:48) 03-27 12:57:49.881: E/AndroidRuntime(604): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 03-27 12:57:49.881: E/AndroidRuntime(604): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627) 03-27 12:57:49.881: E/AndroidRuntime(604): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679) 03-27 12:57:49.881: E/AndroidRuntime(604): at android.app.ActivityThread.access$2300(ActivityThread.java:125) 03-27 12:57:49.881: E/AndroidRuntime(604): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033) 03-27 12:57:49.881: E/AndroidRuntime(604): at android.os.Handler.dispatchMessage(Handler.java:99) 03-27 12:57:49.881: E/AndroidRuntime(604): at android.os.Looper.loop(Looper.java:123) 03-27 12:57:49.881: E/AndroidRuntime(604): at android.app.ActivityThread.main(ActivityThread.java:4627) 03-27 12:57:49.881: E/AndroidRuntime(604): at java.lang.reflect.Method.invokeNative(Native Method) 03-27 12:57:49.881: E/AndroidRuntime(604): at java.lang.reflect.Method.invoke(Method.java:521) 03-27 12:57:49.881: E/AndroidRuntime(604): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) 03-27 12:57:49.881: E/AndroidRuntime(604): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 03-27 12:57:49.881: E/AndroidRuntime(604): at dalvik.system.NativeStart.main(Native Method) </code></pre> <p><strong>EDIT</strong></p> <p>Here is my Activity.</p> <pre><code>public class AndActivity extends Activity implements LocationListener { private TextView latituteField; private TextView longitudeField; private LocationManager locationManager; private String provider; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); latituteField = (TextView) findViewById(R.id.TextView02); longitudeField = (TextView) findViewById(R.id.TextView04); // Get the location manager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); // Define the criteria how to select the locatioin provider -&gt; use // default Criteria criteria = new Criteria(); provider = locationManager.getBestProvider(criteria, false); Location location = locationManager.getLastKnownLocation(provider); // Initialize the location fields if (location != null) { System.out.println("Provider " + provider + " has been selected."); int lat = (int) (location.getLatitude()); int lng = (int) (location.getLongitude()); latituteField.setText(String.valueOf(lat)); longitudeField.setText(String.valueOf(lng)); } else { latituteField.setText("Provider not available"); longitudeField.setText("Provider not available"); } } /* Request updates at startup */ @Override protected void onResume() { super.onResume(); locationManager.requestLocationUpdates(provider, 400, 1, this); } /* Remove the locationlistener updates when Activity is paused */ @Override protected void onPause() { super.onPause(); locationManager.removeUpdates(this); } @Override public void onLocationChanged(Location location) { int lat = (int) (location.getLatitude()); int lng = (int) (location.getLongitude()); latituteField.setText(String.valueOf(lat)); longitudeField.setText(String.valueOf(lng)); } @Override public void onStatusChanged(String provider, int status, Bundle extras) { } @Override public void onProviderEnabled(String provider) { Toast.makeText(this, "Enabled new provider " + provider, Toast.LENGTH_SHORT).show(); } @Override public void onProviderDisabled(String provider) { Toast.makeText(this, "Disabled provider " + provider, Toast.LENGTH_SHORT).show(); } } </code></pre>
    singulars
    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