Google Android SDK offline documents are very slow to open, it is said to pull something from Google's official website caused. Offline browsing resolves the issue. Firefox can be used on the PC side.
But Android doesn't seem to have a browser that supports working offline. It makes me very sad.
decided to develop a simple offline browser to view the SDK documentation at high speed on the phone.
The main points of the design are: initialization of webview and scaling problem, adding application to File open mode.
Don't say much nonsense: Here's 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 scaling scale, which results in poor user experience. So you need to set it to use discretionary scaling. Settings.setusewideviewport (TRUE); Enables the page to be clickable between links navigation webview.setwebviewclient (new webviewclient ()); Webview.setwebchromeclient (New Webchromeclient ()); The initial page is generally too large. We set it to 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) {//Ensure that you can navigate 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 "/> <!--remove the code for networking permissions <uses-permission android:name=" Android.permission.INTERNET "/>-<application android:allowbackup=" true "android:icon=" @mipmap /ic_launcher "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 "/> &L T;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.