如何确认Android Share Intent是否成功或完成 [英] How to confirm Android Share Intent is successful or complete
问题描述
以下是Android的意图我用来分享的代码。目前,它启动一个对话框,允许用户选择要分享的应用程序:
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));
个人而言,我即将说use startActivityForResult()
,然后检查返回的内容。但是,您可以在这里阅读更多,这不是那么简单。如果用户取消了意图,则返回相同的号码,就像意图已完成(对于大多数应用程序)。
最终,目前为止,更简单的Share意图一般,您无法检查是否成功。
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 Share Intent是否成功或完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!