I'm currently developing an app which uses GPS location on googleMaps view. I check if GPS feature is activated, and if not I redirect the user to the setting menu.
- If I click on Back button (by activating or not the GPS) I come back to my app - works fine
- If I click on Home button, and then relaunch my app, I am directly redirected to the GPS setting menu => my intent is still on.
The problem is that I do not know when kill this intent.
Here is the incriminated part of my code:
Button btnLocateMe = (Button)findViewById(Rsendlocationinfo.id.locateme);
btnLocateMe.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Context context = getApplicationContext();
objgps = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
//Check GPS configuration
if ( !objgps.isProviderEnabled( LocationManager.GPS_PROVIDER ) ) {
//Warn the user that its GPS is not activated
Toast gpsActivationCheck = Toast.makeText(context, "GPS deactivated - Touch to open the GPS settings.", Toast.LENGTH_LONG);
gpsActivationCheck.show();
//Open the GPS settings menu on the next onTouch event
//by implementing directly the listener method - dirt manner
mapView.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
//And here is my problem - How to kill this process
startActivityForResult(new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS), 0);
return false;
}
});
}
else {
//Location acquisition.
}
I tried some stopself(), finish(), in onStop(), onDestroy(), onPause()... It crashes or does not do anything... Could you please give me a hand ?