从应用程序内启动浏览器 - 如何返回应用程序?
我有以下方法可以从 Android 应用程序中打开浏览器。
String url = "http://www.example.com";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
如何让用户在查看页面后返回应用程序?
编辑
我在清单中为调用Intent
的Activity
设置了android:noHistory="true"
。
I've got the following to open up a browser from within an Android app.
String url = "http://www.example.com";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
How do you get the user back to the app after they have viewed the page?
Edit
I have android:noHistory="true"
set in my manifest for the Activity
calling the Intent
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果调用 Activity 位于 Backstack 中(默认情况下),用户将按“后退”键将顶层从堆栈中剥离。
但是,如果浏览器关闭,该 Activity 也会关闭,并且
Backstack
中的最后一个 Activity 就会出现在前面。如果您拥有您要访问的网站,并且可以在其中放置一个“后退”按钮(使用 javascriptwindow.close()
或类似方法),则该活动将关闭,并且您的应用程序堆栈中最顶层的活动将恢复。如果您的 Activity 不在中,那么我建议不要将用户发送到浏览器
Task
,而是使用自定义Activity
包含一个WebView
,让您可以完全控制(例如通过 Intent 手动启动原始 Activity)If the calling Activity is in the
Backstack
(as default) the user would press "back" to peal the top layer off the stack.However if the browser closes, the Activity does too, and the last Activity in the
Backstack
comes to the fore. If you own the site your going to and can put a "back" button in it (With javascriptwindow.close()
or similar), the activity will close and your applications topmost activity in the stack will resume.If your Activity isn't in the backstack then I would suggest instead of sending the user to the browser
Task
use a customActivity
containing aWebView
giving you full control (such as manually starting the original Activity through an Intent)你不能。他们必须按后退按钮才能返回您的应用程序。
You can't. They have to press the back button to get back to your app.