2016-03-24 13 views
2

インテントでACTION_SENDを使用してアプリケーションでテキストを共有しようとしています。しかし、デフォルトでアプリを使用することを選択した場合、毎回尋ねることなく同じアプリと共有されます。インテントACTION_SENDデフォルトの起動なし

誰かが私を助けることができますか?

このコードのようにメール、facebook、twitter、whatsappで共有できるはずです。ありがとう。

Intent textShareIntent = new Intent(Intent.ACTION_SEND); 
      textShareIntent.putExtra(Intent.EXTRA_TEXT, "Text to share, URL"); 
      textShareIntent.setType("text/plain"); 
      startActivity(textShareIntent); 
+0

を試してみてください? –

答えて

8

あなたがAndroidのデフォルトの選択ウィンドウを起動しますか、この

Intent textShareIntent = new Intent(Intent.ACTION_SEND); 
textShareIntent.putExtra(Intent.EXTRA_TEXT, "Text to share, URL"); 
textShareIntent.setType("text/plain"); 
if (textShareIntent.resolveActivity(getPackageManager()) != null) 
    startActivity(Intent.createChooser(textShareIntent, "Share")); 
else 
    // no app can handle this intent, do something else 
+0

素晴らしいです。 ありがとう – Xeijin

関連する問題