This article describes the usage of browsers for Android development. Share it for your reference, as follows:
1. Start the default android browser
Intent intent = new Intent(); (""); Uri content_url = ("https://"); (content_url); startActivity(intent);
In this way, android can call the phone's default browser to access.
2. Specify the corresponding browser to access
1. Specify the browser access that comes with Android
("": packagename; "": start the main activity)
Intent intent = new Intent(); (""); Uri content_url = ("https://"); (content_url); ("",""); startActivity(intent);
2. Start other browsers (of course, this browser must be installed on the machine)
Just modify the following corresponding packagename and main startup activity to call other browsers
uc browser:"", ""
opera:"", ""
QQ Browser:"", ""
3. Open the local html file
When opening a local html file, you must specify a browser, and you cannot browse it in the way. The specific example code is as follows
Intent intent = new Intent(); (""); Uri content_url = ("content:///sdcard/"); (content_url); ("",""); startActivity(intent);
The key point is that the filter "content" is called.
If you have programmed on win32 in the past, you may think that using this form of "file://sccard/" can be done. You can tell you with certainty 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 file by yourself in the Android source code, and then compile the browser code yourself to generate the corresponding apk package to reinstall it on the machine.
The general steps are as follows:
1. Open the packages/apps/Browser/ file and add it to the corresponding <intent-filter>
<intent-filter> <action android:name="" /> <category android:name="" /> <category android:name="" /> <data android:scheme="file" /> </intent-filter>
2. Recompile, package and install, so that the new browser supports the form of "file".
I hope this article will be helpful to everyone's Android programming design.