Google Android SDK offline documents are very slow to open, it is said to pull something from Google's official website caused. Offline browsing can resolve the issue. Firefox can be used on the PC side.
But there seems to be no browser on the Android side that supports working offline. It makes me very sad. decided to develop a simple offline browser to quickly view the SDK documentation on the phone.
The main points of the design are: initialization of webview and scaling problem, adding application to File open mode.
Not much nonsense said: The following is the Code section:
Mainactivity:
Package Net.xby1993.simpleexplorer;import Android.app.activity;import Android.content.intent;import Android.net.uri;import Android.os.bundle;import Android.util.log;import Android.view.keyevent;import Android.view.window;import Android.view.windowmanager;import Android.webkit.webchromeclient;import Android.webkit.websettings;import Android.webkit.webview;import Android.webkit.webviewclient;public Class Mainactivity extends Activity {private static final String tag=mainactivity.class.getsimplename (); Private WebView WebView; @Override protected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); Set full-screen untitled bar requestwindowfeature (Window.feature_no_title); GetWindow (). SetFlags (Windowmanager.layoutparams.flag_fullscreen,windowmanager.layoutparams.flag_fullscreen); Setcontentview (R.layout.activity_main); WebView = (WebView) Findviewbyid (R.id.webview); WebSettings settings= webview.getsettings (); OpenSettings.setsupportzoom (true) for boot scaling support; Settings.setbuiltinzoomcontrols (TRUE); Settings.setjavascriptenabled (TRUE); By default, there is a limit to the scale, which makes the user experience bad, so it needs to be set to use any scale. Settings.setusewideviewport (TRUE); So that the page can be clicked link navigation webview.setwebviewclient (new webviewclient ()); Webview.setwebchromeclient (New Webchromeclient ()); The initial page is generally too large, we set the 75% Webview.setinitialscale (75); Intent intent=getintent (); Extract File Manager open mode transfer file address if (Intent.getaction (). Equals (Intent.action_view)) {String Struri=intent.getdatastri Ng (); LOG.D (Tag,tag); LOG.D (Tag,struri); LOG.D (Tag,uri.encode (Struri)); Webview.loadurl (Struri); }} @Override public boolean onKeyDown (int keycode,keyevent event) {//Make sure that you can browse through the history page stack if by using the return key (keycode== Event. Keycode_back&&webview.cangoback ()) {webview.goback (); return true; } return Super.onkeydown (KeycoDe,event); }}
Androidmanifest.xml
<?xml version= "1.0" encoding= "Utf-8"? ><manifest xmlns:android= "http://schemas.android.com/apk/res/ Android "package=" Net.xby1993.simpleexplorer "> <uses-permission android:name=" android.permission.READ_ External_storage "/> <uses-permission android:name=" Android.permission.MOUNT_UNMOUNT_FILESYSTEMS "/> < Uses-permission android:name= "Android.permission.WRITE_EXTERNAL_STORAGE"/> <uses-permission android:name= " Android.permission.INTERNET "/> <application android:allowbackup=" true "android:icon=" @mipmap/ic_lau Ncher "android:label=" @string/app_name "android:theme=" @style/apptheme "> <activity Android:name= ". Mainactivity "android:label=" @string/app_name "> <intent-filter> <action android:name= "Android.intent.action.MAIN"/> <category android:name= "Android.intent.catego Ry. LAUNCHER "/> </intent-Filter> <!--here to add this app in file open mode--<intent-filter> <action Android : Name= "Android.intent.action.VIEW"/> <category android:name= "Android.intent.category.DEFAULT"/> <data android:mimetype= "text/html"/> </intent-filter> </activity> < /application></manifest>
Can't stand the Android SDK document open slowly problem, self-developed easy offline browser.