Java 类android.support.v4.app.ShareCompat 实例源码

项目:Farmacias    文件:MainActivity.java   
private void sendFeedbackSharingIntent(){
    Intent shareIntent= ShareCompat.IntentBuilder.from(this)
            .setType("text/plain")
            //.setType("application/txt") with this flag filters much better, but not as good as sendFeedBabck
            .addEmailTo(getString(R.string.mailto))
            .setSubject(getString(R.string.subject))
            .setText(Constants.EMPTY_STRING)
            .setChooserTitle(R.string.sendchooser_text)
            .createChooserIntent()
            .addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET)
            .addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

    if (shareIntent.resolveActivity(getPackageManager()) != null) {
        startActivity(shareIntent);
    }
}
项目:dankbank    文件:MemeActivity.java   
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case R.id.meme_share:
            ShareCompat.IntentBuilder
                    .from(this)
                    .setChooserTitle("Share your meme")
                    .setStream(Uri.fromFile(new File(meme.getUri().getPath())))
                    .setType(mimeType)
                    .startChooser();
            break;
        case android.R.id.home:
            onBackPressed();
            return true;
    }

    return super.onOptionsItemSelected(item);
}
项目:Small-Android-apps    文件:MainActivity.java   
private void shareText(String text) {
        String mimeType = "text/plain";
        String title = "learning how to share";
        String textToShare = text;

        ShareCompat.IntentBuilder.from(this)
                .setChooserTitle(title)
                .setType(mimeType)
                .setText(textToShare)
                .startChooser();

//        Intent intent = new Intent();
//        intent.setAction(Intent.ACTION_SEND);
//        intent.putExtra(Intent.EXTRA_TEXT, textToShare);
//        intent.setType(mimeType);
//        startActivity(Intent.createChooser(intent, title));
//        new ShareCompat.IntentBuilder()
    }
项目:CXJPadProject    文件:EmailSpan.java   
@Override
public void onClick(View widget) {
    if (SobotOption.hyperlinkListener != null){
        SobotOption.hyperlinkListener.onEmailClick(email);
        return;
    }
    try {
        ShareCompat.IntentBuilder builder = ShareCompat.IntentBuilder
                .from((Activity)widget.getContext());
        builder.setType("message/rfc822");
        builder.addEmailTo(email);
        builder.setSubject("");
        builder.setChooserTitle("");
        builder.startChooser();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
项目:robird-reborn    文件:HomeActivity.java   
private void handleShareIntent(final ShareCompat.IntentReader reader) {
    Analytics.event(Analytics.SHARE_VIA_ROBIRD);
    if (reader.getStreamCount() > 0) {
        final int count = reader.getStreamCount() > 4 ? 4 : reader.getStreamCount();
        ComposeFragment
                .share(new ArrayList<Uri>() {
                    {
                        for (int i = 0; i < count; ++i)
                            add(reader.getStream(i));
                    }
                })
                .show(getSupportFragmentManager(), ComposeFragment.TAG_SHARE);
    } else {
        final StringBuilder shareBuilder = new StringBuilder();

        if (!TextUtils.isEmpty(reader.getSubject()))
            shareBuilder.append(reader.getSubject()).append(" ");

        shareBuilder.append(reader.getText());

        ComposeFragment
                .share(shareBuilder.toString())
                .show(getSupportFragmentManager(), ComposeFragment.TAG_SHARE);
    }
}
项目:Camera-Roll-Android-App    文件:ItemActivity.java   
public void sharePhoto() {
    Uri uri = albumItem.getUri(this);

    Intent shareIntent = ShareCompat.IntentBuilder.from(this)
            .addStream(uri)
            .setType(MediaType.getMimeType(this, uri))
            .getIntent();

    shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
    String title = getString(R.string.share_item, albumItem.getType(this));
    if (shareIntent.resolveActivity(getPackageManager()) != null) {
        startActivity(Intent.createChooser(shareIntent, title));
    } else {
        String error = getString(R.string.share_error, albumItem.getType(this));
        Toast.makeText(this, error, Toast.LENGTH_SHORT).show();
    }
}
项目:android-instant-apps-demo    文件:CartActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_cart);
    viewModel = ViewModelProviders.of(this).get(CartViewModel.class);

    fab = (FloatingActionButton) findViewById(R.id.fab);
    toolbar = (Toolbar) findViewById(R.id.toolbar);

    setupToolbar();
    handleDeepLink();

    fab.setImageDrawable(VectorDrawableCompat.create(getResources(), R.drawable.ic_share_white_24dp, null));
    fab.setOnClickListener(view -> {
        String cartId = viewModel.getCartId().getValue();
        ShareCompat.IntentBuilder.from(this)
                .setText(String.format(Locale.US, "Check out my shopping cart now using Android Instant Apps! \n%s/cart/%s", ROOT_ENDPOINT, cartId))
                .setType("text/plain")
                .setChooserTitle(share_cart)
                .startChooser();
    });
}
项目:materialup    文件:ShareDribbbleImageTask.java   
@Override
    protected void onPostExecute(File result) {
        if (result == null) {
            return;
        }
        // glide cache uses an unfriendly & extension-less name,
        // massage it based on the original
//        result.renameTo(renamed);
        Uri uri = FileProvider.getUriForFile(activity,
                activity.getString(R.string.share_authority), result);
        ShareCompat.IntentBuilder.from(activity)
                .setText(getShareText())
                .setType(getImageMimeType(result.getName()))
                .setSubject(shot.title)
                .setStream(uri)
                .startChooser();
    }
