1

My Android app can share links via Twitter or Facebook.

If someone clicks on a link that was shared and they already have the app installed, how can I make the app launch directly?

Updated - Simple Issue Fixed from here - Make a link in the Android browser start up my app?

Community
  • 1
  • 1

2 Answers2

1

You need to add <Intent-filter> under <activity> tag in manifest.xml file like

 <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>

When another application tries to share any of these things by constructing an intent and passing it to startActivity(), your application will be listed as an option in the intent chooser.

If the user selects your application, the corresponding activity (.ui.MyActivity in the example above) will be started. It is then up to you to handle the content appropriately within your code and UI.

And go to this for better understanding: http://developer.android.com/training/sharing/receive.html

M D
  • 47,665
  • 9
  • 93
  • 114
0

Facebbok/twitter

facebook

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

twitter

 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";
Ashish
  • 101
  • 9