Contacts

Creating an Android browser application. How to change default browser in Android. Girl With a Silver Ring

Let's create a new application - a browser for android devices, with your own hands, it will be interesting, and there won’t be a lot of code.

Browser app for android

Let's launch android studio and create a new project, application name My Site, company domain at our discretion, I entered the website domain site. click Next, on the next tab we leave everything unchanged, click next, then the next one is already selected Empty Activity, we’ll leave it, then in the last tab we’ll change the Layout Name from activity_main to main, and click finish.

Android Studio will prepare the project files, this will take some time. Two files will be opened in the main window, main.xml And MainActivity.java, let's start working in the latter. Let's change extended AppCompactActivity to Activity and save.

Adding Permissions to the Manifest

Then open the file AndroidManifest.xml and add a custom permission after the first section user-permission,

so that our application has access to the Internet. Let's save and close AndroidManifest.xml.

Let's go to the file Main.xml, it is located on the path res/layout/main.xml, delete the line android:text="Hello Word!" completely, change TextView to WebView, remove unnecessary paddings from the properties of the main RelativeLayout layer (paddingBottom, paddingLeft, paddingRight, paddingTop).

For WebView, add the android:id="@+id/webView" property, change android:layout_width="wrap_content" and android:layout_height="wrap_content" to android:layout_width="match_parent" and android:layout_height="match_parent", for so that our WebView element fills the entire screen.

Code logic in Java

We are done with the main.xml file, let's move on to MainActivity.java. Let's add a variable wv type WebView, we’ll assign an element to it, finding it using the findViewById() function, describe the wv settings, in particular, let’s allow the WebView to execute java scripts, indicate the address for loading the site into our browser, for example, I’ll launch Yandex using the function loadUrl("http:// ya.ru").