项目:idec-mobile    文件:FileListFragment.java   
void performShare(final FileListFragment.MyAdapter.ViewHolder holder) {
    if (!holder.exists) {
        Toast.makeText(callingActivity, R.string.no_file_warning, Toast.LENGTH_SHORT).show();
        return;
    }

    Uri fileUri = FileProvider.getUriForFile(
            callingActivity.getApplicationContext(), "vit01.idecmobile.provider", holder.entry.getLocalFile());

    Intent shareIntent = ShareCompat.IntentBuilder.from(callingActivity)
            .setType(callingActivity.getContentResolver().getType(fileUri))
            .setStream(fileUri)
            .getIntent();

    shareIntent.setData(fileUri);
    shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

    if (shareIntent.resolveActivity(callingActivity.getPackageManager()) != null) {
        callingActivity.startActivity(shareIntent);
    } else Toast.makeText(callingActivity, R.string.error, Toast.LENGTH_SHORT).show();
}
项目:XYZReader    文件:ArticleDetailFragment.java   
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    mRootView = inflater.inflate(R.layout.fragment_article_detail, container, false);

    ScrollView scrollView = (ScrollView) mRootView.findViewById(R.id.scrollview);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        scrollView.setNestedScrollingEnabled(true);
    }

    mPhotoView = (ImageView) getActivity().findViewById(R.id.photo);

    getActivity().findViewById(R.id.share_fab).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            startActivity(Intent.createChooser(ShareCompat.IntentBuilder.from(getActivity())
                    .setType("text/plain")
                    .setText("Some sample text")
                    .getIntent(), getString(R.string.action_share)));
        }
    });

    return mRootView;
}
项目:Cook-E    文件:BugReportActivity.java   
/**
 * Starts the process of sending an E-mail message with the report
 * @param report the report to send
 */
