申请截止上后退按钮按Intent.ACTION_WIRELESS_SETTING查看无线设置后,按钮、Intent、ACTION_WIRELESS_SETTING

2023-09-12 05:52:35 作者:5.时间秒杀一切

类似于this的问题,我加的没有历史标志以我的登录活动。在另一边,我在登录活动的一个按钮,显示无线设置。当我preSS回无线设置的意图,应用程序关闭!

Similar to this question, I added no history flag to my login activity. in another side, i have a button in login activity to show wireless setting. When i press back on wireless setting intent, application closed!

我怎么能没有历史标志和 prevent从关闭的应用程序?

How can i have no history flag and prevent application from closing?

推荐答案

当您启动您登录活动使用的是没有历史标志完成另一项活动。您可能已启动无线设置旁边其他活动时,将你的无线设置到另一个活动或调用完成在登录活动。如果你保持无线按钮,在登录你不能使用没有历史。你必须设置一个标志,指示是否设置无线设置正在启动和的onStop称为完成(),如果该标志是假的。

When you launch another activity your login activity is finished using the no history flag. You either have to move your wireless setting to another activity or calling finish in the login activity when launching other activity beside wireless setting. In case you keep the wireless button in your login you cannot use no history. You have to set a flag to indicate if setting wireless setting is being launched and in onStop called finish() if this flag is false.

在您登录活动

private boolean mShowSetting;

在的onStop()

if (!mShowSetting)
{
    finish();
}

在你开始活动,以显示设置方法

In the method where you start the activity to show setting

mShowSetting = true;

和在onResume你必须设置

and in your onResume you have to set

mShowSetting = false;