1

次のコードを使用して、Gmail、Facebook、Twitterなどを介してテキストを共有しています。

  Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, "The status update text");
startActivity(Intent.createChooser(intent, "Dialog title text"));

選択したインテントがであるかどうかを確認したいのですがFacebook、そうである場合は、通常どおり共有インテントを要求する以外のコーディングを行います。

出来ますか?

4

2 に答える 2

3

次のリンクを見つけました: http://clickclickclack.wordpress.com/2012/01/03/intercepting-androids-action_send-intents/

この種のタスクを実行する方法が説明されています。行レイアウトを作成するだけで完了です。私はそれを試してみましたが、うまくいきます!

編集:show関数 の記事に誤りがあります。次のようにする必要があります。

final ShareIntentListAdapter adapter = new ShareIntentListAdapter((Activity)context, R.layout.basiclistview, activities.toArray());

それについて言及してくれた@imram khanに感謝します。

誰かが私の xml 行レイアウトを使用したい場合:

  <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >


   <TextView android:id="@+id/text1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="10dp"
    android:textSize="20sp"
    android:gravity="center"
    android:layout_alignParentRight="true"
    android:layout_marginRight="50dp"
/>


    <ImageView android:id="@+id/logo2"
    android:layout_width="70dp"
    android:layout_height="70dp"
    android:padding="10dp"
    android:src="@drawable/number1"
    android:layout_gravity="center_vertical"
    android:layout_alignParentRight="true"/>

</RelativeLayout>
于 2012-11-30T20:40:15.893 に答える