当前位置: 首页>>代码示例>>Java>>正文


Java ShareActionProvider.setOnShareTargetSelectedListener方法代码示例

本文整理汇总了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;
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:23,代码来源:FileExplorerAction.java

示例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);
}
 
开发者ID:ufrgs,项目名称:ufrgs-mobile-android,代码行数:23,代码来源:NewsOpenActivity.java

示例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;
}
 
开发者ID:jecelyin,项目名称:920-text-editor-v2,代码行数:26,代码来源:FileExplorerAction.java

示例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;
}
 
开发者ID:othreecodes,项目名称:quizmaster-android,代码行数:17,代码来源:MainActivity.java

示例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);
    }
}
 
开发者ID:yuugata,项目名称:TiqaViewer,代码行数:23,代码来源:PhotoViewFragment.java

示例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;
    });
}
 
开发者ID:Egorand,项目名称:android-aop-analytics,代码行数:13,代码来源:CatViewerActivity.java


注:本文中的android.support.v7.widget.ShareActionProvider.setOnShareTargetSelectedListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。