I'm trying to get make a url open the app and to have some data with this url passed into the app, but it doesn't work.
My activity tag in AndroidManifest.xml:
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize"
android:launchMode="singleTask"> <-- added this
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="fcm.ACTION.HELLO" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<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:scheme="conv"
android:host="convid"/> <-- so urls of the form 'conv://convid/ will open the app
</intent-filter>
</activity>
And I added to the entry class of the app:
componentDidMount() {
Linking.addEventListener('url', (e) => {
console.log("url", e);
});
Linking.getInitialURL().then((url) => {
if (url) {
console.log('Initial url is: ' + url);
}
})
}
But when I open the browser and go to conv://convid nothing is being logged and the app doesn't open.
Of course I opened my app before the browser.
The app will not open if the link is entered into the browser's address bar. It has to be a web page <a/> tag like:
link inside some page. (https://developer.chrome.com/multidevice/android/intents)
As you probably do not have a web page to put tag inside, for your tests you can use adb command. Open the console and write the following line:
adb shell am start -W -a android.intent.action.VIEW -d "YOURHOST://YOURSCEME/" com.YOURAPPNAME
for example in your case it should be something like (change YOURAPPNAME with the name of your app):
adb shell am start -W -a android.intent.action.VIEW -d "convid://conv/" com.YOURAPPNAME
if you are using windows and, and if it says adb command is undefined you need to run the command from platform-toolsfolder inside your SDK folder such as:
Android/Sdk/platform-tools/
Related
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.
I need to open a deep link in my Android app, like uniqueName://post/detail/1 in the router but it always removes the first part of the link: (post) and delegates only the rest: /detail/1 instead of /post/detail/1
AndroidManifest.xml:
<intent-filter android:priority="1">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="uniqueName"/>
</intent-filter>
onGenerateRoute:
Route? onGenerateRoute(RouteSettings settings) {
print('Change main route to: ${settings.name}');// prints /detail/1
}
Test:
adb shell am start -a android.intent.action.VIEW
-c android.intent.category.BROWSABLE
-d "uniqueName://post/detail/1"
I'm trying to enable deep linking so that certain links launch my app.
I read this turotial https://developer.android.com/training/app-indexing/deep-linking.html and following it pretty close but when I try to test it by using adb to send the VIEW intent to the app I just get the error
Error: Activity not started, unable to resolve Intent { act=android.intent.actio
n.VIEW dat=example://gizmos flg=0x10000000 pkg=com.myapp.DeepLinkActivity }
DeepLinkActivity.java
public class DeepLinkActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getIntent().getAction() == Intent.ACTION_VIEW) {
Uri uri = getIntent().getData();
}
}
}
Android Manifest declaring deeplink activity
<activity android:name="com.myapp.DeepLinkActivity" >
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data
android:host="gizmos"
android:scheme="example" />
<!-- Accepts URIs that begin with "http://www.example.com/gizmos” -->
<data
android:host="www.example.com"
android:pathPrefix="gizmos"
android:scheme="http" />
</intent-filter>
</activity>
ADB command to send the view intent
adb shell am start -W -a android.intent.action.VIEW -d "example://gizmos" com.myapp.DeepLinkActivity
But I don't think I even need the full path to the activity
adb shell am start -W -a android.intent.action.VIEW -d "example://gizmos" com.myapp
Try skipping package param entirely. I had exactly same problem and it works.
adb shell am start -W -a android.intent.action.VIEW -d "example://gizmos"
Comment out the second data part from your Android Manifest. As per google documentation of deep link :
"Intent filters may only contain a single data element for a URI pattern. Create separate intent filters to capture additional URI patterns."
In your manifest you defined your scheme as "http" but in your intent constructor you are using "example."
The problem is you have one intent filter for 2 types of deep links:
<activity
android:name="app.myActivity"
android:label="#string/app_name"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!-- Accepts URIs that begin with "example://gizmos”-->
<data
android:host="gizmos"
android:scheme="example" />
</intent-filter>
<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.example.com"
android:pathPrefix="/gizmos"
android:scheme="http" />
<!-- note that the leading "/" is required for pathPrefix-->
</intent-filter>
</activity>
And you will be able to use both on the ADB shell. Please see my full answer here
Simply try as follows
Command:
adb shell am start -d your-deep-link
Example:
adb shell am start -d rmagazine://opensetting/v1
I'm pulling my hair out over this; the instructions seemed so simple, yet they just don't work.
Here's the manifest activity intent code:
<activity
android:theme="#style/Theme.Buhzyellowtoplighttabs"
android:name="com.blah.package"
android:configChanges="orientation|keyboardHidden"
android:windowSoftInputMode="adjustResize|stateHidden"
android:screenOrientation="portrait" >
<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:scheme="http" android:host="www.buhz.com" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
So you would think that when I run the app on my phone, go to my browser and go to www.buhz.com it should give me a option to launch the app, right?
As far as I'm aware, this will only work when you click a link to the site, not when you type the URL in.
On the off-chance you're reading this on the Android device your testing on, here is a link for you
Here is the approach that worked for me
The androidmanifest file content is as follows:
<activity
android:name=".SecondActivity"
android:label="#string/title_activity_second">
<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.example.com"
android:pathPrefix="/roses"
android:scheme="http" />
</intent-filter>
</activity>
The command entered in terminal is as follows :
./adb shell am start -a android.intent.action.VIEW -d "http://www.example.com/roses" com.example.irfan.helloworld
Note:
If your operating system is Windows you can remove the first "./" in the above command.
Result:
It opened the "Second Activity" of my app automatically.
Hope it helps :)
For me:
adb shell am start -W -a android.intent.action.VIEW -d "example://gizmos" com.example
didn't work.
Adding category solved it:
adb shell am start -a android.intent.action.VIEW -c android.intent.category.BROWSABLE -d "http://www.example.com/gizmos"
This is my code. I have read other's post about this issue. They said their code worked very well.
And my code almost the same as theirs. Why doesn't it work in my test. my device is Samsung I9300.
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.haibin.androidtest.MainActivity"
android:label="#string/app_name"
android:exported="true" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<data android:scheme="haibintest"/>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity>
</application>
ps: I using "adb -d shell am start -d haibintest:// -a android.intent.action.VIEW" on command line and it launch susccessfully, while use the url in the brower does't work.
ps2: I test it in opera and it work very well , so i know it will not work in some browers and devices.
To use url scheme inside adb you can use the following command line:
adb shell 'am start "intent:#Intent;scheme=yourscheme://yoururl?param1=value1;end"'
Or you can even do it with QrCodes:
Go to ZXing and generate a url of this format:
yourscheme://yoururl?param1=value1
Then scan it with a QrCode app like BarcodeScanner