如何确认Android的分享意图是成功或完全 [英] How to confirm Android Share Intent is successful or complete

查看:457
本文介绍了如何确认Android的分享意图是成功或完全的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法确认是否在Android中一个共享的意图是成功还是不成功? (例如,如果我分享Facebook的帖子,我想知道,如果它成功张贴或知道它是否被取消。)

下面是我用它来分享Android的意图code。目前,它会启动一个对话框,允许用户选择分享给哪些应用:

 意图shareIntent =新意图(android.content.Intent.ACTION_SEND);
shareIntent.setType(text / plain的);
shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,学科);
shareIntent.putExtra(android.content.Intent.EXTRA_TEXT,体);
activity.startActivity(Intent.createChooser(shareIntent,标题));


解决方案

就个人而言,我刚想说用 startActivityForResult(),并检查被返回的。然而,正如你可以更读到这里,它不是那么简单。如果目的是由用户取消,仿佛意图完成(为最appications)被返回的相同数目

最后,此刻更简单分享意图的一般,你不能检查它是否成功与否。

Is there a way to confirm if a Share intent in Android was successful or unsuccessful? (For example, if I share a Facebook post, I'd like to know if it was successfully posted or know if it was cancelled.)

Below is the Android intent code that I use to Share. Currently, it launches a dialog to allow the user to choose which app to share to:

Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
shareIntent.setType("text/plain");
shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, body);    
activity.startActivity(Intent.createChooser(shareIntent, title));

解决方案

Personally, I was about to say "use startActivityForResult()" and check what gets returned. However, as you can read more here, it's not as simple as that. If the intent is cancelled by the user, the same number is returned as if the intent was completed (for most appications).

Ultimately, at the moment for a simpler Share intent in general, you cannot check if it's successful or not.

这篇关于如何确认Android的分享意图是成功或完全的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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