Android Error with Back Button

I’ve noticed that if I click on my phone’s back button, the app closes with an error. I have a feeling this is not a Fuse bug, but I’m not sure where I am supposed to handle this. What I’d like is for the application to just minimize itself if the user clicks on the back button when on the main screen. By minimize, I mean it should disappear from view but still show up in the recent applications menu in Android. That appears to be the default behaviour for apps I’ve tried…

Here are the messages I’m getting when this happens:

12-09 12:44:21.884 30401 30401 E remindme: Uno.NullReferenceException: Object reference was null
12-09 12:44:21.885 30401 30401 F libc    : Fatal signal 6 (SIGABRT), code -6 in tid 30401 (oftware.android)

12-09 12:44:21.942   199   199 F DEBUG   : pid: 30401, tid: 30401, name: oftware.android  >>> com.nestedsoftware.android <<<

12-09 12:44:22.536   778  2840 W InputMethodManagerService: Got RemoteException sending setActive(false) notification to pid 30401 uid 10102

12-09 12:44:22.565   214   214 I Zygote  : Process 30401 exited due to signal (6)
12-09 12:44:22.595   778  1321 I ActivityManager: Process com.nestedsoftware.android (pid 30401) has died
12-09 12:44:22.595   778  1321 D ActivityManager: cleanUpApplicationRecord -- 30401

Process com.nestedsoftware.android terminated.

Note: I find that I can fix this error by adding a Navigator and embedding my main screen inside of it. However, the back button now has no effect at all. Would it be possible to make it put my application in the background as I described above?

System Information:

  • Windows 10 Home build 16299/Intel i5 6400/8 GB Ram/No Additional Video Card

  • Fuse version 1.4.0 (build 14778)

  • Target: Nexus 5, Android 6.0.1

Hi, we’ll need to see a minimal, complete reproduction of an app that reliably crashes every time for you.

Hi,

Sure - it seems this trivial app does the trick:

<App>
    <ClientPanel>
        <ScrollView>
        		<Panel>
    	    		<Text Value="Hello"/>
    	    	</Panel>
        </ScrollView>
    </ClientPanel> 
</App>

I select ‘Export for Android’ from the ‘Export’ menu in Fuse. I then click the phone’s back button once the app comes up. I get a popup window in Android saying “Unfortunately bug_report has stopped.”

Hello! I’m seeing this same behavior myself. I have a single-page app that ‘stops’ in Android when the back button is pressed. The remains in the running apps list and can be restarted from there as well. Is there some special way this should be handled? I’m not using navigator or router in my code. This is a release build, using Fuse 1.5.0, built as:

fuse build --target=Android --configuration=Release

BTW, there are no errors thrown when “simulated back” is pressed in the preview (as would be expected, just wanted to throw that out there).

There is no particular reason why a crash would occur, so if you have any other useful details (OS version, device etc.), we’d like to see them.

As for your question:

Is there some special way this should be handled?

Yes, there is. You would want to use OnBackButton, probably coupled with WhileCanGoBack and fuse-homescreen library.

Thanks @Uldis! Happy to provide more info:

Devices: Pixel XL w/Android 8.1.0 (same issue on a Note 3 w/Android 5.0).

Fuse version 1.5.0 (build 15046)

Uno version 1.4.3 (build 6115) Windows 10 x64 83d8656

Product information
Product.Commit 83d8656035e71a42151ce35b76e3b59cf7725e08
Product.Version 1.4.3.6115

Runtime environment
Environment.OSVersion Microsoft Windows NT 6.2.9200.0
Environment.Version 4.0.30319.42000

Early yesterday, before I saw your message, I successfully implemented:

<OnBackButton><HomeScreen Type="CallIntent" /></OnBackButton>

In addition, I am able to build several of the Fuse examples and they do not stop, so it leads me to believe I have done something wrong, or uncovered a bug. I have tried removing some parts of my project, in an attempt to find the cause, but have not been successful. I have also used uno clean liberally to ensure nothing is residual. I can share my project with you if it helps.

While Bjorn-Orlav’s contribution is excellent and extremely welcome in light of the missing functionality in the base framework, several very old threads in this forum have indicated Fuse will soon have this functionality built-in. What is the possibility of simply implementing the HomeScreen functionality into the core product?

In this thread: https://www.fusetools.com/community/forums/howto_discussions/can_i_exit_app_with_androids_back_button?page=1&highlight=c3d5a3c3-e3dd-438a-a125-859f51cc13b6#post-c3d5a3c3-e3dd-438a-a125-859f51cc13b6 it is indicated that a build switch enables the functionality, is this something we should or should not do. I am not sure if this is a hack or a recommended procedure.

Thanks again for all of your awesome help! You’re one of the best product evangelists I’ve seen for any product!