Android - My app replaces an other one when using the app switcher - android

I'm developing an app that receives data using intents(ACTION_SEND). When I'm sharing content from Chrome for instance, the content reaches my app, but suddenly my app replaces Chrome in the app switcher. So, if I have my app and Chrome opened, after the data sharing I have two instances of my app(even if the Chrome icon appears in top of that window, if I tap it, opens my app).
Any ideas about what is going on here?
Edit: I can't post code here for legal reasons, but tinkering with it I've discovered that this issue is happening on Android 11 and only sharing links from Chrome(using the share option in the Chrome menu). Sharing links from Firefox works ok.

Related

My webapp as a shortcut won't open in a dedicated window on Chrome (Android)

The title may be confusing. Let me explain :
When you open a website in Chrome in Android you can create a shortcut to the page clicking the three dot icon in the top right corner, after choosing "add to Home Screen".
For some website/webapp the shortcut acts as a standalone app starter. In other words it opens in a dedicated container in Android and if you were to tap the shortcut again the app wouldn't open twice, instead it is aware a container already exist and send it to the front (only one instance).
It is as if Chrome recognizes the website as an app.
But for my webapp it doesn't work. If I make a shortcut on the home screen and tap it, the page opens in a new tab in the main Chrome instance. This webpage/webapp is supposed to be standalone, there is no point to have multiple instance of it in the browser. Ideally when I tap the shortcut Chrome should open the app in its dedicated app window (to avoid clogging the tab list uselessly.)
Does anyone know how to circumvent this problem? Are there some instructions to add in the HTML to force Chrome to recognize the page as an "app" and make use of its own container?
As I write this question I believe this has something to do with Progressive Web App, Chrome only accepts to "install" your website as an app shortcut if it follows a certain format.
But also my app doesn't need to implement all these progressive features, it's just a simple app that only myself is using.
So if you know how to force Chrome to produce this effect without writing a lot of code I would appreciate.
It does need to be a PWA. Here are the requirements.

Launch PWA Add To Home Screen from another app on Android/iOS