private void mailReport(BugReport report) {

    final StringBuilder message = new StringBuilder();
    final DateTimeFormatter formatter = ISODateTimeFormat.dateTimeNoMillis();
    message.append("Time: ");
    formatter.printTo(message, report.getDate());
    message.append('\n');
    message.append("User description: ");
    message.append(report.getDesc());
    message.append("\nMetadata: ");
    message.append(report.getMeta());


    ShareCompat.IntentBuilder.from(this)
            .setType("message/rfc822")
            .addEmailTo(REPORT_ADDRESS)
            .setSubject("Cook-E Problem Report")
            .setText(message)
            .setChooserTitle(R.string.mail_report)
            .startChooser();
    finish();
}
项目:Amumu    文件:ShareDribbbleImageTask.java   
@Override
protected void onPostExecute(File result) {
    if (result == null) { return; }
    // glide cache uses an unfriendly & extension-less name,
    // massage it based on the original
    String fileName = shot.images.best();
    fileName = fileName.substring(fileName.lastIndexOf('/') + 1);
    File renamed = new File(result.getParent(), fileName);
    result.renameTo(renamed);
    Uri uri = FileProvider.getUriForFile(activity,
            activity.getString(R.string.share_authority), renamed);
    ShareCompat.IntentBuilder.from(activity)
            .setText(getShareText())
            .setType(getImageMimeType(fileName))
            .setSubject(shot.title)
            .setStream(uri)
            .startChooser();
}
项目:Popular-Movies    文件:MovieDetailFragment.java   
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case android.R.id.home:
            getActivity().onBackPressed();
            return true;
        case R.id.action_share:
            if (mTrailers == null || mTrailers.size() == 0) return false;
            String trailerUrl = YouTubeTrailerUtils.buildVideoUriForTrailer(mTrailers.get(0)).toString();
            ShareCompat.IntentBuilder
                    .from(getActivity())
                    .setType("text/plain")
                    .setChooserTitle(mMovie.getTitle())
                    .setText(trailerUrl)
                    .startChooser();
            return true;
        default:
            return false;
    }
}
项目:android-proguards    文件:ShareDribbbleImageTask.java   
@Override
protected void onPostExecute(File result) {
    if (result == null) { return; }
    // glide cache uses an unfriendly & extension-less name,
    // massage it based on the original
    String fileName = shot.images.best();
    fileName = fileName.substring(fileName.lastIndexOf('/') + 1);
    File renamed = new File(result.getParent(), fileName);
    result.renameTo(renamed);
    Uri uri = FileProvider.getUriForFile(activity, BuildConfig.FILES_AUTHORITY, renamed);
    ShareCompat.IntentBuilder.from(activity)
            .setText(getShareText())
            .setType(getImageMimeType(fileName))
            .setSubject(shot.title)
            .setStream(uri)
            .startChooser();
}
项目:OldDriver-master    文件:ShareDribbbleImageTask.java   
@Override
protected void onPostExecute(File result) {
    if (result == null) { return; }
    // glide cache uses an unfriendly & extension-less name,
    // massage it based on the original
    String fileName = shot.images.best();
    fileName = fileName.substring(fileName.lastIndexOf('/') + 1);
    File renamed = new File(result.getParent(), fileName);
    result.renameTo(renamed);
    Uri uri = FileProvider.getUriForFile(activity,
            activity.getString(R.string.share_authority), renamed);
    ShareCompat.IntentBuilder.from(activity)
            .setText(getShareText())
            .setType(getImageMimeType(fileName))
            .setSubject(shot.title)
            .setStream(uri)
            .startChooser();
}
项目:FastAccess    文件:MainPresenter.java   
@Override public void onShareUserBackup(@NonNull MainView mainView, @NonNull FirebaseUser currentUser) {
    String packageName = mainView.getApplicationContext().getPackageName();
    Uri deepLinkBuilder = new Uri.Builder()
            .scheme("http")
            .authority(BuildConfig.FA_HOST)
            .appendQueryParameter(BuildConfig.SHARED_URI, currentUser.getUid())
            .build();
    Uri.Builder builder = new Uri.Builder()
            .scheme("https")
            .authority(mainView.getResources().getString(R.string.link_ref) + ".app.goo.gl")
            .path("/")
            .appendQueryParameter("link", Uri.parse(deepLinkBuilder.toString()).toString())
            .appendQueryParameter("apn", packageName);
    ShareCompat.IntentBuilder.from(mainView)
            .setType("message/*")
            .setSubject(mainView.getString(R.string.sharing_backup))
            .setChooserTitle(mainView.getString(R.string.share_my_backup))
            .setHtmlText("<a href='" + Uri.decode(builder.toString()) + "'>" + mainView.getString(R.string.click_here_html) +
                    "</a><br/><b>~" + mainView.getString(R.string.app_name) + "</b>").startChooser();
}
项目:pictureapp    文件:ExportData.java   
/**
 * This method create the email intent
 */
private static Intent createEmailIntent(Activity activity, File data) {
    final Uri uri = FileProvider.getUriForFile(activity, BuildConfig.AuthoritiesProvider, data);

    final Intent chooser = ShareCompat.IntentBuilder.from(activity)
            .setType("application/zip")
            .setSubject("Local " + PreferencesState.getInstance().getContext().getString(
                    R.string.malaria_case_based_reporting)
                    + " db " + new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(
                    Calendar.getInstance().getTime()))
            .setStream(uri)
            .setChooserTitle(
                    activity.getResources().getString(R.string.export_data_option_title))
            .createChooserIntent()
            .addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

    return chooser;
}
项目:tinytimetracker    文件:CSVExport.java   
public void share(String subject) {
    if (file == null || ! file.exists()) {
        Log.i(TAG, "does not exist");
        return;
    }
    String chooserTitle = context.getResources().getString(R.string.dialog_title_share_database);
    final Uri uri = FileProvider.getUriForFile(context, "com.firebirdberlin.tinytimetracker.fileprovider", file);
    final Intent intent = ShareCompat.IntentBuilder.from((Activity) context)
        .setType("text/csv")
        .setSubject(subject)
        .setStream(uri)
        .setChooserTitle(chooserTitle)
        .createChooserIntent()
        .addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

    context.startActivity(intent);
}
项目:xamoom-android-sdk    文件:ContentBlock5ViewHolder.java   
private void startShareIntent(String fileUrl) {
  File file = null;
  try {
    file = mFileManager.getFile(fileUrl);
  } catch (IOException e) {
    e.printStackTrace();
  }

  if (file == null) {
    fileNotFoundToast();
    return;
  }

  Uri fileUri = FileProvider.getUriForFile(mFragment.getContext(),
      Config.AUTHORITY, file);
  Intent shareIntent = ShareCompat.IntentBuilder.from(mFragment.getActivity())
      .setType(mFragment.getContext().getContentResolver().getType(fileUri))
      .setStream(fileUri)
      .getIntent();
  shareIntent.setData(fileUri);
  shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

  mFragment.getActivity().startActivity(shareIntent);
}
项目:Casheta    文件:DetailFragment.java   
private Intent createShareMovieIntent() {
    Uri trailerUri = MovieContract.VideoEntry.buildUriForMovieTrailer(movieId);
    Cursor cursor = getActivity().getContentResolver().query(
            trailerUri, null, null, null, null);
    if (cursor.moveToFirst()) {
        int keyColumnIndex = cursor.getColumnIndex(MovieContract.VideoEntry.COLUMN_KEY);
        Intent intent = ShareCompat.IntentBuilder
                .from(getActivity())
                .setText(getString(R.string.sharing_movie_text,
                        YouTubeUriBuilder.getUri(cursor.getString(keyColumnIndex)).toString()) +
                        getResources().getString(R.string.app_hashtag))
                .setType("text/plain")
                .createChooserIntent();
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
        return intent;
    } else
        return null;
}
项目:plaid    文件:ShareDribbbleImageTask.java   
@Override
protected void onPostExecute(File result) {
    if (result == null) { return; }
    // glide cache uses an unfriendly & extension-less name,
    // massage it based on the original
    String fileName = shot.images.best();
    fileName = fileName.substring(fileName.lastIndexOf('/') + 1);
    File renamed = new File(result.getParent(), fileName);
    result.renameTo(renamed);
    Uri uri = FileProvider.getUriForFile(activity, BuildConfig.FILES_AUTHORITY, renamed);
    ShareCompat.IntentBuilder.from(activity)
            .setText(getShareText())
            .setType(getImageMimeType(fileName))
            .setSubject(shot.title)
            .setStream(uri)
            .startChooser();
}
项目:dhis2-android-trackercapture    文件:ExportData.java   
/**
 * This method create the email intent
 */
