2

開発者として、3G接続のAndroid webviewclientで実行されるアプリ(Webページを使用)の構築に関しては、かなり悪い経験をしました。私のユーザーの何人かは、いくつかのページがロードするのに最大10分かかると言っています。(イライラして誇張されているかどうかはわかりません。)個人的には、Android2.2を実行しているHTCDesireを使用し、自分の携帯電話でアプリをテストしました。実際、ローカルに保存されたWebページを使用してAJAXリクエストを行うアプリの場合でも、3Gでは非常に低速です。ほとんどの場合、タイムアウトして空白のページが表示されます。WIFIを使用している場合は、正常に動作し、非常に高速です。

Android2.2のネイティブブラウザは非常に高速だと多くの人が言っています。ただし、私にとっては、ネイティブブラウザアプリも3Gでは非常に遅いと言わざるを得ません。時々、Googleモバイルホームページはロードさえ完了しません。私はシンガポールにいるので、ほとんどの場所で3Gカバレッジで問題ないはずです。

問題を引き起こしているのはデバイスのハードウェアですか?

4

1 に答える 1

0

特に WebView の読み込み時間に関連するデバイス固有のパフォーマンスの問題については認識していません。ただし、リクエスト タイムアウトとネットワーク接続変更リスナーの両方を追加することもできます。追加情報については、要求の時間を計り、遅い要求に関するデバイスと接続情報を報告できます。

handler = new Handler();
WebView webView = findViewById(R.id.webview);
webView.setWebViewClient(new WebViewClient() {
    final long WEBVIEW_REQUEST_TIMEOUT = ...;
    final long WEBVIEW_SLOW_REQUEST_THRESHOLD = ...;
    Runnable onRequestTimeout = null;
    @Override
    public void onPageStarted(WebView view, final String url, Bitmap favicon) {
        super.onPageStarted(view, url, favicon); // current impl is no op but be fwd compatible
        saveRequestStartTime();
        onRequestTimeout = new Runnable() {
            @Override
            public void run() {
                handleRequestComplete(url, WebViewClient.ERROR_TIMEOUT);
            }
        };
        handler.postDelayed(onRequestTimeout, WEBVIEW_REQUEST_TIMEOUT);
    }

    @Override
    public void onPageFinished(WebView view, String url) {
        super.onPageFinished(view, url); // current impl is no op but be fwd compatible
        handleRequestComplete(url, 0);   // Return 0 onSuccess. All WebViewClient defined errors < 0. 
    }

    @Override
    public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
        super.onReceivedError(view, errorCode, description, failingUrl); // current impl is no op but be fwd compatible
        handleRequestComplete(failingUrl, errorCode);
    }

    private void handleRequestComplete(String url, int errorCode) {
        if (onRequestTimeout != null) {
            handler.removeCallbacks(onRequestTimeout);
        }
        onRequestTimeout = null;
        final long elapsedTime = getRequestElapsedTime();
        if (elapsedTime > WEBVIEW_SLOW_REQUEST_THRESHOLD) {
            reportSlowRequest(elapsedTime, url, errorCode);
        }
        clearRequestTime();
    }

    private void saveRequestStartTime() {...}
    private long getRequestElapsedTime() {...}
    private void clearRequestTime() {...}
    private void reportSlowRequest(long elapsedTime, String url, int errorCode) {...}
});
于 2013-12-16T07:36:40.277 に答える