API 15 (Galaxy Nexus) avdevice で次のコードを使用しています
menu_share.xml
<item
android:id="@+id/menu_share"
android:actionProviderClass="android.widget.ShareActionProvider"
android:showAsAction="ifRoom"
android:title="Share"/>
<item
android:id="@+id/item1"
android:orderInCategory="20"
android:showAsAction="always|collapseActionView"
android:title="Refresh">
</item>
主な活動はこんな感じ
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
// Get the ActionProvider
provider = (ShareActionProvider) menu.findItem(R.id.menu_share)
.getActionProvider();
// Initialize the share intent
intent = new Intent(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_TEXT, "This is my text to send.");
intent.setType("text/plain");
provider.setShareIntent(intent);
return true;
}
API 15(Galaxy Nexus)avdで実行すると、クリックできない次のアイコンのみが表示されます(ただし、少なくともメッセージアプリは表示されるはずです)。
API 17 タブレット avd で同じコードを実行すると、SharedActionProvider によって提供されるメッセージング アプリを開始できます。
タブレットでは、このようにメッセージ アプリをドロップダウン リストに表示する方法と、API15 AVD の共有アクション プロバイダーをクリック可能にする方法 (最初の画像) を教えてください。
ありがとう。