Я работаю над приложением, чтобы найти местоположение пользователя.
В моем просмотре карты я завершаю задачу идеально.
но при поиске места я не понял.
ниже мой код и ошибка logcat тоже ..
Код:
tv = (TextView)findViewById(R.id.tv1);
mlocationManager =(LocationManager)getSystemService(LOCATION_SERVICE) ;
Criteria criteria = new Criteria();
criteria.setAccuracy(Criteria.ACCURACY_FINE);
criteria.setPowerRequirement(Criteria.POWER_LOW);
String locatinProvider = mlocationManager.getBestProvider(criteria,true);
Location mlocation = mlocationManager.getLastKnownLocation(locatinProvider);
tv.setText("Last location lat:" +mlocation.getLatitude() + "long:" + mlocation.getLongitude() );
LogCat:
02-17 17:13:12.260: E/AndroidRuntime(1215): FATAL EXCEPTION: main
02-17 17:13:12.260: E/AndroidRuntime(1215): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.satyam.curlocation/com.satyam.curlocation.CurLocationActivity}: java.lang.NullPointerException
02-17 17:13:12.260: E/AndroidRuntime(1215): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1622)
02-17 17:13:12.260: E/AndroidRuntime(1215): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1638)
02-17 17:13:12.260: E/AndroidRuntime(1215): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
02-17 17:13:12.260: E/AndroidRuntime(1215): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:928)
02-17 17:13:12.260: E/AndroidRuntime(1215): at android.os.Handler.dispatchMessage(Handler.java:99)
02-17 17:13:12.260: E/AndroidRuntime(1215): at android.os.Looper.loop(Looper.java:123)
02-17 17:13:12.260: E/AndroidRuntime(1215): at android.app.ActivityThread.main(ActivityThread.java:3647)
02-17 17:13:12.260: E/AndroidRuntime(1215): at java.lang.reflect.Method.invokeNative(Native Method)
02-17 17:13:12.260: E/AndroidRuntime(1215): at java.lang.reflect.Method.invoke(Method.java:507)
02-17 17:13:12.260: E/AndroidRuntime(1215): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
02-17 17:13:12.260: E/AndroidRuntime(1215): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
02-17 17:13:12.260: E/AndroidRuntime(1215): at dalvik.system.NativeStart.main(Native Method)
02-17 17:13:12.260: E/AndroidRuntime(1215): Caused by: java.lang.NullPointerException