简体   繁体   English

android手机按下home键后如何避免应用重启

[英]How to avoid app restart after pressed home button in android phone

I am implementing an android app with Xamarin.我正在使用 Xamarin 实现 android 应用程序。

I performed the following step.我执行了以下步骤。

  1. Start the APP启动APP

  2. The APP opened with first page "A" APP打开第一页“A”

  3. Pressed a button and go to page "B"按下按钮和 go 到“B”页

  4. Pressed home button on mobile phone.按下手机上的主页按钮。

  5. Click on the APP icon to go back to the APP.点击APP图标go回到APP。

  6. The app looks like restart and opened in page "A"该应用程序看起来像重新启动并在页面“A”中打开

Why would this happened?为什么会发生这种情况? How could I avoid this.我怎么能避免这种情况。

I have checked my android manifest file.我检查了我的 android 清单文件。

There is no "android:launchMode" item.没有“android:launchMode”项。

I had the same issue, and in my code, "NoHistory" was set true in MainActivity.cs.我遇到了同样的问题,在我的代码中,“NoHistory”在 MainActivity.cs 中设置为 true。 So I changed it to false:所以我把它改成了假的:

    namespace [YourAppName].Droid
    {
        [Activity(..., MainLauncher = true, NoHistory = false, ...]
        public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
        {
...

My app literally resumes when I select the app after pressing a home button.当我按下主页按钮后 select 应用程序时,我的应用程序从字面上恢复。 I'm wondering if your case is the same as mine.我想知道你的情况和我的情况一样吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM