Android获取手机型号,系统版本,App版本号等信息

jopen 11年前

MainActivity如下:

import android.app.Activity;    import android.graphics.Bitmap;    import android.os.Bundle;    import android.webkit.WebSettings;    import android.webkit.WebView;    import android.webkit.WebViewClient;    import cn.testwebview.TestWebView.ScrollInterface;    /**    * Demo描述:    * 监听WebView滑动到底部    *     * 参考资料:    * 1 http://blog.csdn.net/conant1989/article/details/8124582    *   Thank you very much    */    public class MainActivity extends Activity {        private TestWebView mTestWebView;        @Override        protected void onCreate(Bundle savedInstanceState) {            super.onCreate(savedInstanceState);            setContentView(R.layout.main);            initWebView();        }                                //设置WebView        private void initWebView() {            mTestWebView = (TestWebView) findViewById(R.id.webView);            mTestWebView.setVerticalScrollBarEnabled(true);            mTestWebView.setHorizontalScrollBarEnabled(false);            mTestWebView.getSettings().setSupportZoom(true);            mTestWebView.getSettings().setBuiltInZoomControls(true);            mTestWebView.getSettings().setJavaScriptEnabled(true);                        mTestWebView.getSettings().setDomStorageEnabled(true);            mTestWebView.getSettings().setPluginsEnabled(true);            mTestWebView.requestFocus();                        mTestWebView.getSettings().setUseWideViewPort(true);            mTestWebView.getSettings().setLoadWithOverviewMode(true);            mTestWebView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);                        mTestWebView.loadUrl("http://www.ifeng.com");            mTestWebView.setWebViewClient(new TestWebViewClient());            webViewScroolChangeListener();                    }                //核心代码        private void webViewScroolChangeListener() {            mTestWebView.setOnCustomScroolChangeListener(new ScrollInterface() {                @Override                public void onSChanged(int l, int t, int oldl, int oldt) {                    //WebView的总高度                    float webViewContentHeight=mTestWebView.getContentHeight() * mTestWebView.getScale();                    //WebView的现高度                    float webViewCurrentHeight=(mTestWebView.getHeight() + mTestWebView.getScrollY());                    System.out.println("webViewContentHeight="+webViewContentHeight);                    System.out.println("webViewCurrentHeight="+webViewCurrentHeight);                    if ((webViewContentHeight-webViewCurrentHeight) == 0) {                        System.out.println("WebView滑动到了底端");                    }                }            });        }                    private class TestWebViewClient extends WebViewClient{            @Override            public void onPageStarted(WebView view, String url, Bitmap favicon) {                super.onPageStarted(view, url, favicon);            }            @Override            public boolean shouldOverrideUrlLoading(WebView view, String url) {                view.loadUrl(url);                return true;            }            @Override            public void onPageFinished(WebView view, String url) {                super.onPageFinished(view, url);                            }            @Override            public void onReceivedError(WebView view, int errorCode,String description, String failingUrl) {                super.onReceivedError(view, errorCode, description, failingUrl);            }        }           }  
main.xml如下:
    <RelativeLayout             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"            >                    <TextView                android:id="@+id/textView"                android:layout_width="wrap_content"                android:layout_height="wrap_content"                android:text="@string/hello_world"                 android:layout_centerInParent="true"                />                </RelativeLayout>