意图过滤器来启动我的活动自定义的URI被点击时 [英] Intent Filter to Launch My Activity when custom URI is clicked

查看:196
本文介绍了意图过滤器来启动我的活动自定义的URI被点击时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让一个URI来登记与我的应用程序打开。像 PatternRepository 的黑莓和 CFBundleURLName / CFBundleURLSchemes 在iPhone上。我如何实现对Android相同的结果?

该系统将发送电子邮件与下面的链接:的myapp://myapp.mycompany.com/index/customerId/12345 。我们的想法是,用户应该能够点击链接到应用程序中打开客户活动。

我已经试过无数的建议,从其他等职位,但我不能让操作系统识别模式,并打开我的应用程序。

在Gmail应用中它看起来像这样:MyApp的:// <一href="http://myapp.mycompany.com/index/customerId/12345">myapp.mycompany.com/index/customerId/12345.它承认并强调链接 myapp.mycompany.com/index/customerId/12345 部分,并打开它在浏览器中。该的myapp:// 部分不是的 linkified 的。

标准的邮件应用程序将其视为纯文本的整个环节。

我是什么在这里失踪?

PS:我已经看了 <一href="http://stackoverflow.com/questions/2448213/how-to-implement-my-very-own-uri-schema-on-android">How实现我自己在Android URI模式 和<一href="http://stackoverflow.com/questions/2430045/how-to-register-some-url-namespace-myapp-app-start-for-accessing-your-progra/2430468#2430468">How注册某些URL命名空间(的myapp://app.start/)吗?通过调用浏览器在Android操作系统的URL访问你的程序

的清单:     

 &LT;舱单
    的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    安卓版code =2
    机器人:VERSIONNAME =0.0.8
    包=com.mycompany.myapp.client.android&GT;

    &LT;用途-SDK
        安卓的minSdkVersion =7
        机器人:targetSdkVersion =7/&GT;

    &LT;使用-权限的Andr​​oid:名称=android.permission.INTERNET对/&GT;
    &LT;使用-权限的Andr​​oid:名称=android.permission.WRITE_EXTERNAL_STORAG​​E/&GT;
    &LT;使用-权限的Andr​​oid:名称=android.permission.READ_PHONE_STATE/&GT;

    &lt;应用
        机器人:标签=@字符串/ APP_NAME
        机器人:名称=myappApplication
        机器人:图标=@可绘制/ ic_icon_myapp
        机器人:可调试=真正的&GT;

        &LT;活动
            机器人:标签=我的应用
            机器人:名称=。gui.activity.LoginActivity
            标签=@字符串/ APP_NAME&GT;

            &LT;意向滤光器&gt;
                &lt;作用机器人:名称=android.intent.action.MAIN/&GT;
                &LT;类机器人:名称=android.intent.category.LAUNCHER/&GT;
            &所述; /意图滤光器&gt;

        &LT; /活性GT;

        &LT;活动机器人:名称=。gui.activity.CustomerDetailActivity&GT;
            &LT;意向滤光器&gt;
                 &lt;作用机器人:名称=android.intent.action.VIEW/&GT;
                 &LT;类机器人:名称=android.intent.category.DEFAULT/&GT;
                 &LT;类机器人:名称=android.intent.category.BROWSABLE/&GT;
                 &lt;数据机器人:计划=MyApp的/&GT;
            &所述; /意图滤光器&gt;
        &LT; /活性GT;

        &LT;活动机器人:gui.activity.CustomerDetailActivityNAME = /&GT;
        &LT;活动机器人:gui.activity.CustomerImageViewerActivityNAME = /&GT;
        &LT;活动机器人:gui.activity.CustomerListActivity名称=机器人:configChanges =方向| keyboardHidden/&GT;
        &LT;活动机器人:gui.activity.HomeActivity名称=机器人:configChanges =方向| keyboardHidden/&GT;
        &LT;活动机器人:gui.activity.AboutActivity名称=机器人:configChanges =方向| keyboardHidden/&GT;
        &LT;活动机器人:gui.activity.AccountActivity名称=机器人:configChanges =方向| keyboardHidden/&GT;
    &LT; /用途&gt;
&LT; /舱单&GT;
 

解决方案

最后的解决方案是一个哈克解决方法,以涵盖所​​有基地。电子邮件现在还包含附件与被注册到与该应用打开的延伸。

该清单:

 &LT;活动机器人:名称=。gui.activity.CustomerDetailActivity&GT;
        &LT;意向滤光器&gt;
             &lt;作用机器人:名称=android.intent.action.VIEW/&GT;
             &LT;类机器人:名称=android.intent.category.DEFAULT/&GT;
             &LT;类机器人:名称=android.intent.category.BROWSABLE/&GT;
             &lt;数据机器人:计划=htt​​ps开头
                 机器人:主机=myapp.mycompany.com/&GT;
        &所述; /意图滤光器&gt;
        &LT;意向滤光器&gt;
             &lt;作用机器人:名称=android.intent.action.VIEW/&GT;
             &LT;类机器人:名称=android.intent.category.DEFAULT/&GT;
             &LT;类机器人:名称=android.intent.category.BROWSABLE/&GT;
             &lt;数据机器人:计划=的myapp
                 机器人:主机=myapp.mycompany.com/&GT;
        &所述; /意图滤光器&gt;
        &LT;意向滤光器&gt;
            &lt;作用机器人:名称=android.intent.action.VIEW/&GT;
            &lt;作用机器人:名称=android.intent.action.EDIT/&GT;
            &lt;作用机器人:名称=android.intent.action.PICK/&GT;
            &LT;类机器人:名称=android.intent.category.DEFAULT/&GT;
            &LT;类机器人:名称=android.intent.category.BROWSABLE/&GT;
            &lt;数据机器人:MIMETYPE =应用程序/ MyApp的/&GT;
        &所述; /意图滤光器&gt;
    &LT; /活性GT;
 

I am trying to allow a URI to be registered to open up with my app. Like the PatternRepository on the Blackberry and the CFBundleURLName/CFBundleURLSchemes on the iPhone. How do I achieve the same results on the Android?

The system will be sending emails with the following link: myapp://myapp.mycompany.com/index/customerId/12345. The idea is that the user should be able to click on the link to open up the customer activity in the application.

I've tried numerous suggestions from other SO posts but I cannot get the OS to recognize the pattern and open my app.

On The Gmail app it looks like this: myapp://myapp.mycompany.com/index/customerId/12345. It recognizes and underlines the myapp.mycompany.com/index/customerId/12345 portion of the link and it opens it in a browser. The myapp:// part is not linkified.

The standard mail application treats the entire link as plain text.

What am I missing here?

PS: I've already looked at How to implement my very own URI schema on Android and How to register some URL namespace (myapp://app.start/) for accessing your program by calling a URL in browser in Android OS?

The Manifest:

<manifest
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:versionCode="2"
    android:versionName="0.0.8" 
    package="com.mycompany.myapp.client.android">

    <uses-sdk 
        android:minSdkVersion="7" 
        android:targetSdkVersion="7"/>

    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.READ_PHONE_STATE"/>

    <application 
        android:label="@string/app_name" 
        android:name="myappApplication" 
        android:icon="@drawable/ic_icon_myapp" 
        android:debuggable="true">

        <activity 
            android:label="My App" 
            android:name=".gui.activity.LoginActivity" 
            label="@string/app_name">

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>

        </activity>

        <activity android:name=".gui.activity.CustomerDetailActivity" > 
            <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="myapp"/> 
            </intent-filter> 
        </activity>

        <activity android:name=".gui.activity.CustomerDetailActivity"/>
        <activity android:name=".gui.activity.CustomerImageViewerActivity" />
        <activity android:name=".gui.activity.CustomerListActivity" android:configChanges="orientation|keyboardHidden"/>
        <activity android:name=".gui.activity.HomeActivity" android:configChanges="orientation|keyboardHidden"/>
        <activity android:name=".gui.activity.AboutActivity" android:configChanges="orientation|keyboardHidden"/>
        <activity android:name=".gui.activity.AccountActivity" android:configChanges="orientation|keyboardHidden" />  
    </application>
</manifest>

解决方案

The final solution was a hacky workaround to cover all bases. The email now also contains an attachment with an extension that is registered to open with the app.

The Manifest:

        <activity android:name=".gui.activity.CustomerDetailActivity" > 
        <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="https"
                 android:host="myapp.mycompany.com" /> 
        </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="myapp"
                 android:host="myapp.mycompany.com" /> 
        </intent-filter> 
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <action android:name="android.intent.action.EDIT" />
            <action android:name="android.intent.action.PICK" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data android:mimeType="application/myapp" />
        </intent-filter>
    </activity>

这篇关于意图过滤器来启动我的活动自定义的URI被点击时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