首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >android filter url in "intent-filter“

android filter url in "intent-filter“
EN

Stack Overflow用户
提问于 2011-08-02 12:48:17
回答 3查看 5.8K关注 0票数 6

我正在开发一个下载图片的应用程序。我已经成功地触发我的应用程序时,用户点击下载图像link.How我是否过滤特定的网址?

下面是我的清单代码:

代码语言:javascript
复制
<activity android:theme="@style/Transparent" android:name=".DownloadImage"
        android:label="@string/app_name">
        <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:mimeType="image/*" android:host="*"
                android:scheme="http" />
        </intent-filter>
</activity>

我的应用程序将在用户单击浏览器中的任何链接时启动和下载图像,但不会在特定的url上触发,例如"http://www.ABC.com“或特定项目"http://www.ABC.com/image/background.jpg

EN

回答 3

Stack Overflow用户

发布于 2012-06-09 15:43:46

当您的应用程序调用下载图像时,您应该浏览link:

代码语言:javascript
复制
    Intent intent = getIntent();
    String link = intent.getDataString();
票数 7
EN

Stack Overflow用户

发布于 2012-11-30 11:34:23

在这里查看数据标记的其他有用属性(pathPattern、pathPrefix):http://developer.android.com/guide/topics/manifest/data-element.html

票数 2
EN

Stack Overflow用户

发布于 2013-03-01 02:54:47

通过从意图过滤器获取url简单示例:

代码语言:javascript
复制
public class openUrl extends Activity{

    String link;
    TextView text;

    public void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        setContentView(R.layout.xmlname);

        Intent intent = getIntent();
            link = intent.getDataString();

            text = (TextView)findViewById(R.id.textViewId);
            text.setText(link.toString());
    }
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6907373

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档