private Intent createEmailIntent(Activity activity, File data) {
    Log.d(TAG, data.toURI() + "");
    data.setReadable(true, false);
    final Uri uri = FileProvider.getUriForFile(activity,
            "org.hisp.dhis.android.trackercapture.export.ExportData", data);

    final Intent chooser = ShareCompat.IntentBuilder.from(activity)
            .setType("application/zip")
            .setSubject(mContext.getString(
                    R.string.app_name)
                    + " db " + new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(
                    Calendar.getInstance().getTime()))
            .setStream(uri)
            .setChooserTitle(
                    activity.getResources().getString(R.string.export_data_name))
            .createChooserIntent()
            .addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

    return chooser;
}
项目:OpenLinkWith    文件:AddToHomeScreen.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    analytics.sendScreenView("AddToHomeScreen");

    final ShareCompat.IntentReader reader = ShareCompat.IntentReader.from(this);
    String foundUrl = Urls.extractUrlFrom(getIntent(), reader);

    if (foundUrl != null) {
        Intent intent = RedirectFixActivity.createIntent(this, foundUrl)
                .putExtra(ResolverActivity.EXTRA_ADD_TO_HOME_SCREEN, true);
        startActivity(intent);
    } else {
        Toast.makeText(this, R.string.error_invalid_url, Toast.LENGTH_SHORT).show();
    }

    finish();
}
项目:Mover    文件:MoverRecycleFragment.java   
@Override
public boolean onMenuItemClick(MenuItem menuItem) {

    switch (menuItem.getItemId()){
        case R.id.share:
            Video video = ((WatchMeAdapterNew.WatchMeHolder) getRecycleView()
                    .findViewHolderForPosition(mSelectedVideoPosition)).getObject();

            ShareCompat.IntentBuilder.from(getActivity())
                    .setChooserTitle(R.string.abc_shareactionprovider_share_with)
                    .setType("text/plain")
                    .setText(getString(R.string.sharing_video_template, video.getTitle(), video.getLinkForShare()))
                    .startChooser();

            return true;

        default:
            return false;
    }
}
项目:Umweltzone    文件:IntentHelper.java   
public static Intent getSendEmailIntent(
        @NonNull Activity activity,
        @NonNull String[] toRecipients,
        @Nullable String[] bccRecipient,
        @NonNull String subject,
        @NonNull String message) {
    ShareCompat.IntentBuilder builder = ShareCompat.IntentBuilder.from(activity);
    builder.setEmailTo(toRecipients);
    if (bccRecipient != null) {
        builder.setEmailBcc(bccRecipient);
    }
    builder.setSubject(subject);
    builder.setType("message/rfc822");
    builder.setHtmlText(message);
    return builder.getIntent();
}
项目:SpaceLaunchNow-Android    文件:DebugPresenter.java   
@Override
public void downloadLogsClicked(Activity activity) {
    File textFile = new File(activity.getCacheDir(), "success.txt");
    Uri uriForFile = FileProvider.getUriForFile(activity, "me.calebjones.spacelaunchnow", textFile);
    activity.grantUriPermission("me.calebjones.spacelaunchnow", uriForFile, Intent.FLAG_GRANT_READ_URI_PERMISSION);

    Intent intent = ShareCompat.IntentBuilder.from(activity)
            .setStream(uriForFile) // uri from FileProvider
            .setType("text/plain")
            .getIntent()
            .setAction(Intent.ACTION_SEND) //Change if needed
            .setDataAndType(uriForFile, "text/plain")
            .addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

    activity.startActivity(Intent.createChooser(intent, "Save File"));
}
项目:iosched    文件:SessionDetailFragment.java   
@Override
public void displayUserActionResult(SessionDetailModel data,
        SessionDetailUserActionEnum userAction, boolean success) {
    switch (userAction) {
        case SHOW_MAP:
            Intent mapIntent = new Intent(getActivity(), MapActivity.class);
            mapIntent.putExtra(MapActivity.EXTRA_ROOM, data.getRoomId());
            getActivity().startActivity(mapIntent);
            break;
        case SHOW_SHARE:
            ShareCompat.IntentBuilder builder = ShareCompat.IntentBuilder.from(getActivity())
                    .setType("text/plain")
                    .setText(getString(R.string.share_template, data.getSessionTitle(),
                            BuildConfig.CONFERENCE_HASHTAG, data.getSessionUrl()));
            Intent shareIntent = Intent.createChooser(
                    builder.getIntent(),
                    getString(R.string.title_share));
            getActivity().startActivity(shareIntent);
            break;
        default:
            // Other user actions are completely handled in model
            break;
    }
}
项目:toposuite-android    文件:PointsManagerActivity.java   
/**
 * Update the share intent.
 */
