Deep Linking from browser not working Android - android

Deep Linking not working in android. I have pasted my manifest code here. When I tested, it goes to the website and not opening my activity in my app. Can someone help me fix this?
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.clinicloud.app" >
<application
android:name=".MainApp"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar" >
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="www.XXXX.com"
android:pathPrefix="/xyz"
android:scheme="http"/>
</intent-filter>
</activity>
<activity
android:name=".OnboardingActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ProfileViewActivity"
android:label="#string/title_activity_profile_view"
android:theme="#style/AppTheme.NoActionBar" >
</activity>
</application>
</manifest>
UPDATE:
adb shell am start -W -a android.intent.action.VIEW -d "http://www.clinicloud.com/xyz" com.clinicloud.app
Testing with adb opens the app but just with browser its not opening the app.

It's so annoying to test deep link through adb as the Android Developer team suggested. We won't get the gist of the problem I think. We want a straight forward method like paste a link to the browser in the same device which also installed the app already, hit GO, then the app comes up. But unfortunately, it won't work though.
Reason:
It's not a pure link, when you go to URL search of the browser it actually does a different URL, e.g: 'https://www.google.com/search?....'
Solution: Open a pure link
As #Parag Chauhan suggested, using another app to open a link, sure it is a definitely working solution because it's a pure link. However, this is not practical as expected.
Alternatively,
2.1. You can build your own simple web page (simple file *.html) with a link, then click it to open a pure link. Here is an example of the web page:
<html>
<h1>
<a id="deeplink" href="ss.wohui.learn://subscribed">Deep Link</a>
</h1>
</html>
2.2. Replace ss.wohui.learn://subscribed with what your deep link is.
2.3. Download the file to your device.
2.4. Open it by a browser.
2.5. Click on the Deep Link.
2.6. The app will start.

Add this code in Manifest.xml
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="www.clinicloud.com"
android:path="/xyz"
android:scheme="http" />
</intent-filter>
For test create another project and run below code
Intent i = new Intent(
Intent.ACTION_VIEW , Uri.parse("http://www.clinicloud.com/xyz")
);
startActivity(i);
You can also pass parameter in link. For more info, see my blog post Make a link in the Android browser start up my app?

This will only work if server has /.well-known/assetlinks.json properly defined in the root domain on the server.
So you need to create a json file and define there package name and SHA256. Then guys from backend should put this json file into root domain on the server.
The content of the file looks like:
[
{
"relation": [
"delegate_permission/common.handle_all_urls"
],
"target": {
"namespace": "android_app",
"package_name": "com.blablabla.staging",
"sha256_cert_fingerprints": ["XXXXXXXXXXXXXXXXXXX"]
}
}
]
You can split it for different environments: staging, beta, prod etc.
I tested in default browser of Samsung “Internet” and it fired the deeplink!

Related

App links working when using adb but not when using url in browser

I have added assetlinks.json to my domain and I have verified ith
https://developers.google.com/digital-asset-links/tools/generator
When my app is install I can see the link as verified under settings, and if I use adb like this:
adb shell am start -W -a android.intent.action.VIEW -d "https://my-domain.org/login?code=sdfsdfsdf"
It works, my app is opened. But if I type in "https://my-domain.org/login?code=sdfsdfsdf" in Chrome on the device, it simply open the URL in the Chrome browser and does not open my app.
Here is my AndroidManifest part:
<application
android:allowBackup="false"
android:icon="${appIcon}"
android:label="My app">
<activity
android:name=".MainActivity"
android:exported="true"
android:hardwareAccelerated="true"
android:launchMode="singleTask"
android:theme="#style/LaunchTheme"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="my-domain.org"
android:scheme="https" />
</intent-filter>
</activity>
</application>
Any ideas please?
Best regards
Søren
But if I type in "https://my-domain.org/login?code=sdfsdfsdf" in Chrome on the device, it simply open the URL in the Chrome browser and does not open my app
AFAICT, that is working as intended. App links are for links, not manually-entered URLs.
Create a Web page. Put a link to https://my-domain.org/login?code=sdfsdfsdf in the Web page. Load the Web page in Chrome. Click the link. Then, if app links are set up correctly, it should work.

