android.view.MenuItem.getActionProvider()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(8.6k)|赞(0)|评价(0)|浏览(132)

本文整理了Java中android.view.MenuItem.getActionProvider()方法的一些代码示例,展示了MenuItem.getActionProvider()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MenuItem.getActionProvider()方法的具体详情如下:
包路径:android.view.MenuItem
类名称:MenuItem
方法名:getActionProvider

暂无

代码示例

代码示例来源:origin: stackoverflow.com

public boolean onCreateOptionsMenu(Menu menu) {
  getMenuInflater().inflate(R.menu.share, menu);
  MenuItem item = menu.findItem(R.id.share_item);
  actionProvider = (ShareActionProvider) item.getActionProvider();

  // Create the share Intent
  String shareText = URL_TO_SHARE;
  Intent shareIntent = ShareCompat.IntentBuilder.from(this)
    .setType("text/plain").setText(shareText).getIntent();
  actionProvider.setShareIntent(shareIntent);
  return true;
}

代码示例来源:origin: commonsguy/cw-omnibus

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
 inflater.inflate(R.menu.notes, menu);
 share=
  (ShareActionProvider)menu.findItem(R.id.share)
   .getActionProvider();
 share.setShareIntent(shareIntent);
 super.onCreateOptionsMenu(menu, inflater);
}

代码示例来源:origin: commonsguy/cw-omnibus

@Override
public boolean onCreateOptionsMenu(Menu menu) {
 getMenuInflater().inflate(R.menu.actions, menu);
 share=
   (ShareActionProvider)menu.findItem(R.id.share)
                .getActionProvider();
 share.setOnShareTargetSelectedListener(this);
 return(super.onCreateOptionsMenu(menu));
}

代码示例来源:origin: stackoverflow.com

public boolean onCreateOptionsMenu(Menu menu) {
  // Inflate the menu; this adds items to the action bar if it is present.
  getMenuInflater().inflate(R.menu.mainpage, menu);
  MenuItem item = menu.findItem(R.id.menu_item_share);
  mShareActionProvider = (ShareActionProvider) item.getActionProvider();
  // Create the share Intent
  String playStoreLink = "https://play.google.com/store/apps/details?id=" +
    getPackageName();
  String yourShareText = "Install this app " + playStoreLink;
  Intent shareIntent = ShareCompat.IntentBuilder.from(this)
    .setType("text/plain").setText(yourShareText).getIntent();
  // Set the share Intent
  mShareActionProvider.setShareIntent(shareIntent);
  return true;
}

代码示例来源:origin: stackoverflow.com

@Override
public boolean onCreateOptionsMenu(Menu menu) {
  getMenuInflater().inflate(R.menu.mainpage, menu);
  MenuItem item = menu.findItem(R.id.menu_item_share);

  mShareActionProvider = (ShareActionProvider) item.getActionProvider();
  mShareActionProvider.setShareHistoryFileName(null);

  return true;
}

代码示例来源:origin: grzegorznittner/chanu

public static ShareActionProvider initializeShareActionProvider(Menu menu) {
  MenuItem item = menu.findItem(R.id.action_share);
  ShareActionProvider shareActionProvider = null;
  if (item != null)
    shareActionProvider = (ShareActionProvider) item.getActionProvider();
  return shareActionProvider;
}

代码示例来源:origin: stackoverflow.com

public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. 
int id = item.getItemId(); 
detailtext= (TextView) findViewById(R.id.detail); 
if (id==R.id.menu_item_share) 
{ 
 doShare(); 
 provider=item.getActionProvider();       
}return super.onOptionsItemSelected(item);

代码示例来源:origin: stackoverflow.com

@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
MenuItem item =(MenuItem) menu.findItem(R.id.menu_settings);
shareAction = (android.support.v7.widget.ShareActionProvider) item.getActionProvider();
shareAction.setShareIntent(createShareIntent());
return true;
}

代码示例来源:origin: stackoverflow.com

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
  super.onPrepareOptionsMenu(menu);
  getMenuInflater().inflate(R.menu.share_menu, menu);
  MenuItem item = menu.findItem(R.id.menu_item_share);
  mShareActionProvider = (ShareActionProvider) item.getActionProvider();
  mShareActionProvider.setShareIntent(getDefaultShareIntent());

  return true;
}

代码示例来源:origin: stackoverflow.com

@Override
public boolean onCreateOptionsMenu(Menu menu) {

  MenuInflater inflater = getSupportMenuInflater();
  inflater.inflate(R.menu.menu_detalle_tapa, (Menu) menu);
  MenuItem item = menu.findItem(R.id.ab_comparte);
  mShareActionProvider = (ShareActionProvider) item.getActionProvider();

  this.menu = menu;
  return true;
}

代码示例来源:origin: stackoverflow.com

MenuItem actionItem = menu.findItem(R.id.menu_item_share_action_provider_action_bar);
ShareActionProvider actionProvider = (ShareActionProvider) actionItem.getActionProvider();
actionProvider.setShareHistoryFileName(ShareActionProvider.DEFAULT_SHARE_HISTORY_FILE_NAME);
actionProvider.setShareIntent(createShareIntent());

