Android application specified browser development instance
This article mainly explains the development example of Android browser, which has three parts: starting the default Android browser, specifying the browser to access and opening the local HTML file.
1、 Launch Android default browser
Java code
In this way, Android can call the default browser of the mobile phone.
II. Specify a browser to access
1. Specify the browser access that comes with Android ("com. Android. Browser": packagename; "com. Android. Browser. Browseractivity": start the main activity)
Java code
2. Start other browsers (of course, the browser must be installed on the machine)
You can call other browsers by modifying the following corresponding packagename and main startup activity.
intent. setClassName("com.android.browser","com.android.browser.BrowserActivity");
UC browser: "com uc. browser","com. uc. browser. Activityupdate: "com. Opera. Mini. Android", "com. Opera. Mini. Android. Browser" QQ browser: "com. Tencent. MTT", "com. Tencent. MTT. Mainactivity"
III. open the local HTML file
When opening a local HTML file, you must specify a browser instead of browsing in one way. The specific example code is as follows:
Java code
The key point is that the filter "content" is called.
Some friends who used to program in Win32 may feel that this form is used. " file://sccard/help.html "Yes, I can definitely tell you that the default browser settings do not parse the" file ". If you want your default Android browser to have this function, you need to modify the manifest.xml file in the Android source code, and then compile the browser code to generate the corresponding APK package to reinstall it on the machine.
The general steps are as follows:
1. Open packages / apps / Browser / androidmanifest Just add the XML file to the corresponding < intent Filter >.
XML / HTML code
2. Recompile, package and install. In this way, the new browser supports the form of "file".
Thank you for reading, hope to help you, thank you for your support to this site!