private void updateShareIntent() {
    try {
        final File tmpPointsPath = new File(this.getCacheDir(), "points");
        if (!tmpPointsPath.exists()) {
            if (!tmpPointsPath.mkdir()) {
                Logger.log(Logger.ErrLabel.IO_ERROR, "failed to create directory " + tmpPointsPath.getAbsolutePath());
            }
        }
        String currentJobName = Job.getCurrentJobName();
        String name = (currentJobName == null) || (currentJobName.isEmpty()) ? "points" : currentJobName;
        final File tmpPointsFile = new File(tmpPointsPath, name + ".csv");
        SharedResources.getSetOfPoints().saveAsCSV(this, tmpPointsFile);
        final Uri uri = FileProvider.getUriForFile(this, this.getPackageName(), tmpPointsFile);
        final Intent sendIntent = ShareCompat.IntentBuilder.from(this)
                .setType("text/csv")
                .setStream(uri).getIntent()
                .setAction(Intent.ACTION_SEND)
                .addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET)
                .addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
        this.setShareIntent(sendIntent);
    } catch (IOException e) {
        Logger.log(Logger.ErrLabel.IO_ERROR, e.getMessage());
    }
}
项目:muzei    文件:GalleryAddPhotosActivity.java   
@Nullable
private String getCallingApplication(ShareCompat.IntentReader intentReader) {
    String callingPackage = intentReader.getCallingPackage();
    if (TextUtils.isEmpty(callingPackage)) {
        Uri referrer = ActivityCompat.getReferrer(this);
        if (referrer != null) {
            callingPackage = referrer.getHost();
        }
    }
    CharSequence label = null;
    if (!TextUtils.isEmpty(callingPackage)) {
        PackageManager pm = getPackageManager();
        try {
            label = pm.getApplicationLabel(pm.getApplicationInfo(callingPackage, 0));
        } catch (PackageManager.NameNotFoundException e) {
            Log.w(TAG, "Could not retrieve label for package " + callingPackage, e);
        }
    }
    return label != null ? label.toString() : null;
}
项目:android-flat-button    文件:MainActivity.java   
@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.
    switch (item.getItemId()) {
        case R.id.action_github:
            Intent browse = new Intent(Intent.ACTION_VIEW, Uri.parse(Config.GITHUB_URL));
            startActivity(browse);
            return true;
        case R.id.action_social:
            ShareCompat.IntentBuilder intentBuilder = ShareCompat.IntentBuilder.from(MainActivity.this);
            intentBuilder.setChooserTitle("Choose Share App")
                    .setType("text/plain")
                    .setSubject("Flat button for android")
                    .setText("A flat button library for android #AndroidFlat goo.gl/C6aLDi")
                    .startChooser();
            return true;
    }
    return super.onOptionsItemSelected(item);
}
项目:google-iosched    文件:SocialStreamFragment.java   
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case R.id.menu_compose:
            Intent intent = ShareCompat.IntentBuilder.from(getActivity())
                    .setType("text/plain")
                    .setText(mSearchString + "\n\n")
                    .getIntent();

            UIUtils.preferPackageForIntent(getActivity(), intent,
                    UIUtils.GOOGLE_PLUS_PACKAGE_NAME);

            startActivity(intent);

            EasyTracker.getTracker().trackEvent("Home Screen Dashboard", "Click",
                    "Post to Google+", 0L);
            LOGD("Tracker", "Home Screen Dashboard: Click, post to Google+");

            return true;
    }
    return super.onOptionsItemSelected(item);
}
项目:iosched2013    文件:SocialStreamFragment.java   
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case R.id.menu_compose:
            Intent intent = ShareCompat.IntentBuilder.from(getActivity())
                    .setType("text/plain")
                    .setText(mSearchString + "\n\n")
                    .getIntent();

            UIUtils.preferPackageForIntent(getActivity(), intent,
                    UIUtils.GOOGLE_PLUS_PACKAGE_NAME);

            startActivity(intent);

            EasyTracker.getTracker().sendEvent("Home Screen Dashboard", "Click", "Post to G+", 0L);
            LOGD("Tracker", "Home Screen Dashboard: Click, post to g+");

            return true;
    }
    return false;
}
项目:ubiquitous    文件:DetailActivity.java   
/**
 * Uses the ShareCompat Intent builder to create our Forecast intent for sharing.  All we need
 * to do is set the type, text and the NEW_DOCUMENT flag so it treats our share as a new task.
 * See: http://developer.android.com/guide/components/tasks-and-back-stack.html for more info.
 *
 * @return the Intent to use to share our weather forecast
 */
