Open chrome browser and then how to return to app inventor?

Hello, Greetings to all!!
Thank you for being able to participate in this forum!
I'm almost new to appinventor, and although I've studied a little bit of python, I still don't master much.

I'm trying an app that opens the chrome browser and works well with activitystarter, but when I want to go back to the appinventor again with the back button of the mobile, it doesn't come back... How could I do that?

Toni

Hello Toni

I’m stumped for an answer - your App should still be on Screen, so closing Chrome would reveal it, but perhaps it is possible that the behaviour differs by device manufacturer.

By the way, test the Web Viewer if your App is targeting later version Android (8+), it’s possible that you do not need to launch an external browser.

Hey, ChrisWard,
Thank you for your help. Yes, with the web viewer it works, but for what is the application I need to open the chrome, and then come back again!

Another thing I need to do and looking in the documentation and web pages I can’t find is to close the application when the application goes to the background.

Try this simple aia project, can you come back from Chrome with one press of the Back Button ?

ChromeTest.aia (2.1 KB)

You could try doing something with Taifun's Tools Extension: ActivityStateChanged - not sure if putting Close Application in there when activity state is pause or stop ? If it does work, this may have undesirable effects on the operation of your app....

As an alternative you could use this to "reset" your app, I found this worked very well - to clear sensitive data from the app on pause/resume.

1 Like

Thank you very much TimAI2 for your help!
I just tried it (android 9) and when I hit the back button it minimizes the app, but it doesn’t come back. When I click again on the application’s shortcut, it opens the Chrome again, but the tab I had opened has closed it. So with back button, it closes the opened tab in the chrome, but it doesn’t come back to the application.

I’m going to try…

Did you try compiled app ?

It is Android 9, what is the device (or devices) ?
If you can test on another device/android version ?

Yes, I generated the apk and installed it, but it still doesn’t work. When I hit the back button, it minimizes the chrome and shows me the home screen. But the apk stays open with the chrome in the background…
I tried it on the samsung tablet with android 7 and pixel 2 with android 10

@ewpatton

Need to resurrect this thread as I am seeing the same behaviour with compiled apps on an HTC10 Android 7 device when going to Chrome with the activityStarter. On pressing the back button I am returned to the home screen of the device. If I press the square button and select the Chrome page, I am then returned to the app. I should be going straight back to the app.

All works fine with compiled and companion on my Genymotion Android 9.

Don't think there is anything untoward with my blocks that could be causing the problem...:

image

It is worse with companion on that device, when selecting the Chrome page after pressing the square button, it opens Chrome on the last tab previously used/available (I have three tabs running). Tested without any tabs same issue.

Is one of these the hook you need to regain control from Chrome?
component_event (1) component_event

but "do" what ?

Made some progress

image

This works with companion, had to choose Chrome (Just Once, then Always)

will try compiled now.

1 Like

Works when compiled as well....crazy stuff....
Need to force use to use Chrome (or probably a proper browser) to get the web pages from Google to work.

Any testers Android 8/9/10:

This one with the full Chrome request in the activity Starter (which fails)
ChromeTest.aia

and this one which offers all "browsers" for use to choose from (which works)
ChromeTest2.aia (2.0 KB)

Please test with companion and compiled apps

1 Like

APK compile taking a month of Sundays!?!

Tests Samsung S8, Android 9:

ChromeTest.aia
Companion

  • Uses Chrome to display google.co.uk
  • Home button closes Companion
  • Back button goes to recent website viewed
  • Reset connection fails
  • Companion force stop also fails - necessary to restart phone!

ChromeTest.aia
APK

  • Uses Chrome to display google.co.uk
  • Home button closes App
  • Back button goes to recent website viewed

ChromeTest2.aia
Companion

  • Offers Choice of available browsers
  • Chrome selected, displays google.co.uk
  • Home button closes Companion
  • Back button returns to App
  • Reset connection works

ChromeTest2.aia
APK

  • Offers Choice of available browsers
  • Chrome selected, displays google.co.uk
  • Home button closes App
  • Back button returns to App

Thanks Chris, that's 7 and 8 behaving the same way.

I had forgotten this topic and I have tried it now and yes, it works. Thank you!