gpt4 book ai didi

android - 使用隐式 Intent 时 Activity 未出现在选择器对话框中

转载 作者:行者123 更新时间:2023-11-29 21:00:22 24 4
gpt4 key购买 nike

我想从另一个应用程序 IntentsLab 启动 MyBrowser,一个像内置浏览器应用程序一样显示网页的应用程序。

我关注了Launch custom android application from android browser设置 Intent ,还有the official Intent and Intent-filters guide确实说“您需要包含 CATEGORY_DEFAULT 才能接收隐式 Intent ”。

所以我的intent-filter是这么写的:

        <intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.categroy.DEFAULT" />
<data android:scheme="http" />
</intent-filter>

IntentsLab中父activity启动新activity的代码为:

    Intent baseIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com"));
String title = "Use Browser";
Intent chooserIntent = Intent.createChooser(baseIntent, title);
if(chooserIntent != null) startActivity(chooserIntent);

MyBrowser 应用程序未显示在选择器对话框中。但是,当我在 IntentsLab 中创建一个 Activity 并向其添加相同的 intent-filter 时,该 Activity 会显示在选择器对话框中。代码有什么问题吗?或者,同一应用程序中的 Activity 隐含 Intent 与不同应用程序中的 Activity 隐含 Intent 之间有什么区别吗?

最佳答案

为 MyBrowserActivity 提供了我的 AndroidManifest.xml。它非常适合我。即使我正在上 Android 编程课 :)

<activity android:name=".MyBrowserActivity" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="http" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<!-- TODO - Add necessary intent filter information so that this
Activity will accept Intents with the
action "android.intent.action.VIEW" and with an "http"
schemed URL -->
</activity>

关于android - 使用隐式 Intent 时 Activity 未出现在选择器对话框中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26314819/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com