Home > Mobile >  Android a positioning error
Android a positioning error

Time:09-21

Android error here, what's the matter, thank you

CodePudding user response:

Package com. Example. Myapplication1;
The import android. The annotation. SuppressLint;
The import android. Content. Intent;
The import android. The location. The Criteria;
The import android. The location. The location;


The import android. Location. LocationListener;
The import android. Location. LocationManager;
The import android. OS. Bundle;
import androidx.appcompat.app.AppCompatActivity;

The import android. The provider. Settings;
The import android. View. The view;
The import android. Widget. TextView;


Public class MainActivity extends AppCompatActivity implements LocationListener {
The static final ints MIN_TIME=5000;
The static final float MIN_DIST=5;
LocationManager MGR.

TextView TXV;




@ Override
Protected void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TXV=the findViewById (R.i which extView3);

MGR=(LocationManager) getSystemService (LOCATION_SERVICE);





}



Protected void onResume () {


Super. OnResume ();
String best=MGR. GetBestProvider (new Criteria (), true);


If (best!=null) {
MGR. RequestLocationUpdates (best, MIN_TIME MIN_DIST, this);
MGR.





}







}





@ Override
Public void onLocationChanged Location (Location) {

String STR="positioning providers:" + location. GetProvider ();
STR +=the String. Format (" \ n dimensions: : % 5 f \ n: longitude: %. 5 f \ n height: : %, 2 f m ",
The location. GetLatitude (),
The location. GetLongitude (),
The location. GetAltitude ());




}

@ Override
Public void onStatusChanged (String s, int I Bundle Bundle) {

}

@ Override
Public void onProviderEnabled (String s) {

}

@ Override
Public void onProviderDisabled (String s) {

}


Public void setup (View v) {

The Intent of it=new Intent (Settings. ACTION_LOCATION_SOURCE_SETTINGS);
startActivity(it);




}


}


















CodePudding user response:

The mouse moves to the error code will have error message, sent to look at
  • Related