NFCForms icon indicating copy to clipboard operation
NFCForms copied to clipboard

Crash in OnNewIntent when restarting the app.

Open Gekidoku opened this issue 6 years ago • 0 comments

Has to do with #23

Platform: Xamarin Forms 3.4.0.1009999 Xamarin Android Targeting Android 8.1 API 27 Minimum API 21

What happens: App crashes on restart.

Steps to reproduce.

Create A blank PCL project. Add NFCForms Build App Open app on device. Go back to device home screen by pressing the home key of your device. Reopen the app from the app drawer. Exception occurs.

So im writing this as an issue even though i know the solution. It has to do with the check on line 92 in this file

For some reason it thinks droidTag has a value on a regular restart of the app. However if you move the check to your MainActivity it sees it as null as expected. MainActivity

protected override void OnNewIntent(Intent intent)
{
            base.OnNewIntent(intent);
            //Check that normally occurs in line 92
            var TestIntent = intent.GetParcelableExtra(NfcAdapter.ExtraTag) as Tag;
            if (TestIntent != null)
            {
                x.OnNewIntent(this, intent);
            }


}

For now this fixes it however its not the prettiest of solutions.

Gekidoku avatar Jan 11 '19 13:01 Gekidoku