I have a somewhat weird question where I don't actually know the correct terminology so if I incorrectly state something please correct me so I can better ask this question. Right now I guess I'm more focused on Android since I have one and can easily emulate and test, but eventually I would like to get it to work on iOS.
Goal: Launch a PWA (Progressive Web App) which was added to the home screen of my device through the A2HS (Add To Home Screen) from another application.
So I currently have two PWA added to my home screen through google chrome, called PWA1 and PWA2. These are URLs that when accessed VIA chrome I can add to my home page through A2HS and when I open it, it functions and looks just like an app.
MyApp - Android/iOS app Xamarin
PWA1/2 - Progressive Web App added to home screen using Google Chrome's A2HS
I am currently working on another app right now called MyApp, and I would like to know how I can launch my PWA1 and PWA2 from within MyApp. I know I am able to launch other apps installed on my device using PackageManager and intent to launch the app but since these aren't actually real apps I have no idea how to access the ones that are saved to my home screen.
I'm pretty sure I can implement the button on my app opening com.android.chrome but that would just open the chrome app not specifically the PWA on my home screen. So how would I go about doing this?
My first train of thought is that somewhere on the Android OS or in Chrome there is a lookup of the available PWA added to the home screen. If I am able to find that I was hoping there was a way to specify to chrome or the PackageManager that I want to launch com.android.chrome:PWA1 and it will load the one that was added to my home screen.
Any feed back on whether this is possible, or what I should clarify would be greatly appreciated!
I have triggered the prompt to choose to open the link from PWA or the browser.
I'm using Custom Tab from Chrome, you can read implementation here.
Something like this:
CustomTabsIntent.Builder().apply {
setShowTitle(true)
setUrlBarHidingEnabled(true)
setColorScheme(COLOR_SCHEME_SYSTEM)
setInstantAppsEnabled(false)
setStartAnimations(this#openWeb, R.anim.right_in, R.anim.left_out)
setExitAnimations(this#openWeb, R.anim.left_in, R.anim.right_out)
setShareState(SHARE_STATE_OFF)
}.build().launchUrl(this, Uri.parse("https://your.pwa.url"))
If you installed the PWA in your device, when opening the link using the custom tab... it should triggered the prompt, like this:
Or if you choose your PWA as default app to handle your link, it should automatically open your PWA

Switching from website to instant app

Say someone taps a link and is shown the appropriate speed bump page prompting the user to open the app or the website and the user chooses to open the website (potentially not knowing why/how they are able to open an app they don't have).
How does that user launch the instant app after choosing to open the website rather than the instant app? I know the user can choose to go to the website after launching the instant app (via the notification) but I don't know how to do the opposite.
As a side note, iOS makes it easy to toggle between a website and app from deep links. Safari shows a small banner that has an "Open app" button if you pull down from the top of the webpage slightly. When you are in the app there is a direct-forward link in the upper-right status bar. This makes it super easy to toggle between the two.
If you're in Chrome you can tap on the https/lock and there can be a button showing open instant app. However this doesn't show up on all android versions.
Tested on android 6 showing
Tested on Android 8 not showing
hope this helps
Play Console has "Mobile holdback" feature which allows developers to choose the percentage of users who will see the Instant app, so it looks like it cannot be directly controlled by users.

Chrome homescreen web app - Newsfeed link opening in browser

I recently followed Googles steps to have a simple homescreen web app going; something that gets created when I choose the "Add to Homescreen" option on an android with Chrome. The manifest helps define the icons and name and such, and most links within this standlone app thing stay within the app... except the /newsfeed page.
Whenever I click any link to get to the domain.com/newsfeed page on my site it opens it up in the Chrome browser instead. Every other link stays put within the homescreen app, including ones that lead off-site.
There's nothing special about that page as far as I can see; it doesn't have a target=_blank or any other details that aren't present on other links. My current guess is that somehow it reacts differently to links with "newsfeed" in them, thinking that I'm somehow incapable of handling dynamic content within the homescreen webapp.
Any ideas? It's not a HUGE deal, but I'd really rather know why that one page won't stay in the homescreen webapp.

Create a Android launch icon for Website

I have a responsive website which can be accessed across multiple devices, our design and application is mainly targeted for mobile users.
To ease access to the site, we want to create a launch icon which will apear on the mobile home screen and user can access the site using one touch, as against launching the browser and typing the url / opening the bookmarked page.
I found a solution for it in IOS, which is also supported by the safari browser using which you can save the page url as a launch icon, can a similar feature be found on a android device? I would also be interested in prompting the users to create the launch icon if they are accessing it from a mobile phone /tablet.
Default Android
This is the preferred way since this is all based on default Android options and doesn't add any maintenance.
As a widget from bookmarks
If on android you long press the home screen and then select the widget option you can create a bookmark. This will let you select a bookmark from your chrome bookmarks to be linked on the desktop. If that works for you you're all set with default Android features. The icon from the bookmark is used on the desktop.
Directly from Chrome
Similar to this approach is selecting the "Add to homescreen" option in the chrome settings menu.
The icon is the icon from the website.
Custom alternative
As stated before the alternative is to create an app that only serves the purpose of being a link to your mobile website. Then you have 2 options:
Using default browser of user
An app that uses intents to open the default browser of the user with your URL. This should be the way to go since the user can now keep on using his favorite browser.
In app browser
An app that contains a single webview loading the URL of your webapp. This last option gives you more control over the browsing experience (blocking scripts, overriding requests, ...). However the user can no longer use his preferred browser.
About the icon
In both cases the Icon will be the icon configured and distributed within the app. This also introduce the need of a new app release if the icon or the URL should change.
About the code
Code examples and information about this webapp in app approach can be found at http://developer.android.com/guide/webapps/webview.html
Another good resource is https://developers.google.com/chrome/mobile/docs/webview/overview where mobile app development using a native android app with webview is covered with several aspects like tools, css tricks and more.
If I have understood your issue exactly then you would want to show a launcher icon for your website without creating any activity (screen) or doing any programming in android.
If this is the case then my answer is YES, as depicted in snap Google chrome provides this functionality to create a launcher/app icon on home screen.
Some webBrowsers like chrome enable the user to make a bookmark for a specific URL as an icon in the home screen, but I did not get evolved in a project like that. So it is possible.
You can make it simple by creating an application that contain only a webview to open your url and you can then create an icon for your app that hold the website on the home screen as the following in this answer
In my 3 years on Android I have never seen a website ask me to make a shortcut on my homescreen, however, the standard Android browser as well as Dolphin can create shortcuts from bookmarks.
While researching this with a quick search I found this thread states that Chrome allows this as well, and there's even a way to specify a homescreen icon for your users.

Categories

Resources