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


Java ShareActionProvider.setShareIntent方法代码示例

本文整理汇总了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);
}
 
开发者ID:IMSmobile,项目名称:Fahrplan,代码行数:19,代码来源:ConnectionActivity.java

示例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;
}
 
开发者ID:PaulKlinger,项目名称:Sprog-App,代码行数:21,代码来源:PoemActivity.java

示例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));
        }
    }
}
 
开发者ID:victoraldir,项目名称:BuddyBook,代码行数:20,代码来源:DetailActivityFragment.java

示例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());
    }
}
 
开发者ID:googlecodelabs,项目名称:getting-ready-for-android-n,代码行数:17,代码来源:DetailFragment.java

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

示例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());
    }
}
 
开发者ID:katamaditya,项目名称:Weather4U,代码行数:17,代码来源:DetailFragment.java

示例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?");
    }
}
 
开发者ID:FreakPirate,项目名称:Sunshine-v2,代码行数:21,代码来源:DetailActivityFragment.java

示例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);
        }
    }
}
 
开发者ID:ultramega,项目名称:flavordex,代码行数:20,代码来源:ViewInfoFragment.java

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

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

示例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;
}
 
开发者ID:De7vID,项目名称:klingon-assistant,代码行数:24,代码来源:EntryActivity.java

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

示例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?"); }
    }
}
 
开发者ID:lockerfish,项目名称:mysunshine,代码行数:19,代码来源:DetailFragment.java

示例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;
}
 
开发者ID:TylerMcCraw,项目名称:android-weather,代码行数:19,代码来源:DetailActivity.java

示例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);
}
 
开发者ID:gzsll,项目名称:TLint,代码行数:19,代码来源:BrowserActivity.java


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