android 调用第三方应用程序后发生什么事件?
我对android有点陌生,我只是想问android调用第三方应用程序后发生了什么事件?
例如,我有以下代码打开 adobe reader 以从 sdcard 读取我的文件:
File fileToShow = new File(passedFileToShow);
Intent nextActivity = new Intent();
nextActivity.setAction(android.content.Intent.ACTION_VIEW);
nextActivity.setDataAndType(Uri.fromFile(fileToShow), "application/pdf");
nextActivity.putExtra("itemName", itemName );
startActivityForResult(nextActivity, 0);
打开 adobe reader 并且读完文件后,如何在点击设备后退按钮后调用该事件?
onBackPressed 不起作用, onActivityResult 也不起作用..
非常感谢您的帮助! :)
I'm kinda new to android, i just wanna ask android what is the event after invoking third party application?
for example i have the following code to open the adobe reader to read my file from the sdcard:
File fileToShow = new File(passedFileToShow);
Intent nextActivity = new Intent();
nextActivity.setAction(android.content.Intent.ACTION_VIEW);
nextActivity.setDataAndType(Uri.fromFile(fileToShow), "application/pdf");
nextActivity.putExtra("itemName", itemName );
startActivityForResult(nextActivity, 0);
after opening the adobe reader and i finished reading the file, how do i call the event after i tap the device back button?
onBackPressed doesn't work,
onActivityResult doesn't work too..
thanks a lot for any help! :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您按下后退按钮,它将调用 onRestart (它还应该使用 resutlCode *Activity.RESULT_CANCELED* 调用 onActivityResult )
您可以看到整个活动生命周期 此处
if you pressed the back button, it's going to call onRestart (Also it should call onActivityResult with the resutlCode *Activity.RESULT_CANCELED*)
You can see the whole activity lifecyle here
我要做的是定义一个布尔值来跟踪用户是否打开了 adobe。
然后在打开 pdf 之前将其设置为 true:
然后您可以检查 onResume() 中的布尔值并执行某些操作。只需记住之后将其设置回 false:
What I would do is define a boolean which keeps track of if the user opened adobe.
Then set it to true just prior to opening the pdf:
Then you can check the boolean in the onResume() and do something. Just remember to set it back to false afterward: