简体   繁体   English

使用隐式意图时,活动没有出现在选择器对话框中

[英]Activity not appearing on Chooser dialog when using Implicit Intent

I would like to start MyBrowser, an application that show web pages like the built-in Browser app, from another application, IntentsLab. 我想从另一个应用程序IntentsLab启动MyBrowser,该应用程序显示诸如内置浏览器应用程序之类的网页。

I followed Launch custom android application from android browser to setup the intent, and also the official Intent and Intent-filters guide which does says "You need to include CATEGORY_DEFAULT to receive implicit intents". 我遵循了从android浏览器启动自定义android应用程序以设置意图,以及官方的Intent和Intent-filters指南 ,该指南的内容是“您需要包含CATEGORY_DEFAULT才能接收隐式意图”。

So my intent-filter is so written: 所以我的意图过滤器是这样写的:

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

The code of the parent activity in IntentsLab to start the new activity is: IntentsLab中用于启动新活动的父活动的代码是:

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

The MyBrowser application does not show up on the chooser dialog. MyBrowser应用程序未显示在选择器对话框中。 However, when I created an Activity inside the IntentsLab and added to it a same intent-filter, this activity shows up in the chooser dialog. 但是,当我在IntentsLab中创建一个Activity并将其添加到同一intent-filter时,该活动将显示在选择器对话框中。 Is there anything wrong with the code? 代码有什么问题吗? Or is there any difference between implicit intent towards Activities in a same Application with those in a different one? 还是在同一应用程序中对活动的隐式意图与在不同应用程序中的隐式意图之间有什么区别?

Provided my AndroidManifest.xml for the MyBrowserActivity. 为MyBrowserActivity提供了我的AndroidManifest.xml。 It works perfectly for me. 它非常适合我。 Even I am doing the coursera Android programming class :) 甚至我正在上Coursera 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> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM