SoFunction
Updated on 2025-04-09

Share Android browser development examples

This article mainly explains the development examples of Android browser, which has three parts: starting the Android default browser, specifying the browser to access, and opening the local html file.

 1. Start the Android default browser

Java code

Intent intent = new Intent();      
("");    
Uri content_url = ("");   
(content_url);   
startActivity(intent); 

In this way, android can call the phone's default browser to access.

 2. Specify the browser to access it

1. Specify the browser access that comes with Android
("": packagename; "": start the main activity)

Java code

Intent intent = new Intent();      
("");    
Uri content_url = ("/android");   
(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.

("","");

  1. uc browser":"", "“
  2.   opera:"", ""
  3.  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:

Java code

Intent intent = new Intent();  
("");    
Uri content_url = ("content:///sdcard/");   
(content_url);       
("","");   
startActivity(intent); 

The key point is to call the "content" filter.

Friends who used to program in win32 may think that using this form of "file://sccard/" can be done, I 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, 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>.

XML/HTMLCode
&lt;intent-filter&gt; 
&lt;action android:name="" /&gt; 
&lt;category android:name="" /&gt; 
&lt;category android:name="" /&gt; 
&lt;data android:scheme="file" /&gt; 
&lt;/intent-filter&gt; 

2. Recompile, package and install, so that the new browser supports the form of "file".

The above is the sample code for the development of Android browser. I hope it can help friends who develop this function. Thank you for your support!