本文介绍了安卓分享通过对话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过共享对话框是像TFLN(文本从昨晚)的应用程序见过了。看起来是这样的:

I've seen the "share via" dialogs that are in apps like TFLN (texts from last night).Looks like this:

我期待共享文本。有人能指出我朝着正确的方向吗?这是做了与意图?

I am looking to share text. Can someone point me in the right direction? Is this done with intents?

推荐答案

这的确是与意图完成。

有关共享图像,比如上例中的图片,这将是这样的:

For sharing an image, like in the example picture, it would be something like this:

Intent share = new Intent(Intent.ACTION_SEND);
share.setType("image/jpeg");

share.putExtra(Intent.EXTRA_STREAM,
  Uri.parse("file:///sdcard/DCIM/Camera/myPic.jpg"));

startActivity(Intent.createChooser(share, "Share Image"));

有关文字,你会使用这样的:

For text you would use something like:

Intent share = new Intent(Intent.ACTION_SEND);
share.setType("text/plain");
share.putExtra(Intent.EXTRA_TEXT, "I'm being sent!!");
startActivity(Intent.createChooser(share, "Share Text"));

这篇关于安卓分享通过对话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-22 03:41