當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。