从链接中打开我的应用程序 [英] Open my app from a link

查看:275
本文介绍了从链接中打开我的应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序服务器发送此链接:应用程序的名字:// veryfy email=test@mail.com&令牌= ASDF-ASDF-ASDF-xcfghfgh ,但有可能得到像电子邮件= test@mail.com 值和标记= sdfdkgdkgjgfd

In my app the server send this link: appname://veryfy?email=test@mail.com&token=asdf-asdf-asdf-xcfghfgh but is it possible to get the values like email= test@mail.com and the token = sdfdkgdkgjgfd.

到目前为止,我只加了这个意图过滤器里面我的清单,但应用不叫:

So far I've only added this intent filter inside my manifest but the app is not called:

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

                <data android:mimeType="text/plain" android:scheme="appname://"/>
            </intent-filter>

请注意这应该打开我的应用程序被点击浏览器中的链接时

Note this should open my app when the link is clicked in the browser

推荐答案

您可以得到电子邮件和通过获取活动的意图,这样的令牌:

You can get the email and token by getting the Activity's intent like this:

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

                    <data android:mimeType="text/plain" android:scheme="https" 
                     android:host="api.myapp.com"
                     android:pathPrefix="/api/v2/verify"/>
       </intent-filter>

Intent intent = getIntent();
Uri data = intent.getData();
String email = data.getQueryParameter("email");
String token = data.getQueryParameter("token");

这篇关于从链接中打开我的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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