我有这个意图
Button share = (Button)findViewById(R.id.share);
share.setOnClickListener(new Button.OnClickListener()
{
public void onClick(View v)
{
//createShareIntent( );
}
});
以及类中的这两个方法:
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
getMenuInflater().inflate(R.layout.menu, menu);
MenuItem item = menu.findItem(R.id.menu_item_share);
myShareActionProvider = (ShareActionProvider)item.getActionProvider();
myShareActionProvider.setShareHistoryFileName(
ShareActionProvider.DEFAULT_SHARE_HISTORY_FILE_NAME);
myShareActionProvider.setShareIntent(createShareIntent());
return true;
}
private Intent createShareIntent()
{
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("text/plain");
shareIntent.putExtra(Intent.EXTRA_TEXT,
"testing");
return shareIntent;
}
public void doShare(Intent shareIntent)
{
// When you want to share set the share intent.
myShareActionProvider.setShareIntent(shareIntent);
}
和这个 sdk 版本配置:
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="15"/>
但我的问题是我不知道如何称呼它。单击共享按钮后,如何实际显示菜单?
谢谢!