如何打开我的应用程序被点击应用程序链接时, [英] How to open my application when app link is clicked

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

问题描述

我要的是分享我的应用程序的特定页面的链接。假设我在我的应用程序的一些用户的个人资料页,我想该用户分享给我的一些朋友,所以我想通过什么应用和其他应用程序分享。

What i want is to share the link of specific page of my application. Suppose i am in a profile page of some user in my app and i want to share that user to some of my friends so i would like to share it via whats-app and other applications.

所以基本上我想分享一个链接到我的应用程序。

So basically i want to share a link to my app.

这就是我现在做正确

Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
    shareIntent.setType("text/plain");
    shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, "https://play.google.com/store/apps/details?id=" + activity.getPackageName());
    activity.startActivity(Intent.createChooser(shareIntent, "Share"));

我知道这是不是我真正想要的,但其部分完成。
如果用户没有安装我的应用程序则此code重定向他到Google Play商店页面下载这个应用程序。

i know this is not what i really want but its partially done. if user hasn't installed my app then this code redirect him to google play store page to download this app.

主要问题是,当用户已经这个应用程序这个环节只是打开的应用程序。我想用户重定向到指定页面,当他点击一个链接。

Main problem is when user have already this app this link just opens the app. I want to redirect user to that specific page when he clicks on a link.

我怎样才能做到这一点。

How can i do this.

我听说过一些关于意图过滤器,但不知道如何使用它们。

I heard something about intent filter but not sure how to use them.

<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="application/pdf" />

更新时间:

现在我试图分享这样我的应用程序的链接

Now i am trying to share my app link like this

Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
    shareIntent.setType("text/plain");
    shareIntent.putExtra("PostID", postID);
    shareIntent.putExtra("UserID", userID);
    shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, "https://play.google.com/store/apps/details?id=" + activity.getPackageName());
    activity.startActivity(Intent.createChooser(shareIntent, "Share"));

MT清单里我已经宣布这样一个活动。

inside mt manifest i have declared an activity like this

<activity
        android:name=".activities.ShareActivity"
        android:screenOrientation="sensorPortrait"
        android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen">

        <intent-filter>
            <action android:name="android.intent.action.SEND" />

            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />

            <data
                android:host="details"
                android:scheme="market" />
            <data
                android:host="play.google.com"
                android:pathPattern="/store/apps/details?id=my_package_name"
                android:scheme="http" />
            <data
                android:host="play.google.com"
                android:pathPattern="/store/apps/details?id=my_package_name"
                android:scheme="https" />
        </intent-filter>
    </activity>

但我仍然无法看到我的应用程序时,我使用我WhatsApp的或其他任何方式共享点击链接。

But i am still not able to see my app when i click on the link i shared using whatsapp or any other means.

请帮我

任何帮助将是非常美联社preciated。
先谢谢了。

Any help will be really appreciated. Thanks in advance.

推荐答案

以下意图过滤器添加到您的活动宣言,​​在项目的Andr​​oidManifest:

Add the following intent-filters to your activity declaration, in the AndroidManifest of your project :

    <intent-filter>

        <action android:name="android.intent.action.SEND"/>
        <category android:name="android.intent.category.DEFAULT"/>

        <data android:mimeType="text/plain"/>

    </intent-filter>

现在,在的onCreate() onResume() onNewIntent()您的活动周期的方法,你可以使用< STRONG>的getData()意向STRONG> 已经解雇了您的活动。

Now, in the onCreate(), onResume() or onNewIntent() method of your activity lifecycle, you can use the getData() of the intent that has fired your activity.

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

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