Callback from chooser

ぐ巨炮叔叔 提交于 2019-12-25 05:51:29

问题


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! :)


回答1:


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.



来源:https://stackoverflow.com/questions/9982349/callback-from-chooser

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!