如下面的代码所示,我想在使用Activity
(app info)退出App info Intent
(ACTION_APPLICATION_DETAILS_SETTINGS)后运行我的函数。但是mylocation()
正在与开放的活动一起运行。怎么做到这一点?
@Override
public void onRequestPermissionsResult(int requestCode,String[] permissions,int[] grantResults) {
switch (requestCode){
case MY_PERMISSION_FINE_LOCATION:{
if (grantResults.length>0&&grantResults[0]==PackageManager.PERMISSION_GRANTED){
my_location();
}
else
{
Toast.makeText(getActivity(),"Location permission required for fetching your current location Permission>Enable location",Toast.LENGTH_LONG).show();
//redirect to app info
startActivity(new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS, Uri.parse("package:com.example.anonymous.trackerplus")));
my_location();
}
}
}
}
活动生命周期方法onDestroy
在活动结束时调用。因此,在您的活动中覆盖onDestroy
方法,并执行您希望在活动关闭时执行的任何操作。