从设置意图返回到应用程序
在我的应用程序中,我需要使用下一个代码进入手机的设置活动:
`Intent myIntent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
startActivity(myIntent);´
然后在设置活动中,当用户按返回键时,我想返回到我的应用程序,这可能吗?
谢谢
In my applicattion i need to go to de settings activity of the phone whith the next code:
`Intent myIntent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
startActivity(myIntent);´
Then in the settings activity, when the user press BACK key, i want to return to my applicattion ¿it's possible?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为原因是因为您已将代码放入 onCreate() 方法中。尝试将其拍摄到 onStart() 方法。当用户单击后退按钮时,将调用此方法。
有关 Activity 生命周期的详细信息,请参阅此页面
I think the reason is because you have put your code in onCreate() method. Try to movie it to onStart() method. Them when user click back button this method will be called.
For more info about activity life cycle please see this page
当按下后退键时,它应该自动返回到上一个活动。我在我的一个应用程序中使用位置设置活动,当用户按回时,它会将其返回到应用程序。唯一可能不会发生的情况是,如果您的应用程序关闭以释放另一个应用程序/服务的内存,但如果您只是打开位置设置,则这种情况不太可能发生。
It should automatically go back to the previous activity when the back key is pressed. I use the location settings activity in one of my apps and when the user presses back it returns them to the app. The only time it might not happen is if your app is closed to free memory for another app/service, but this is very unlikely if you are just opening the location settings .