Android Browser Intent back button

耗尽温柔 提交于 2019-12-23 19:13:38

问题


Hello I am lauching the browser from my application using an intent such as:

String url = "XXXX";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);

but when I press back on the browser i want to go back to the my application, instead of going to the options of the browser. how can i control this behaviour?


回答1:


You can't as the back button implementation is now under control of Browser Application.

Implement a WebView in your application and handle Back Key Pressed is the only option.




回答2:


Try:

Intent i = new Intent(Intent.ACTION_VIEW);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.setData(Uri.parse(url));
startActivity(i);

A task (from the activity that started it to the next task activity) defines an atomic group of activities that the user can move to. Tasks can be moved to the foreground and background; all of the activities inside of a particular task always remain in the same order. You can find more about it here: http://developer.android.com/guide/components/tasks-and-back-stack.html



来源:https://stackoverflow.com/questions/12367602/android-browser-intent-back-button

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!