从Facebook和Twitter应用程序重定向到移动应用程序

时间:2014-04-08 06:34:04

标签: android facebook twitter

我的Android应用可以通过Twitter或Facebook分享链接。

如果有人点击已共享的链接并且他们已经安装了应用,那么如何直接启动应用?

更新 - 简单的问题从这里修复 - Make a link in the Android browser start up my app?

2 个答案:

答案 0 :(得分:1)

您需要在<Intent-filter>文件中的<activity>标记下添加manifest.xml,例如

 <activity android:name=".ui.MyActivity" >
<intent-filter>
    <action android:name="android.intent.action.SEND" />
    <category android:name="android.intent.category.DEFAULT" />
    <data android:mimeType="image/*" />
</intent-filter>
<intent-filter>
    <action android:name="android.intent.action.SEND" />
    <category android:name="android.intent.category.DEFAULT" />
    <data android:mimeType="text/plain" />
</intent-filter>
<intent-filter>
    <action android:name="android.intent.action.SEND_MULTIPLE" />
    <category android:name="android.intent.category.DEFAULT" />
    <data android:mimeType="image/*" />
</intent-filter>
</activity>

当另一个应用程序尝试通过构建意图并将其传递给 startActivity()来共享任何这些内容时,您的应用程序将作为意图选择器中的选项列出。

如果用户选择了您的应用程序,则将启动相应的活动(上例中的.ui.MyActivity)。然后,您可以在代码和UI中正确处理内容。

为了更好地理解,请转到此处:http://developer.android.com/training/sharing/receive.html

答案 1 :(得分:0)

Facebbok /微博

<强>实

After facebbok login  OnComplete() is called. So, fire your intent in this method.
 public void onComplete(Bundle values) 
 {
    # fire desired intent      
  }

<强>微博

 put this code into your manifest file with activity name and on which activity 
  want to redirect put the below line so link is created and you will redirect
  <activity
        android:name="com.example.mainactivity"
        android:screenOrientation="portrait" >

          <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:host="home"
                android:scheme="oauth" />
        </intent-filter>

    </activity>

*********************************************************************
<h6>put this into your mainactivty</h6>
static final String TWITTER_CALLBACK_URL = "oauth://home";
static final String TWITTER_CALLBACK_URL = "oauth://home";