共有機能を持ったアプリを開発する必要があります。フェイスブック、ツイッター、メール、その他のサービスで共有する必要があります。
どうすればいいのでしょうか?ネット上にライブラリはありますか?iOSの開発にはShareKitがありますが、Androidには?
ありがとうございます。)
Paresh Mayani'の答えはほぼ正しいです。単純にBroadcast Intentを使って、コンテンツをどのような方法で共有するかをシステムや他のすべてのアプリに選択させます。
テキストを共有するには、以下のコードを使用します。
String message = "Text I want to share.";
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("text/plain");
share.putExtra(Intent.EXTRA_TEXT, message);
startActivity(Intent.createChooser(share, "Title of the dialog the system will open"));
共有ボタンを用意して、それをクリックすると、適切なメディアやウェブサイトのオプションが表示されて、共有できるようにしたいのだと思います。Androidでは、同じことをするために、createChooser
を作成する必要があります。
共有テキスト。
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, "This is the text that will be shared.");
startActivity(Intent.createChooser(sharingIntent,"Share using"));
バイナリオブジェクト(画像、動画など)の共有
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
Uri screenshotUri = Uri.parse(path);
sharingIntent.setType("image/png");
sharingIntent.putExtra(Intent.EXTRA_STREAM, screenshotUri);
startActivity(Intent.createChooser(sharingIntent, "Share image using"));
参考までに、上記のコードはSharing content in Android using ACTION_SEND Intentを参考にしています。
ACTION_SEND」では、GMailやYahooMailなど(携帯電話にインストールされているアプリケーションで、「ACTION_SEND」を実行できるもの)を使って送信するオプションのみが提供されます。FacebookやTwitterで共有したい場合は、それぞれにカスタムボタンを配置し、Facebook SDKやTwitter4Jなどの独自のSDKを使用する必要があります。