Android:通过Intent.ACTION_SEND共享(某些东西),然后自动返回到我的应用 [英] Android: Sharing (something) via Intent.ACTION_SEND, then automatically return to my app

查看:406
本文介绍了Android:通过Intent.ACTION_SEND共享(某些东西),然后自动返回到我的应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想分享我的应用程序中的某些内容。
共享(例如,发送消息)后,我希望我的应用程序再次处于活动状态,而发送的应用程序消失。
使用以下代码,我希望调用 onActivityResult ,但从未调用过。

I would like to share something from my application. Once it is shared (e.g - message sent), I want my application to be active again and the sending app to disappear. Using the code below, I expected onActivityResult to be called, but it is never called.

发送电子邮件后,我的应用程序再次出现,但是发送SMS(消息传递)后,消息传递应用程序仍然保留。 (从未调用 onActivityResult

After sending email, my application appears again, but after sending SMS ('Messaging') the messaging app remains. (onActivityResult is never called)

谢谢:-)

Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("text/plain"); 
String shareBody = "This is a test";
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "You have to see this!");
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareBody);

startActivityForResult(Intent.createChooser(sharingIntent, "Share via"),1);

getFragmentManager().popBackStack();


推荐答案

只有在用户按下后退按钮时才会调用按钮。因为您正在启动新的意图,所以您将控制权交给另一个应用程序。
因此,通常情况下,如果用户按下后退按钮(我将以Android用户的身份进行操作),则该用户将返回到您的应用程序。据我所知,这是我更喜欢在这种情况下使用的方式,也是在Android中实现此目的的唯一方法。

This will only be called if the user presses the back button. Because you are starting a new intent, so you give control to another application. So normally, if the user presses the back button (which I would do as an Android user) the user will go back to your app. This the way I would prefer to use for this case, and as far as I know it is also the only way to do this in Android.

这篇关于Android:通过Intent.ACTION_SEND共享(某些东西),然后自动返回到我的应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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