的onActivityResult()从外部PDF阅读器返回时不叫 [英] onActivityResult() not called when returning from external pdf reader

查看:146
本文介绍了的onActivityResult()从外部PDF阅读器返回时不叫的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始从code这样的PDF阅读器:

I'm starting a pdf reader from code like this:

public static final int MY_INTENT_FLAG = 1;
String documentName = "filename.pdf";
File file = new File(getFilesDir(), documentName);
if (file != null && file.exists()) {
   Uri filePathUri = Uri.fromFile(file);
   Intent intent = new Intent(Intent.ACTION_VIEW);
   intent.setDataAndType(filePathUri, "application/pdf");

   try {
      startActivityForResult(intent,MY_INTENT_FLAG);
   } catch (ActivityNotFoundException e) {...}
}

它工作正常打开文档阅读它。然而,当我preSS从pdf阅读器的onActivityResult()的返回按钮没有被调用。为什么是这样?可以简单地因为特定的PDF阅读器不结果集code精加工时?我有我的设备上使用Acrobat Reader。

It works fine to open the document and read it. However, when I press the back button from the pdf reader onActivityResult() is not called. Why is this? Can it simply be because that particular pdf reader does not set a result code when finishing? I have Acrobat Reader on my device.

我想知道,当我得到来自外部的活动回来,这样用户就不需要在这种情况下再次登录。

I want to know when I get back from the external Activity so that the user don't need to login again in this case.

感谢您的任何输入

推荐答案

您可以得到一个的onActivityResult()方法,但你不能从子活动的结果,因为它不是由的setResult返回结果()

You can get a onActivityResult() method but you can not get the result from child activity because it is not returning result by setResult()

和你告诉你检查登录,这样你的替代方法来检查的登录

and you are telling you for check login so you have alternative ways to check the login

例如:

您可以保存用户名和密码 preference 键,你可以从中读取登录详细信息
如果它的细节present然后用户登录,如果没有,那么你可以弹出登录界面用户。

You can save username and password to preference and you can read the login details from it If details present in it then user is login and if not then you can popup login screen to user.

这篇关于的onActivityResult()从外部PDF阅读器返回时不叫的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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