Implement permissions on this exported component

I am coding an application for Android Automotive OS. It is a simple Hello World for now, but that is not the problem of the app so far.
To run the app in the in-built automotive emulator of Android Studio (I use the Canary version of Android Studio Electric Eel | 2022.1.1 Canary 10) I had to download an app called Google Automotive App Host, gonna refer to them as GAAH from now on, to be able to run my own created app. So far so good.
Now I came across a "problem" in my AndroidManifest.xml which says:
Implement permissions on this exported component. in the <service> section:
<application
android:allowBackup="true"
android:icon="#mipmap/example_icon"
android:label="#string/app_name"
android:roundIcon="#mipmap/example_icon_round"
android:supportsRtl="true"
android:theme="#style/Theme.Example">
<meta-data
android:name="androidx.car.app.minCarApiLevel"
android:value="1" />
<service
android:name="com.example.launcher.services.LauncherService"
android:exported="true">
<intent-filter>
<action android:name="androidx.car.app.CarAppService" />
</intent-filter>
</service>
<activity
android:name="androidx.car.app.activity.CarAppActivity"
android:exported="true"
android:launchMode="singleTask"
android:theme="#android:style/Theme.DeviceDefault.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data
android:name="distractionOptimized"
android:value="true" />
</activity>
</application>
Most of the answers stated, that android:exported should be set to false, which makes sense, so other apps don't have access to my own app.
The problem is, it also includes the aforementioned GAAH, which I need to be able to run it at all. It is not something game-breaking, it is just an inconvenience to deal with.
My question is: Are there ways to fix this issue and retain the ability for GAAH to run my app in AAOS?
Thanks in advance!
Grey
Edit: Expanded the XML section from <service> to <application>
The Google Automotive App Host holds the android.car.permission.TEMPLATE_RENDERER permission, so you should be able to use that as follows:
<service
android:name=(hidden)
android:exported="true"
android:permission="android.car.permission.TEMPLATE_RENDERER">
<intent-filter>
<action android:name="androidx.car.app.CarAppService" />
</intent-filter>
</service>
Additionally, you can further refine which hosts you trust by overriding the CarAppService::createHostValidator method.

Android Instant App URL execution trouble

I've created what I think is an android instant app. When ever I test the instant app functionality via Android Studio it works as expected. I've followed the instructions to generate the associated files for linking the instant app to a URL and placed them accordingly on my site. I've uploaded a signed bundle to a alpha closed testing track. The URL I'm using will work to launch the app. However, when I goto Settings-> Google-> Apps & Notifications and remove the instant app, the link no longer works it takes me directly to the website. I dont understand what I've done wrong as its my understanding that instant apps dont need to be preinstalled the URL should trigger I assume the play store to send over a bundle to load into memory (of some sorts). Am I correct in thinking I should be able to run an instant app with out installing it first? Any help would be appreciated. Below is my manifest file. Which I believe to be correct.
Almost identical problem to: InstantApp not being launched when clicking on link
I've tried the solution mentioned in that post. To no success.
If this description/question sucks please let me know I will try to make it better. Second post ever first got deleted I presume because it sucked? No idea. Thanks community ahead of time for your help.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:dist="http://schemas.android.com/apk/distribution"
xmlns:tools="http://schemas.android.com/tools"
package="learn.instantapps">
<!-- The following declaration enables this module to be served instantly -->
<dist:module dist:instant="true"></dist:module>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:targetSandboxVersion="2"
android:theme="#style/AppTheme">
<activity android:name="learn.instantapps.MainActivity">
<meta-data
android:name="default-url"
android:value="https://mysite/main" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter android:order="1">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="https"
android:host="my site"
android:path="/main" />
</intent-filter>
<intent-filter android:order="1">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="http"
android:host="my site"
android:path="/main" />
</intent-filter>
</activity>
</application>
</manifest>