private Intent createShareForecastIntent() {
    Intent shareIntent = ShareCompat.IntentBuilder.from(this)
            .setType("text/plain")
            .setText(mForecastSummary + FORECAST_SHARE_HASHTAG)
            .getIntent();
    shareIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
    return shareIntent;
}
项目:DailyTech    文件:DetailActivity.java   
private void shareArticleUrl() {
    String mimeType = "text/plain";
    String title = "Share Article";
    String newsTitle = article.getTitle();
    String newsUrl = article.getUrl();

    ShareCompat.IntentBuilder.from(this)
            .setChooserTitle(title)
            .setType(mimeType)
            .setText(newsTitle + "\n" + newsUrl)
            .startChooser();
}
项目:WhatsAppStatusSaver    文件:MainActivity.java   
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();
    //noinspection SimplifiableIfStatement
    if (id == R.id.action_refresh) {
        swipeRefreshLayout.setRefreshing(true);
        StatusSavingService.performFetch(mContext);
        return true;
    } else if (id == R.id.action_help) {
        showHelpPopup(MainActivity.this);
        return true;
    } else if (id == R.id.action_share) {
        String mimeType = "text/plain";
        String title = "Share  WhatsApp Status Saver App";
        ShareCompat.IntentBuilder.from(this)
                .setType(mimeType)
                .setChooserTitle(title)
                .setText(getResources().getString(R.string.share_text))
                .startChooser();
        return true;
    } else if (id == R.id.action_settings) {
        Intent intent = new Intent(MainActivity.this, SettingsActivity.class);
        startActivity(intent);
        return true;
    }
    return super.onOptionsItemSelected(item);
}
项目:Android_Sunshine_Watch    文件:DetailActivity.java   
/**
 * Uses the ShareCompat Intent builder to create our Forecast intent for sharing.  All we need
 * to do is set the type, text and the NEW_DOCUMENT flag so it treats our share as a new task.
 * See: http://developer.android.com/guide/components/tasks-and-back-stack.html for more info.
 *
 * @return the Intent to use to share our weather forecast
 */
private Intent createShareForecastIntent() {
    Intent shareIntent = ShareCompat.IntentBuilder.from(this)
            .setType("text/plain")
            .setText(mForecastSummary + FORECAST_SHARE_HASHTAG)
            .getIntent();
    shareIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
    return shareIntent;
}
项目:android-dev-challenge    文件:MainActivity.java   
private void shareText (String text) {
    // COMPLETED (2) Create a String variable called mimeType and set it to "text/plain"
    String mimeType = "text/plain";
    // COMPLETED (3) Create a title for the chooser window that will pop up
    String title = "Share with:";
    // COMPLETED (4) Use ShareCompat.IntentBuilder to build the Intent and start the chooser
    ShareCompat.IntentBuilder
            .from(this)
            .setType(mimeType)
            .setChooserTitle(title)
            .setText(text)
            .startChooser();
}
项目:android-dev-challenge    文件:DetailActivity.java   
/**
 * Uses the ShareCompat Intent builder to create our Forecast intent for sharing.  All we need
 * to do is set the type, text and the NEW_DOCUMENT flag so it treats our share as a new task.
 * See: http://developer.android.com/guide/components/tasks-and-back-stack.html for more info.
 *
 * @return the Intent to use to share our weather forecast
 */
private Intent createShareForecastIntent() {
    Intent shareIntent = ShareCompat.IntentBuilder.from(this)
            .setType("text/plain")
            .setText(mForecastSummary + FORECAST_SHARE_HASHTAG)
            .getIntent();
    shareIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
    return shareIntent;
}
项目:android-dev-challenge    文件:DetailActivity.java   
/**
 * Uses the ShareCompat Intent builder to create our Forecast intent for sharing. We set the
 * type of content that we are sharing (just regular text), the text itself, and we return the
 * newly created Intent.
 *
 * @return The Intent to use to start our share.
 */
private Intent createShareForecastIntent() {
    Intent shareIntent = ShareCompat.IntentBuilder.from(this)
            .setType("text/plain")
            .setText(mForecast + FORECAST_SHARE_HASHTAG)
            .getIntent();
    return shareIntent;
}