【问题标题】:java.lang.IllegalArgumentException when android intentjava.lang.IllegalArgumentException 当android意图
【发布时间】:2021-12-13 15:45:54
【问题描述】:

我正在尝试使用自定义 url 方案打开应用程序。

我在部署前通过 adb 进行测试时遇到了以下错误。

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)

我尝试使用以下命令打开它。

adb shell am start -W -a android.intent.action.VIEW - "onionmarkethost://onionmarket.open" kr.gowoonwoori.oniontime

此代码是我创建自定义架构的清单代码。

<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>

怎么了?我真的不知道。请帮帮我。

【问题讨论】:

  • “怎么了?” -- 你似乎在android.intent.action.VIEW 之后有一个普通的-。为什么会在那里?它应该是一个完整的选项,在- 之后有一个字母吗?

标签: android android-intent deep-linking


【解决方案1】:

您需要在AndroidManifest.xml 文件中设置android:exported="true"


<activity android:name=".schema.SchemaActivity"
                 android:exported="true">
            <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>

【讨论】:

  • 谢谢!我解决它。抱歉我迟到的评论...
  • 这是我的荣幸
猜你喜欢
  • 1970-01-01
  • 2023-03-21
  • 2018-07-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-01-11
相关资源
最近更新 更多