본문 바로가기
옛날

공유 Intent [Android]

by 차가운게 조아 2015. 12. 14.
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("text/plain");
i.putExtra(Intent.EXTRA_SUBJECT, "Sharing URL");
i.putExtra(Intent.EXTRA_TEXT, "http://www.url.com");
startActivity(Intent.createChooser(i, "Share URL"));

If the app you want to share to is not installed on the user's device, for example - facebook, then you'll have to use Facebook SDK.

If you want your Activity to handle text data shared from other apps as well, you can add this to your AndroidManifest.xml:

<activity android:name=".ShareLink">
    <intent-filter>
        <action android:name="android.intent.action.SEND" />
        <category android:name="android.intent.category.DEFAULT" />
        <data android:mimeType="text/plain" />
    </intent-filter>
</activity>


'옛날' 카테고리의 다른 글

http post [Android]  (0) 2015.12.14
intent uri 모음 [Android]  (0) 2015.12.14
Webview source [Android]  (0) 2015.12.14
멀티 해상도 [Android]  (0) 2015.12.11
튜토리얼 페이지 [Android]  (0) 2015.12.11