當前位置: 首頁>>代碼示例>>Java>>正文


Java ShareActionProvider類代碼示例

本文整理匯總了Java中android.support.v7.widget.ShareActionProvider的典型用法代碼示例。如果您正苦於以下問題:Java ShareActionProvider類的具體用法?Java ShareActionProvider怎麽用?Java ShareActionProvider使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ShareActionProvider類屬於android.support.v7.widget包,在下文中一共展示了ShareActionProvider類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onOptionsItemSelected

import android.support.v7.widget.ShareActionProvider; //導入依賴的package包/類
@Override
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();


    // Fetch and store ShareActionProvider
    mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(item);

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_settings) {
        startActivity(new Intent(App.getAppContext(),Settings.class));
        return true;
    }else  if (id == R.id.action_favorite) {
       favourite(post);
    }else  if (id == R.id.action_share) {
        shareTextUrl();
    }
    return super.onOptionsItemSelected(item);
}
 
開發者ID:jamesddube,項目名稱:LaravelNewsApp,代碼行數:23,代碼來源:PostActivity.java

示例2: 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

示例3: onCreateOptionsMenu

import android.support.v7.widget.ShareActionProvider; //導入依賴的package包/類
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.ride_menu, menu);

    // store action provider
    shareMenuItem = menu.findItem(R.id.menu_item_share);
    shareMenuItem.setVisible(false);
    shareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(shareMenuItem);

    // Create share intent
    shareFileIntent = new Intent();
    shareFileIntent.setAction(Intent.ACTION_SEND);
    shareFileIntent.setType("text/csv");
    shareFileIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
    setShareIntent(shareFileIntent);

    return true;
}
 
開發者ID:ponewheel,項目名稱:android-ponewheel,代碼行數:19,代碼來源:RideDetailActivity.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.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

示例5: 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

示例6: 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

示例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.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

示例8: 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

示例9: 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

示例10: 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

示例11: onCreateOptionsMenu

import android.support.v7.widget.ShareActionProvider; //導入依賴的package包/類
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    MaterialMenuInflater.with(getActivity(), inflater)
            .setDefaultColor(0xFFFFFFFF)
            .inflate(R.menu.hadis, menu);

    mSwitch = menu.findItem(R.id.favswitch);
    mFav = menu.findItem(R.id.fav);
    setCurrentPage(mPager.getCurrentItem());

    MenuItem item = menu.findItem(R.id.menu_item_share);
    mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(item);

    item = menu.findItem(R.id.menu_search);
    SearchView searchView = (SearchView) item.getActionView();

    searchView.setOnQueryTextListener(this);
}
 
開發者ID:metinkale38,項目名稱:prayer-times-android,代碼行數:20,代碼來源:HadithFragment.java

示例12: 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

示例13: 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

示例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.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

示例15: onCreateOptionsMenu

import android.support.v7.widget.ShareActionProvider; //導入依賴的package包/類
@Override
public boolean onCreateOptionsMenu(Menu menu) {

    this.getMenuInflater().inflate(R.menu.toolbar_menu, menu);

    menu.findItem(R.id.packet_number_entry).setVisible(false);
    menu.findItem(R.id.clear_btn).setVisible(false);
    menu.findItem(R.id.scan_btn).setVisible(false);
    menu.findItem(R.id.state_bt_btn).setVisible(false);
    menu.findItem(R.id.reset_snoop_file).setVisible(false);
    menu.findItem(R.id.filter_btn).setVisible(false);
    menu.findItem(R.id.refresh).setVisible(false);

    MenuItem item = menu.findItem(R.id.share);

    if (item != null) {
        mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(item);
        setSharedIntent();
    }

    return super.onCreateOptionsMenu(menu);
}
 
開發者ID:bertrandmartel,項目名稱:hci-debugger,代碼行數:23,代碼來源:DescriptionActivity.java


注:本文中的android.support.v7.widget.ShareActionProvider類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。