No Launcher activity found, The launch will only sync the application package on the device

I got this warning from console when running my application on emulator
No Launcher activity found!
The launch will only sync the application package on the device!
In fact i have declared an activity as the main launcer in AndroidManifest.xml file
<activity
android:name=".myActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
I don't need any other intent-filter to use on that activity.. just basic main and launcher
What's the reason? Please give me a solution..
If the launcher activity is in another package, you will need to specify that as well.
For instance, from one of my personal projects:
<activity
android:name=".activities.MainScreen"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
The MainScreen.java is in the activities package. Also, check spelling for upper or lower case letters.
It seems that you must have "android.intent.action.MAIN" specified immediately before "android.intent.category.LAUNCHER". I encountered the same issue as you when I had the following:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.SEARCH" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
The issue was resolved only when I re-orderd as follows:
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
In all normal circumstances, listen to what the other guy(s) said.
I was able to replicate your issue using a Mac Book Pro & Eclipse Indigo. when you create your android project, you MUST have Eclipse start you off with a templated activity (like a blank activity). if you don't, and you try to add an activity to your manifest later, Eclipse just derps and can't find the launcher. (i looked at other manifest files and i can't see any differences. i really don't think it's your poor manifest's fault in this special case.)
here's your lazy easy fix:
start a new project, and copy over all the files (make sure you back up ur files first, in case you delete something wrong or mess up the ordering)
Using Eclipse Indigo, open Run Configurations windows, click the project and use launch default activity on Android tab, choose Automatically pick compatible device...and apply.

Android app won't open after i install. But it can run in emulator

I have exported my app from eclipse and installed it on my phone. After installation, I click open from package installer, but the installer force close. Afterwards, when I tried to launch the app, nothing happen after I click it. I click the app in app drawer but it return to home screen instead.
I am able to run in emulator and in debug mode when I connect my device via usb, but not when I export the apk to install.
Note that this is not the first app that I exported to install. Previous apps are working fine.
I found the problem! I had declared the activity 2 times in the manifest with different properties, like:
<activity android:name=".myclass"></activity>
and
<activity android:name=".myclass" android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Remove the unwanted one from the manifest and it will work.
Check your android emulator version and the firmware version of the phone. If firmware version is not supported for that app you will be install from adb, but you cant start the app.
Check the settings to be able to install the unknown apps in
Settings->Applications and check box "Unknown Sources"
Try to check on permission in Android Manifest. I was having the same problem earlier when i install a NFC app. I forget to give permission for NFC. After i gave the permission it works fine for me. Please check your AndroidManifest.
I spent few days to identify the problem why it occurred .But I solved my problem this way- Modification in Android Manifest
<activity android:configChanges >
<intent-filter android:label="#string/launcher_name">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<I removed my code here that i added for reference to google play store for reference >
Remove the unwanted one from the manifest and it will work.
Try to search errors in your Android manifest, i have the same problem and the problem was the 'R' in the category LAUNCHER are in lower case.
like this:
<category android:name="android.intent.category.LAUNCHEr" />
to solve it, simple:
<category android:name="android.intent.category.LAUNCHER" />
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
Removing the configuration of all the modules that are not from the app worked for me. In other words, just leave the Project.app module and check its configuration.
Edit Run/Debug Configurations -> Android app -> app
GL
if you use splash in react native:
To avoid error: Binary XML file line #XXX: requires a valid src attribute
inside a layer-list, use:
<item android:drawable="#drawable/image" />
instead of:
<item>
<bitmap android:src="#drawable/image"/>
</item>
My solution is to add this flag in download manager when application is install
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
In my case - i had this flag -> intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
I replaced it with Intent.FLAG_ACTIVITY_NEW_TASK and everything worked!
My Manifest looked like this. Those that need help and have a similar manifest look bellow.
<activity android:name=".login.activities.SplashScreenActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data
android:host="example.com"
android:scheme="https"/>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
You just need to remove the
< data>
element in the intent-filler and it should work.

Categories

Resources