从选择器回调 [英] Callback from chooser

查看:198
本文介绍了从选择器回调的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚开始实施一项共享功能,但不知道是否可能告诉我的内容是如何被共享(脸谱/叽叽喳喳/文字/等)不写我自己的选择器实现的。我最初的猜测是推出了选择器,但没有管理时使用startActivityForResult弄清楚使用哪个请求code。

 公共无效份额(字符串主题,字符串文本){
 最终意向意图=新意图(Intent.ACTION_SEND);
 intent.setType(text / plain的);
 intent.putExtra(Intent.EXTRA_SUBJECT,学科);
 intent.putExtra(Intent.EXTRA_TEXT,文字);
 startActivity(Intent.createChooser(意图的getString(R.string.share)));
}

任何帮助将大大AP preciated! :)


解决方案

  

我最初的猜测是使用startActivityForResult启动选择器,但没有设法弄清楚使用哪个请求code时。


这将无法可靠地工作。 〜活动99%都没有设立与 startActivityForResult 工作


  

我刚开始实施一项共享功能,但如果其可能在想告诉我的内容是如何被共享(脸谱/叽叽喳喳/文字/等),而无需编写我自己的实现选配的


对不起,您将需要编写您自己选择器这一点。

I just started implementing a share functionality but was wondering if its possible to tell how my content was shared (facebook/twitter/text/etc) without writing my own implementation of chooser. My initial guess was to use startActivityForResult when launching the chooser but haven't managed to figure out which requestcode to use.

public void share(String subject,String text) {
 final Intent intent = new Intent(Intent.ACTION_SEND);
 intent.setType("text/plain");
 intent.putExtra(Intent.EXTRA_SUBJECT, subject);
 intent.putExtra(Intent.EXTRA_TEXT, text);
 startActivity(Intent.createChooser(intent, getString(R.string.share)));
}

Any help would be greatly appreciated! :)

解决方案

My initial guess was to use startActivityForResult when launching the chooser but haven't managed to figure out which requestcode to use.

That will not work reliably. ~99% of activities are not set up to work with startActivityForResult.

I just started implementing a share functionality but was wondering if its possible to tell how my content was shared (facebook/twitter/text/etc) without writing my own implementation of chooser

Sorry, you will need to write your own chooser for this.

这篇关于从选择器回调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