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


Java ShareCompat类代码示例

本文整理汇总了Java中android.support.v4.app.ShareCompat的典型用法代码示例。如果您正苦于以下问题:Java ShareCompat类的具体用法?Java ShareCompat怎么用?Java ShareCompat使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ShareCompat类属于android.support.v4.app包,在下文中一共展示了ShareCompat类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sendFeedbackSharingIntent

import android.support.v4.app.ShareCompat; //导入依赖的package包/类
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);
    }
}
 
开发者ID:cahergil,项目名称:Farmacias,代码行数:17,代码来源:MainActivity.java

示例2: shareText

import android.support.v4.app.ShareCompat; //导入依赖的package包/类
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()
    }
 
开发者ID:soryncrash13,项目名称:Small-Android-apps,代码行数:19,代码来源:MainActivity.java

示例3: getCallingApplication

import android.support.v4.app.ShareCompat; //导入依赖的package包/类
@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;
}
 
开发者ID:romannurik,项目名称:muzei,代码行数:21,代码来源:GalleryAddPhotosActivity.java

示例4: onOptionsItemSelected

import android.support.v4.app.ShareCompat; //导入依赖的package包/类
@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);
}
 
开发者ID:daergoth,项目名称:dankbank,代码行数:19,代码来源:MemeActivity.java

示例5: onClick

import android.support.v4.app.ShareCompat; //导入依赖的package包/类
@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();
	}
}
 
开发者ID:fengdongfei,项目名称:CXJPadProject,代码行数:19,代码来源:EmailSpan.java

示例6: handleShareIntent

import android.support.v4.app.ShareCompat; //导入依赖的package包/类
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);
    }
}
 
开发者ID:mecid,项目名称:robird-reborn,代码行数:26,代码来源:HomeActivity.java

示例7: sharePhoto

import android.support.v4.app.ShareCompat; //导入依赖的package包/类
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();
    }
}
 
开发者ID:kollerlukas,项目名称:Camera-Roll-Android-App,代码行数:18,代码来源:ItemActivity.java

示例8: onCreate

import android.support.v4.app.ShareCompat; //导入依赖的package包/类
@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();
    });
}
 
开发者ID:willowtreeapps,项目名称:android-instant-apps-demo,代码行数:23,代码来源:CartActivity.java

示例9: onPostExecute

import android.support.v4.app.ShareCompat; //导入依赖的package包/类
@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();
    }
 
开发者ID:goodev,项目名称:materialup,代码行数:18,代码来源:ShareDribbbleImageTask.java

示例10: performShare

import android.support.v4.app.ShareCompat; //导入依赖的package包/类
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();
}
 
开发者ID:vit1-irk,项目名称:idec-mobile,代码行数:22,代码来源:FileListFragment.java

示例11: onCreateView

import android.support.v4.app.ShareCompat; //导入依赖的package包/类
@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;
}
 
开发者ID:frank-tan,项目名称:XYZReader,代码行数:25,代码来源:ArticleDetailFragment.java

示例12: mailReport

import android.support.v4.app.ShareCompat; //导入依赖的package包/类
/**
 * 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();
}
 
开发者ID:Cook-E-team,项目名称:Cook-E,代码行数:27,代码来源:BugReportActivity.java

示例13: onPostExecute

import android.support.v4.app.ShareCompat; //导入依赖的package包/类
@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();
}
 
开发者ID:liulinbo,项目名称:Amumu,代码行数:19,代码来源:ShareDribbbleImageTask.java

示例14: onOptionsItemSelected

import android.support.v4.app.ShareCompat; //导入依赖的package包/类
@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;
    }
}
 
开发者ID:vanyaland,项目名称:Popular-Movies,代码行数:21,代码来源:MovieDetailFragment.java

示例15: onPostExecute

import android.support.v4.app.ShareCompat; //导入依赖的package包/类
@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();
}
 
开发者ID:yongjhih,项目名称:android-proguards,代码行数:18,代码来源:ShareDribbbleImageTask.java


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