本文整理汇总了Java中android.support.v7.widget.ShareActionProvider.setShareIntent方法的典型用法代码示例。如果您正苦于以下问题:Java ShareActionProvider.setShareIntent方法的具体用法?Java ShareActionProvider.setShareIntent怎么用?Java ShareActionProvider.setShareIntent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v7.widget.ShareActionProvider
的用法示例。
在下文中一共展示了ShareActionProvider.setShareIntent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreateOptionsMenu
import android.support.v7.widget.ShareActionProvider; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.share, menu);
MenuItem item = menu.findItem(R.id.action_share);
ShareActionProvider shareAction = (ShareActionProvider) MenuItemCompat.getActionProvider(item);
Intent send = new Intent();
send.setAction(Intent.ACTION_SEND);
send.putExtra(Intent.EXTRA_TEXT, text.toString());
send.setType("text/plain");
if(shareAction != null) {
shareAction.setShareIntent(send);
}
return super.onCreateOptionsMenu(menu);
}
示例2: onCreateOptionsMenu
import android.support.v7.widget.ShareActionProvider; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.poem_toolbar, menu);
favoriteItem = menu.findItem(R.id.action_addToFavorites);
if (presenter.isFavorite()){
favoriteItem.setIcon(R.drawable.ic_star_full);
}
MenuItem item = menu.findItem(R.id.action_share);
ShareActionProvider mShareActionProvider =
(ShareActionProvider) MenuItemCompat.getActionProvider(item);
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("text/plain");
shareIntent.putExtra(Intent.EXTRA_TEXT, presenter.getPoemContentString());
mShareActionProvider.setShareIntent(shareIntent);
return true;
}
示例3: onCreateOptionsMenu
import android.support.v7.widget.ShareActionProvider; //导入方法依赖的package包/类
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
if (getActivity() instanceof MainActivity) {
((MainActivity) getActivity()).setIntentShareMenu(createShareBookIntent(mBookSelected));
} else {
inflater.inflate(R.menu.menu_detail, menu);
MenuItem menushareItem = menu.findItem(R.id.action_share);
ShareActionProvider mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(menushareItem);
if (mBookSelected != null) {
menushareItem.setVisible(true);
mShareActionProvider.setShareIntent(createShareBookIntent(mBookSelected));
}
}
}
示例4: onCreateOptionsMenu
import android.support.v7.widget.ShareActionProvider; //导入方法依赖的package包/类
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
// Inflate the menu; this adds items to the action bar if it is present.
inflater.inflate(R.menu.detailfragment, menu);
// Retrieve the share menu item
MenuItem menuItem = menu.findItem(R.id.action_share);
// Get the provider and hold onto it to set/change the share intent.
mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(menuItem);
// If onLoadFinished happens before this, we can go ahead and set the share intent now.
if (mForecast != null) {
mShareActionProvider.setShareIntent(createShareForecastIntent());
}
}
示例5: onCreateOptionsMenu
import android.support.v7.widget.ShareActionProvider; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.news_activity_menu, menu);
MenuItem item = menu.findItem(R.id.action_share);
ShareActionProvider shareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(item);
shareActionProvider.setShareIntent(getDefaultShareIntent());
shareActionProvider.setOnShareTargetSelectedListener(new ShareActionProvider.OnShareTargetSelectedListener() {
@Override
public boolean onShareTargetSelected(ShareActionProvider source, Intent intent) {
String shareTarget = intent.getComponent().getPackageName();
TrackerUtils.shareNewsArticle(mNewsVo.title,shareTarget);
return false;
}
});
return super.onCreateOptionsMenu(menu);
}
示例6: onCreateOptionsMenu
import android.support.v7.widget.ShareActionProvider; //导入方法依赖的package包/类
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
// Inflate the menu; this adds items to the action bar if it is present.
inflater.inflate(R.menu.menu_detail_fragment, menu);
// Retrieve the share menu item
MenuItem menuItem = menu.findItem(R.id.action_share);
// Get the provider and hold onto it to set/change the share intent.
mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(menuItem);
// If onLoadFinished happens before this, we can go ahead and set the share intent now.
if (mForecast != null) {
mShareActionProvider.setShareIntent(createShareForecastIntent());
}
}
示例7: onCreateOptionsMenu
import android.support.v7.widget.ShareActionProvider; //导入方法依赖的package包/类
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
// Inflate the menu; this adds items to the action bar if it is present.
inflater.inflate(R.menu.menu_detail_fragment, menu);
// Retrieve the share menu item
MenuItem menuItem = menu.findItem(R.id.action_share);
// Get the provider and hold onto it to set/change the share intent.
ShareActionProvider mShareActionProvider =
(ShareActionProvider) MenuItemCompat.getActionProvider(menuItem);
// Attach an intent to this ShareActionProvider. You can update this at any time,
// like when the user selects a new piece of data they might like to share.
if (mShareActionProvider != null ) {
mShareActionProvider.setShareIntent(createShareForecastIntent());
} else {
Log.d(LOG_TAG, "Share Action Provider is null?");
}
}
示例8: onPrepareOptionsMenu
import android.support.v7.widget.ShareActionProvider; //导入方法依赖的package包/类
@Override
public void onPrepareOptionsMenu(Menu menu) {
super.onPrepareOptionsMenu(menu);
final Context context = getContext();
if(context == null || mTitle == null) {
return;
}
final MenuItem shareItem = menu.findItem(R.id.menu_share);
if(shareItem != null) {
final Intent shareIntent = EntryUtils.getShareIntent(context, mTitle, mRating);
final ShareActionProvider actionProvider =
(ShareActionProvider)MenuItemCompat.getActionProvider(shareItem);
if(actionProvider != null) {
actionProvider.setShareIntent(shareIntent);
}
}
}
示例9: onCreateOptionsMenu
import android.support.v7.widget.ShareActionProvider; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
MenuItem shareItem = menu.findItem(R.id.shareQuiz);
mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(shareItem);
mShareActionProvider.setShareIntent(getDefaultIntent());
mShareActionProvider.setOnShareTargetSelectedListener(new ShareActionProvider.OnShareTargetSelectedListener() {
@Override
public boolean onShareTargetSelected(ShareActionProvider source, Intent intent) {
// startActivity(intent);
return false;
}
});
return true;
}
示例10: onCreateOptionsMenu
import android.support.v7.widget.ShareActionProvider; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_contact, menu);
// Retrieve the share menu item
MenuItem shareItem = menu.findItem(R.id.action_share);
// get the ShareActionProvider
mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(shareItem);
// create a default intent for the share action
if (mShareActionProvider != null) {
mShareActionProvider.setShareIntent(createShareIntent(""));
} else {
Log.d(LOG_TAG, "Problem finding ShareActionProvider");
//shareActionProvider = new ShareActionProvider(getActivity());
//MenuItemCompat.setActionProvider(shareItem, shareActionProvider);
}
return true;
}
示例11: onCreateOptionsMenu
import android.support.v7.widget.ShareActionProvider; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
mShareButton = menu.findItem(R.id.action_share);
mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(mShareButton);
// This is also updated in onPageSelected.
if (mShareActionProvider != null && mShareEntryIntent != null) {
// Enable "Share" button.
mShareActionProvider.setShareIntent(mShareEntryIntent);
mShareButton.setVisible(true);
}
// TTS:
// The button is disabled in the layout. It should only be enabled in EntryActivity.
mSpeakButton = menu.findItem(R.id.action_speak);
// if (ttsInitialized) {
// // Log.d(TAG, "enabling TTS button in onCreateOptionsMenu");
mSpeakButton.setVisible(true);
// }
return true;
}
示例12: setupShareActionMenu
import android.support.v7.widget.ShareActionProvider; //导入方法依赖的package包/类
private void setupShareActionMenu(Menu menu) {
final MenuItem itemShare = menu.findItem(R.id.action_share);
final Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("text/plain");
shareIntent.putExtra(Intent.EXTRA_TEXT,
String.format("%s\n%s", mTopic.getTitle(), mTopic.getUrl()));
if (MiscUtils.HAS_L) {
itemShare.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
TopicFragment.this.startActivity(Intent.createChooser(shareIntent, null));
return true;
}
});
} else {
final ShareActionProvider actionProvider = new ShareActionProvider(getContext());
MenuItemCompat.setActionProvider(itemShare, actionProvider);
actionProvider.setShareIntent(shareIntent);
}
}
示例13: onCreateOptionsMenu
import android.support.v7.widget.ShareActionProvider; //导入方法依赖的package包/类
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
if (D) { Log.v(TAG, "onCreateOptionsMenu: menu: " + menu + " inflater: " + inflater); }
// Inflate the menu; this adds items to the action bar if it is present.
inflater.inflate(R.menu.detail_fragment, menu);
// Locate MenuItem with ShareActionProvider
MenuItem item = menu.findItem(R.id.action_share);
// Fetch and store ShareActionProvider
ShareActionProvider mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(item);
if (mForecastStr != null) {
mShareActionProvider.setShareIntent(createShareForecastIntent());
} else {
if (D) { Log.d(TAG, "Share Action Provider is null?"); }
}
}
示例14: onCreateOptionsMenu
import android.support.v7.widget.ShareActionProvider; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.detail, menu);
// Locate MenuItem with ShareActionProvider
MenuItem item = menu.findItem(R.id.menu_item_share);
// Fetch and store ShareActionProvider
mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(item);
if (mShareActionProvider != null) {
mShareActionProvider.setShareIntent(getDefaultShareIntent());
}
else {
Log.d(LOG_TAG, "ShareActionProvider is null");
}
return true;
}
示例15: onPrepareOptionsMenu
import android.support.v7.widget.ShareActionProvider; //导入方法依赖的package包/类
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
menu.removeGroup(R.id.browser);
getMenuInflater().inflate(R.menu.menu_browser, menu);
String shareContent = String.format("%s %s ", getTitle() + "", url + "");
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("text/plain");
shareIntent.putExtra(Intent.EXTRA_TEXT, shareContent);
MenuItem shareItem = menu.findItem(R.id.share);
ShareActionProvider shareProvider =
(ShareActionProvider) MenuItemCompat.getActionProvider(shareItem);
shareProvider.setShareHistoryFileName("channe_share.xml");
shareProvider.setShareIntent(shareIntent);
return super.onPrepareOptionsMenu(menu);
}