private Intent createShareIntent() {
  Intent shareIntent = new Intent(Intent.ACTION_SEND);
  shareIntent.setType("image/*");
  Uri uri = Uri.fromFile(getFileStreamPath("shared.png"));
  shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
  return shareIntent;
}

代码示例来源:origin: com.willowtreeapps/oak-demos

@Override
public ActionProvider getActionProvider() {
  android.view.ActionProvider nativeProvider = mNativeItem.getActionProvider();
  if (nativeProvider != null && nativeProvider instanceof ActionProviderWrapper) {
    return ((ActionProviderWrapper)nativeProvider).unwrap();
  }
  return null;
}

代码示例来源:origin: com.actionbarsherlock/actionbarsherlock

@Override
public ActionProvider getActionProvider() {
  android.view.ActionProvider nativeProvider = mNativeItem.getActionProvider();
  if (nativeProvider != null && nativeProvider instanceof ActionProviderWrapper) {
    return ((ActionProviderWrapper)nativeProvider).unwrap();
  }
  return null;
}

代码示例来源:origin: grzegorznittner/chanu

protected void setupShareActionProviderOPMenu(final Menu menu) {
  updateSharedIntentOP(shareActionProviderOP);
  if (menu == null)
    return;
  MenuItem shareItem = menu.findItem(R.id.thread_share_menu);
  shareActionProviderOP = shareItem == null ? null : (ShareActionProvider) shareItem.getActionProvider();
  if (DEBUG) Log.i(TAG, "setupShareActionProviderOP() shareActionProviderOP=" + shareActionProviderOP);
}

代码示例来源:origin: stackoverflow.com

@Override
 public boolean onCreateActionMode(ActionMode mode, Menu menu) {
   mode.getMenuInflater().inflate(R.menu.cab, menu);
   final MenuItem item = menu.findItem(R.id.your_share_action_provider_id);
   mshare = (ShareActionProvider) item.getActionProvider();
   mshare.setShareIntent(Share());
   return true;
 }

代码示例来源:origin: andforce/iBeebo

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
  inflater.inflate(R.menu.actionbar_menu_browserweibocommentactivity, menu);
  MenuItem item = menu.findItem(R.id.menu_share);
  mShareActionProvider = (ShareActionProvider) item.getActionProvider();
  buildShareActionMenu();
  super.onCreateOptionsMenu(menu, inflater);
}

代码示例来源:origin: stackoverflow.com

@Override
  public boolean onCreateOptionsMenu(Menu menu) {
  // Inflate your menu.
  getSupportMenuInflater().inflate(R.menu.share_action_provider, menu);

  // Set file with share history to the provider and set the share intent.
  MenuItem item = menu.findItem(R.id.menu_item_share_action_provider_action_bar);
  ShareActionProvider provider = (ShareActionProvider) item.getActionProvider();
         provider.setShareHistoryFileName(ShareActionProvider.DEFAULT_SHARE_HISTORY_FILE_NAME);
  // Note that you can set/change the intent any time,
  // say when the user has selected an image.
  provider.setShareIntent(createShareIntent());

  return true
}

代码示例来源:origin: dogriffiths/HeadFirstAndroid

@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 menuItem = menu.findItem(R.id.action_share);
  shareActionProvider = (ShareActionProvider) menuItem.getActionProvider();
  setIntent("This is example text");
  return super.onCreateOptionsMenu(menu);
}

代码示例来源:origin: li2/learning-android-open-source

@Override
public boolean onCreateOptionsMenu(Menu menu) {
  // Be sure to call the super class.
  super.onCreateOptionsMenu(menu);
  // Inflate the menu and configure the media router action provider.
  getMenuInflater().inflate(R.menu.presentation_with_media_router_menu, menu);
  MenuItem mediaRouteMenuItem = menu.findItem(R.id.menu_media_route);
  MediaRouteActionProvider mediaRouteActionProvider =
      (MediaRouteActionProvider)mediaRouteMenuItem.getActionProvider();
  mediaRouteActionProvider.setRouteTypes(MediaRouter.ROUTE_TYPE_LIVE_VIDEO);
  // Return true to show the menu.
  return true;
}

代码示例来源:origin: stackoverflow.com

getSupportMenuInflater().inflate(R.menu.share_action_provider, menu);
 // Set file with share history to the provider and set the share intent.
 MenuItem actionItem = menu.findItem(R.id.menu_item_share_action_provider_action_bar);
 ShareActionProvider actionProvider = (ShareActionProvider) actionItem.getActionProvider();
 ***actionProvider.setShareHistoryFileName(null);
 OnShareTargetSelectedListener listener = new OnShareTargetSelectedListener() {
   public boolean onShareTargetSelected(ShareActionProvider source, Intent intent) {
     startActivity(intent);
     return true;
   }
 };
 actionProvider.setOnShareTargetSelectedListener(listener);***

相关文章