本文整理汇总了Java中android.support.v7.widget.ShareActionProvider.setOnShareTargetSelectedListener方法的典型用法代码示例。如果您正苦于以下问题:Java ShareActionProvider.setOnShareTargetSelectedListener方法的具体用法?Java ShareActionProvider.setOnShareTargetSelectedListener怎么用?Java ShareActionProvider.setOnShareTargetSelectedListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v7.widget.ShareActionProvider
的用法示例。
在下文中一共展示了ShareActionProvider.setOnShareTargetSelectedListener方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreateActionMode
import android.support.v7.widget.ShareActionProvider; //导入方法依赖的package包/类
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
menu.add(0, R.id.select_all, 0, R.string.select_all).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
menu.add(0, R.id.cut, 0, R.string.cut).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
menu.add(0, R.id.copy, 0, R.string.copy).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
MenuItem pasteMenu = menu.add(0, R.id.paste, 0, R.string.paste);
pasteMenu.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
pasteMenu.setEnabled(fileClipboard.canPaste());
renameMenu = menu.add(0, R.id.rename, 0, R.string.rename);
renameMenu.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
shareMenu = menu.add(0, R.id.share, 0, R.string.share);
shareMenu.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
shareActionProvider = new ShareActionProvider(context);
shareActionProvider.setOnShareTargetSelectedListener(this);
MenuItemCompat.setActionProvider(shareMenu, shareActionProvider);
menu.add(0, R.id.delete, 0, R.string.delete).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
return true;
}
示例2: 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);
}
示例3: onCreateActionMode
import android.support.v7.widget.ShareActionProvider; //导入方法依赖的package包/类
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
menu.add(0, R.id.select_all, 0, R.string.select_all).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
menu.add(0, R.id.cut, 0, R.string.cut).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
menu.add(0, R.id.copy, 0, R.string.copy).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
MenuItem pasteMenu = menu.add(0, R.id.paste, 0, R.string.paste);
pasteMenu.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
pasteMenu.setEnabled(fileClipboard.canPaste());
renameMenu = menu.add(0, R.id.rename, 0, R.string.rename);
renameMenu.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
shareMenu = menu.add(0, R.id.share, 0, R.string.share);
shareMenu.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
shareActionProvider = new ShareActionProvider(context);
shareActionProvider.setOnShareTargetSelectedListener(this);
MenuItemCompat.setActionProvider(shareMenu, shareActionProvider);
menu.add(0, R.id.delete, 0, R.string.delete).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
copyPathMenu = menu.add(0, R.id.copy_path, 0, R.string.copy_path);
copyPathMenu.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
return true;
}
示例4: 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;
}
示例5: onCreateOptionsMenu
import android.support.v7.widget.ShareActionProvider; //导入方法依赖的package包/类
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
MenuItem item = menu.findItem(R.id.action_share);
if (item != null) {
mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(item);
mShareActionProvider.setOnShareTargetSelectedListener(this);
// dummy File
File file = createFileObj(false);
if(file ==null) return;
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.setType("image/jpg");
Uri uri = Uri.fromFile(file);
shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
setShareIntent(shareIntent);
}
}
示例6: initShareActionProvider
import android.support.v7.widget.ShareActionProvider; //导入方法依赖的package包/类
private void initShareActionProvider(Menu menu) {
MenuItem shareMenuItem = menu.findItem(R.id.action_share);
ShareActionProvider actionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(shareMenuItem);
Intent shareIntent = new Intent(Intent.ACTION_VIEW);
shareIntent.setType(catImage.getType());
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(catImage.getLink()));
actionProvider.setShareIntent(shareIntent);
actionProvider.setOnShareTargetSelectedListener((source, intent) -> {
trackSharingAction(analyticsTrackerHelper, AnalyticsTags.CATEGORY_ACTION, AnalyticsTags.ACTION_SHARE);
return true;
});
}