I followed this to Enable GPS Programatically
So here its working with Ok and cancel Buttons
so if User Press Cancel Button App will exit and if he press ok app will work fine with GPS.
Here In my application I have 12 activities all activities need GPS(Location)
With that example its works fine but If user disable GPS manually What should I do I need to add the Same code for all 12 activities...? can any one suggest me how to monitor GPS status on or off on each activity and if User disable GPS after opening a activity App should close...
I already Tried this but its working only for one time
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
if (requestCode == 1000) {
if(resultCode == Activity.RESULT_OK)
{
String result=data.getStringExtra("result");
}
if (resultCode == Activity.RESULT_CANCELED) {
finish();
System.exit(0);
}
}
}