java.lang.IllegalArgumentException when android intent - android

I am trying to open an app using a custom url scheme.
I ran into the following error while testing through adb before deployment.
Exception occurred while executing 'start':
java.lang.IllegalArgumentException: Unknown option: -
at android.content.Intent.parseCommandArgs(Intent.java:8358)
at com.android.server.am.ActivityManagerShellCommand.makeIntent(ActivityManagerShellCommand.java:349)
at com.android.server.am.ActivityManagerShellCommand.runStartActivity(ActivityManagerShellCommand.java:451)
at com.android.server.am.ActivityManagerShellCommand.onCommand(ActivityManagerShellCommand.java:192)
at android.os.BasicShellCommandHandler.exec(BasicShellCommandHandler.java:98)
at android.os.ShellCommand.exec(ShellCommand.java:44)
at com.android.server.am.ActivityManagerService.onShellCommand(ActivityManagerService.java:13144)
at android.os.Binder.shellCommand(Binder.java:965)
at android.os.Binder.onTransact(Binder.java:839)
at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:6044)
at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:3642)
at android.os.Binder.execTransactInternal(Binder.java:1195)
at android.os.Binder.execTransact(Binder.java:1159)
I tried to open it with the following command.
adb shell am start -W -a android.intent.action.VIEW - "onionmarkethost://onionmarket.open" kr.gowoonwoori.oniontime
This code is the manifest code for me to create a custom schema.
<activity android:name=".schema.SchemaActivity">
<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="onionmarkethost"
android:scheme="onionmarket.open" />
</intent-filter>
</activity>
What's the matter? I really don't know. Please, Help me.

Just remove the hyphen '-' after 'android.intent.action.VIEW' and use a single space instead before your url scheme

Related

Unable to pass deep links with parameters - Android

I am trying to pass parameters to deep links in Android and that is not working.
I have specified a hostName variable in the app/build.gradle file to distinguish between UAT and production URLs. This hostName variable is referenced in AndroidManifest.xml like so:
<activity
android:name=".ui.MyActivity"
android:theme="#style/MyTheme"
android:configChanges="orientation"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!-- deep links for home page. -->
<data
android:scheme="https"
android:host="${hostName}"
android:pathPrefix="/login.jsp?signup=true" />
</intent-filter>
</activity>
I am trying to use adb to test for deep links like so:
adb.exe shell am start -W -a android.intent.action.VIEW -d "https://www.mywebsite.co.in/login.jsp?signup=true" com.myapp.ui.MyActivity
The error I get is:
Starting: Intent { act=android.intent.action.VIEW dat=https://www.mywebsite.co.in/... pkg=com.myapp.android.alpha }
Error: Activity not started, unable to resolve Intent { act=android.intent.action.VIEW dat=https://www.mywebsite.co.in/... flg=0x10000000 pkg=com.myapp.android.alpha }
I have read through a number of similar questions here on SO and all of them suggest escaping the special characters. But that has not worked in this case.
Any insights on resolving this will be most welcome.
The android:pathPrefix is invalid in your AndroidManifest.xml.
It should only contain the path element, not the query:
android:pathPrefix="/login.jsp"
The query string ?signup=true is not part of the path. You cannot filter on query strings.

Deep linking react native app on Android

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/

Android app link multiple intent filter hosts and manifest merge not working

I am working with build variants and want to capture additional links based on the variant. I want all variants to capture links from host one so I have declared an intent-filter in my main AndroidManifest.xml file like so:
<activity android:name=".activity.DeepLinkActivity"
android:noHistory="true">
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:host="hostOne.com" android:path="/page.aspx" android:scheme="http"/>
</intent-filter>
</activity>
I am also generating a partial manifest for other variants such as hostTwo.com like so:
<?xml version="1.0" encoding="UTF-8"?><manifest package="com.package.my.domain">
<application xmlns:android="http://schemas.android.com/apk/res/android" android:name="AlarmMobile">
<activity android:name=".activity.DeepLinkActivity">
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:scheme="http://" android:host="hostTwo.com" android:path="/page.aspx"/>
</intent-filter>
</activity>
</application>
</manifest>
It is placed in an appropriately named folder according to the build variant (based upon the documentation here) and Android studio's merged manifest view shows that the intent-filter for host two has been added to the final merged manifest, however, the emulator or actual device fails to capture intents meant for the second host.
I am generating intents like so in the command prompt:
adb shell am start -a android.intent.action.VIEW -c android.intent.category.BROWSABLE -d "http://hostone.com/page.aspx"
which works for hostone, but doing
adb shell am start -a android.intent.action.VIEW -c android.intent.category.BROWSABLE -d "http://hosttwo.com/page.aspx"
will launch the browser because the app fails to capture it.
Do android app links only work for one host name? Is there anything else which I can try?
I figured out that the partial manifest was incorrect. In the intent-filter's data tag, android:scheme="http://" is invalid due to the trailing ://.
According to google's documentation, Android builds the intent-filter URI like so: <scheme>://<host>:<port>/<path> so including it in the declaration is unnecessary.
After changing my declaration to android:scheme="http" the merge continues to be successful and the OS attempts to validate the links defined in the partial manifest!
Corrected partial manifest:
<?xml version="1.0" encoding="UTF-8"?><manifest package="com.package.my.domain">
<application xmlns:android="http://schemas.android.com/apk/res/android" android:name="AlarmMobile">
<activity android:name=".activity.DeepLinkActivity">
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:scheme="http" android:host="hostTwo.com" android:path="/page.aspx"/>
</intent-filter>
</activity>
</application>
</manifest>

Deep linking with Query Parameter

I have this link which I want to link a specific activity on clicking this url.
I am able to link "http://example.com" to my application, but when I tried using this query parameter in the path prefix, it returned nothing.
I use this intent-filter to link my url :
<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="example.com"
android:scheme="http"
android:pathPrefix="/"/>
</intent-filter>
Here I don't know what is the path prefix for my Url.
It does not solve your problem, but to test your URL try this ADB command:
adb shell 'am start -a android.intent.action.VIEW -c android.intent.category.BROWSABLE -d "http://example.com?path_resolution=xyz&city=abc"'

Android deep linking doesn't launch app

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"

Categories

Resources