xamarin/Xamarin.Forms

MainActivity is getting created twice causing app crashing in navigation

开放

#5,813 创建于 2019年4月4日

 (5 条评论) (0 个反应) (0 位负责人)C# (1,926 个派生)batch import
e/6 :clock6:help wantedi/highinactivep/Androidt/bug :bug:up-for-grabs

仓库指标

星标
 (5,644 个星标)
PR 合并指标
 (30 天内没有已合并 PR)

描述

Description

Hitting the home button and then clicking on the app icon in the home screen causes another MainActivity to create again and has weird side effect that causes a crash in the Navigation stack.

NOTE: I am only able to confirm when the apk is build from the IDE and immediately deploy to device for the first time. After the crash, relaunching the app doesn't happen again, but will appear again if you compile and deploy again.

Steps to Reproduce

Sample project https://1drv.ms/u/s!ApQ7q0pIhq0egVXFMuvC5OX1iZIS

  1. Compile and deploy the onto Android device
  2. After the app is launched hit the home button and open the app by finding the app icon in the home screen (if you reopen the app from task manager it does not happen)
  3. If you put a break point in the MainActivity onCreate, you will see that it creates another activity onto the stack 4 a. At this step if you attempt to display an dialogue/alert, the app will crash with "can't attach to view" exception 4 b. After step 3 if you hit back button you will see that there is a previous created activity

However if you were to use back button at step 2, and return to the app in any mean, it will work fine as there is only one activity in the navigation stack

Expected Behavior

It shouldn't create a new Activity on step 3

Actual Behavior

It created a new activity and I believe xamarin form is still referencing the first activity that got created rather than the second activity that is displayed. This causing exception.

Basic Information

  • Version with issue: 3.4.0.1008975
  • Last known good version: N/A
  • IDE: Visual Studio for MAC 3.0 (build 3001)
  • Platform Target Frameworks:
    • Android: 9.2.0.5
  • Android Support Library Version:
  • Nuget Packages: 4.8.2.5835
  • Affected Devices: one plus 6T (pie) the only device I tested on

Screenshots

N/A

Reproduction Link

https://1drv.ms/v/s!ApQ7q0pIhq0egVTJbOmdbkZmnZLl

贡献者指南