public class MainActivity extends Activity ( WebView wv; @Override protected void onCreate(Bundle savedInstanceState) ( super.onCreate(savedInstanceState); setContentView(R.layout.main); wv = (WebView)findViewById(R.id.webView); WebSettings settings = wv.getSettings(); settings.setJavaScriptEnabled(true); wv..setWebViewClient(new WebViewClient());

Below we will also write the processing of pressing the back button on the device.

@Override public void onBackPressed())( if(wv.canGoBack())( wv.goBack(); )else( super.onBackPressed(); ) )

Running an application in an emulator

Click the Start button, it's a green triangle on the toolbar AndroidStudio, our emulator will start, and if everything is done correctly, after a while the Yandex search will start in the browser, you can click on virtual keyboard and look for something, everything works well.

Let’s close the program without closing the emulator itself by clicking on the red rectangle, this is Stop instead of Start, change the address to an arbitrary one, I will “promote” my site “https://site”,

I’ll click save and run the program again, this time everything will happen faster, I’ll wander around the site, in the Programming for Android section there are articles and videos on how to install and configure AndroidStudio, make an Android emulator and simple examples of programs.

Full text of AndroidManifest.xml

Full text of main.xml

Full text of MainActivity.java

package ru.maxfad.mysite; import android.app.Activity; import android.os.Bundle; import android.webkit.WebSettings; import android.webkit.WebView; import android.webkit.WebViewClient; public class MainActivity extends Activity ( WebView wv; @Override protected void onCreate(Bundle savedInstanceState) ( super.onCreate(savedInstanceState); setContentView(R.layout.main); wv = (WebView)findViewById(R.id.webView); WebSettings settings = wv.getSettings(); settings.setJavaScriptEnabled(true); wv..setWebViewClient(new WebViewClient()); @Override public void onBackPressed())( if(wv.canGoBack())( wv.goBack(); )else( super.onBackPressed(); ) ) )

This video shows in detail how to create a browser application for Android devices:

I started learning Android programming not long ago. After Eclips produced my first Hello Word, I immediately wanted more: many plans and grandiose ideas arose. One such idea was to write your own Browser. I think many beginning programmers have had this desire. Here are the requirements I set and what happened in the end.

  • The program should open links global network, freely move forward and backward through pages;
  • Be able to download files and upload them back to the network;
  • Create bookmarks and save them;
  • Be able to download links sent from other applications;
  • There should be a home page button, a menu with various settings, etc.

In general, a full-fledged do-it-yourself browser. Let's put this into code.

The program is written based on the standard webview included in Android. As home page I use Yandex, it's a matter of taste. The main Activity will be MainActivity.

First of all, we set the xml markup of the file -activity_main.xml. We use LinearLayout as the main container - we wrap the ProgressBar in it to display the loading process. Next, we create another LinearLayout container - we wrap our Webview and FrameLayout in it (we use it to stretch the playing video to the full screen).

View code

LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height= "match_parent" android:orientation="vertical" tools:context=".MainActivity">

Let's start writing code in MainActivity

Full code of MainActivity.

View full code

Import java.io.File; import android.R.menu; import android.annotation.SuppressLint; import android.app.ActionBar; import android.app.Activity; import android.app.AlertDialog; import android.app.DownloadManager; import android.app.DownloadManager.Request; import android.app.KeyguardManager; import android.app.SearchManager; import android.content.BroadcastReceiver; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.IntentFilter; import android.content.SharedPreferences; import android.net.Uri; import android.os.Bundle; import android.os.Environment; import android.os.Parcelable; import android.os.PowerManager; import android.preference.PreferenceManager; import android.provider.MediaStore; import android.util.Log; import android.view.KeyEvent; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.WindowManager; import android.webkit.ConsoleMessage; import android.webkit.DownloadListener; import android.webkit.ValueCallback; import android.webkit.WebBackForwardList; import android.webkit.WebChromeClient; import android.webkit.WebView; import android.webkit.WebViewClient; import android.widget.FrameLayout; import android.widget.SearchView; import android.widget.Toast; import android.graphics.Bitmap; import android.webkit.URLUtil; public class MainActivity extends Activity ( //Логическая переменная для статуса соединения Boolean isInternetPresent = false; ConnectionDetector cd; private WebChromeClient.CustomViewCallback mFullscreenViewCallback; private FrameLayout mFullScreenContainer; private View mFullScreenView; private WebView mWebView; String urload; int cache = 1; SharedPreferences sPref; final Activity activity = this; public Uri imageUri; private static final int FILECHOOSER_RESULTCODE = 2888; mUploadMessage; private Uri mCapturedImageURI = null; = Uri.parse(url); ConnectingToInternet(); DOWNLOAD_SERVICE); private DownloadManager downloadManager;@Override protected void onCreate(Bundle savedInstanceState) ( super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //Create an example connection detector class: cd = new ConnectionDetector(getApplicationContext()); // create a home button final ActionBar actionBar = getActionBar(); actionBar.setHomeButtonEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true); // catch the intent that the file is loaded and notify BroadcastReceiver receiver = new BroadcastReceiver() ( @Override public void onReceive(Context context, Intent intent) ( String action = intent.getAction(); if (DownloadManager.ACTION_DOWNLOAD_COMPLETE.equals(action)) ( loadEnd(); ) ) ); // catch the intent that the file is loaded registerReceiver(receiver, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)); mWebView = (WebView) findViewById(R.id.web_view); mFullScreenContainer = (FrameLayout) findViewById(R.id.fullscreen_container); mWebView.setWebChromeClient(mWebChromeClient); handleIntent(getIntent()); class HelloWebViewClient extends WebViewClient ( @Override public void onPageStarted(WebView view, String url, Bitmap favicon) ( super.onPageStarted(view, url, favicon); findViewById(R.id.progress1).setVisibility(View.VISIBLE); setTitle( url); urload=mWebView.getUrl(); ConnectingToInternet (); @Override public boolean shouldOverrideUrlLoading(WebView view, String url) ( view.loadUrl(url); // launch links to the market= new File(imageStorageDir + File.separator + "IMG_" + String.valueOf(System.currentTimeMillis()) + ".jpg");< 3.0 @SuppressWarnings("unused") public void openFileChooser(ValueCallbackmCapturedImageURI = Uri.fromFile(file); uploadMsg, String acceptType, String capture) ( openFileChooser(uploadMsg, acceptType); ) public boolean onConsoleMessage(ConsoleMessage cm) ( onConsoleMessage(cm.message(), cm.lineNumber(), cm.sourceId()); return true; ) public void onConsoleMessage(String message, int lineNumber, String sourceID) ( //Log.d("androidruntime", "Show console messages, Used for debugging: " + message); ); );// End setWebChromeClient // Get the result @SuppressWarnings("unused") private Object data; @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) ( if (data == null) ( return; ) String urlPage2 = data.getStringExtra("urlPage2"); mWebView.loadUrl(urlPage2); if (requestCode = = FILECHOOSER_RESULTCODE) ( if (null == this.mUploadMessage) ( return; ) Uri result = null; try ( if (resultCode != RESULT_OK) ( result = null; ) else ( // retrieve from own variable if intent is null result = data == null ? mCapturedImageURI: data.getData(); ) ) catch (Exception e) ( Toast.makeText(getApplicationContext(), "activity:" + e, Toast.LENGTH_LONG).show(); ) mUploadMessage .onReceiveValue(result); mUploadMessage = null ) ) //******************************** public void loadEnd () ( Toast .makeText(this, "File Uploaded to Donwload", Toast.LENGTH_SHORT).show(); ) // menu @Override public boolean onCreateOptionsMenu(Menu menu) ( // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); mWebView.loadUrl("http://yandex.ru");

return true;

case R.id.item1:// back mWebView.canGoBack(); ( mWebView.goBack(); ) return true; case R.id.item2: // forward mWebView.canGoForward();

( mWebView.goForward(); ) return true;

Today, there are quite a lot of web browsers designed for Android devices. They all have their advantages and disadvantages. But, despite their differences, you can set any of them by default in three ways: various methods. Each of them will be described in detail later in the article.

Method 1: Setting OS Settings

The most popular and easiest method of setting the default browser is to configure the OS. To install your primary web browser, follow these steps:

    1. Go to your smartphone's settings from the home screen or application menu.


    1. Open item "Applications and notifications".

    1. Scroll to the bottom of the list to find the line "Additional settings". Sometimes you may not see this section in the list, since it is hidden in the column "More".

    1. Next, select an option "Default Applications".

    1. Choose a section "Browser", in order to set the default web browser. You can also set settings for messages, phone, voice input and more.

    1. When a window appears with a list of all installed browsers, check the box next to the one you want to set as default.


  1. You can now use your web browser. All links and messengers will be opened in the future in the installed browser.

This method is really very simple, and you can also set additional settings for your smartphone.

Method 2: Setting up web browsers

Using the settings, you can set any browser as the default, except the standard Google Chrome. You can complete this procedure in a few simple steps. Later in the article, using the example of the mobile version of Yandex Browser and MozillaFirefox, all the steps that must be performed to install the main web browser will be described in more detail. For other browsers the algorithm of actions will be similar.

    1. Open mobile version browser, in the upper or lower right corner, click on the three vertical dots to open the menu.


    1. Find the column "Settings" or "Options" and tap it to open it.

    1. Find the item in the list provided “Set as default browser” and click on it. If you use Yandex Browser, you can find this section at home page in the search bar menu.

    1. Next, a tab will appear on the screen in which you need to click "Settings".

    1. You will be taken to the settings page "Default Application". Now follow the same steps as described in steps 5, 6 and 7 of the previous method.


This option is very similar to the method described above. After completing certain actions, you will still go to the “Default Applications” section. But having given preference this method, you can set the settings without leaving your web browser.

Method 3: active link

This option has the same advantages as the first method described. You can install any browser as the main one on your smartphone, if it provides such an option.

This method is only relevant when you downloaded a new browser from the Play Store, or the main web browser was not previously installed on your phone.

  1. Go to the application that has an active link, click on it to go. If a window pops up with a list of actions, select "Open".
  2. A tab will appear in front of you in which you need to select a web browser to open the link. This should be the browser that you want to see as the main one on your smartphone, then check the button "Always".
  3. The selected link will open in the marked browser, which will be set as your default.

Unfortunately, this method not relevant for applications such as Telegram, VKontakte and the like. It may not be used in all situations. However, if you have recently installed a web browser, or the default settings have been removed, this option will become ideal solutions for you.

Additional installation of a web browser to follow internal links

Certain applications have a built-in link reader called WebView. For these programs, GoogleChrome or the WebView tool already mentioned above is used as the main browser. If necessary, you can change this parameter.
Well-known web browsers do not have this function, so you will have to look among less popular browsers. You can choose viewers from different manufacturers that are already installed in the proprietary Android OS shell. Before you proceed with the steps below, make sure that you have an active menu on your smartphone "For developers".

To replace the WebView viewer, follow these steps:

    1. Go to settings and find the item "System", which is at the bottom of the list.

    1. Next, open the section "For developers". You can also find it in the main settings menu at the end of the list of actions.

    1. Now find the column "WebView Service" and run it.

    1. If you are offered several options for viewing services, select the one that suits you best by checking the checkbox.

  1. Now all links will open in the browser you have chosen.

Link viewer, very rarely replaced. But you can use this option if your smartphone has the option described above.

This article described all possible methods for installing the browser as the main one for an Android smartphone. Depending on the situation, you can always choose the method that suits you.

Standard browsers on devices Android based often do not meet the everyday needs of demanding users. In this operating system There are a lot of high-quality and functional Internet browsers. We have collected the best browsers for Android in this article.

Firefox rightfully bears the title of one of the best mobile browsers on Android. Over the years of presence on this operating system, Mozilla's development has acquired a lot of functions and received an improved modern interface. Firefox for Android is a balance of functionality, convenience and speed of use. Mobile browser from Mozilla is inferior in speed to the same Google Chrome, but many of the features of Firefox are made much more pleasant and convenient.

Firefox's own Gecko engine supports almost all modern web standards, and there are also extensions for it with additional functionality, just like in the desktop version of the browser. Among the main functions of Fiefox: synchronization of all data between browsers using a special account, safe surfing, convenient start panel, a lot of extensions, reading mode.



The most popular browser not only on computers, but also on mobile devices ah is Google Chrome. Not surprising, since it is almost always pre-installed on the most popular mobile OS. Chrome has deservedly gained its popularity - it is fast, relatively functional, simple and convenient, and it is also well integrated with Google services and the desktop version of the browser (there is full synchronization of data and tabs). Integration with Google services can sometimes be useful, for example - translating text on pages with using Google Translator or voice search.

Chrome also takes care of user safety - the browser has a built-in filter for sites that may be dangerous for Android devices. There is some kind of data compression technology. It is not as perfect as Opera's, but it still saves a lot of data transmitted both over Wi-Fi and the mobile Internet. There is an incognito mode for anonymously visiting sites. Perhaps the only drawback of Chrome on this moment- lack of extension support. For those who want to try all the new features first, there's Chrome Beta and Dev. These browser versions are updated faster and more often - all innovations are tested in them.



Mobile browsers from the Norwegian company Opera are also one of the most popular, functional and fastest growing on the Android platform. Over the many years of their work, these guys have definitely been able to come up with a formula for an almost perfect Internet browser for smartphones and tablets. Opera has almost everything you need to the average user: fast surfing, convenient classic express panel, data synchronization with the desktop version, anonymous mode, convenient search with hints from the address panel, and one of the main features is traffic compression.

The guys from Opera have done their best with traffic saving technologies. Mobile Opera with activated mode Turbo can cut costs mobile internet two or even three times. For those for whom traffic consumption is especially important, there is Opera Mini - in it, saving is enabled by default, but sometimes it suffers from this appearance sites. Also, the mini version is much lighter and faster than regular Opera. Another one strong point browser of the same name - beautiful and pleasant appearance. Opera has always been famous for having one of the most stylish interfaces in browsers. If you want to compress all traffic on your device, then pay attention to the application.



Dolphin is an alternative browser on Android with tons of additional features and out-of-the-box features. Among these it is worth noting the support Adobe Flash, which almost everyone has abandoned, but it is still used in many places, the use of various themes to change the interface, support for unique add-ons and control of convenient and simple gestures. All this is available immediately - no additional settings. Dolphin is also fast, secure, free and always up-to-date - the developers release browser updates almost every week.


Puffin is a mobile web browser that is similar in concept to Dolphin. Here, too, there is a beautiful and convenient interface, there are many possibilities, and Puffin is as fast as the “dolphin”. Basically, the Puffin browser is suitable for weak devices, since it provides a special technology for “lightweight” web surfing - pages are first loaded on cloud service Puffin, they are optimized there and appear in a light form on the device screen. At the same time, the quality and appearance of the pages practically do not suffer from broken layout or reduced quality.

Also worth noting in Puffin are a number of additional features:

  • full Adobe Flash support for games (virtual joystick on the screen);
  • traffic encryption via cloud service;
  • mouse emulation;
  • the ability to upload files first to the cloud and then to the device;
  • installing extensions;
  • interface themes.
The Puffin browser is an excellent choice for weak devices, but the functionality in this Internet browser is not limited.



The Russian company Yandex has succeeded in creating its own browser for Android mobile devices. Yandex.Browser for this platform is an excellent solution for users from the CIS. This Internet browser is absolutely imbued with integration with the services of Yandex itself and other local social networks/ portals. For example, the search bar in the browser suggests the necessary sites and understands queries perfectly, and inside the application you can also view information about the weather and traffic jams.

Did you like the article? Share it