これが正しい方法かどうかはまったくわかりませんが、Webビューが読み込まれている限り、スプラッシュスクリーンを表示しています。Webビューの読み込みが完了すると、Webビューが表示されます。
しかし、WebビューのHTMLコンテンツが正しくレンダリングされていません。それは私のAndroid携帯電話の内蔵ブラウザと私が持っている他のすべてのデバイスでコンテンツを正しく表示します。したがって、問題はこのアプリに限定されます。
MainActivity.java
package dk.zerone.vuc;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Bundle;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.Color;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class MainActivity extends Activity {
public final boolean networkCheck() {
ConnectivityManager connec = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);
if ( connec.getNetworkInfo(0).getState() == NetworkInfo.State.CONNECTED ||
connec.getNetworkInfo(0).getState() == NetworkInfo.State.CONNECTING ||
connec.getNetworkInfo(1).getState() == NetworkInfo.State.CONNECTING ||
connec.getNetworkInfo(1).getState() == NetworkInfo.State.CONNECTED ) {
return true;
} else if (connec.getNetworkInfo(0).getState() == NetworkInfo.State.DISCONNECTED || connec.getNetworkInfo(1).getState() == NetworkInfo.State.DISCONNECTED ) {
return false;
}
return false;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
/* Splash screen */
setContentView(R.layout.splash);
if(networkCheck()) {
String url = "http://mobil.vucfyn.dk/mobil";
final WebView webview;
webview = new WebView(MainActivity.this);
webview.loadUrl(url);
webview.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
//view.loadUrl(url);
return false;
}
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
setContentView(webview);
}
});
} else {
AlertDialog alertDialog = new AlertDialog.Builder(MainActivity.this).create();
alertDialog.setTitle("Fejl");
alertDialog.setMessage("Ingen forbindelse til internettet");
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
}
});
alertDialog.show();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
LogCat出力:
08-29 09:29:56.572: D/dalvikvm(545): GC_FOR_ALLOC freed 66K, 3% free 10191K/10503K, paused 58ms
08-29 09:29:56.579: I/dalvikvm-heap(545): Grow heap (frag case) to 11.036MB for 1048592-byte allocation
08-29 09:29:56.640: D/dalvikvm(545): GC_CONCURRENT freed 1K, 4% free 11214K/11591K, paused 4ms+4ms
08-29 09:29:56.849: I/WebView(545): webview.loadUrl(url)
08-29 09:29:57.139: D/gralloc_goldfish(545): Emulator without GPU emulation detected.
08-29 09:29:57.849: E/chromium(545): external/chromium/net/disk_cache/backend_impl.cc:1097: [0829/092957:ERROR:backend_impl.cc(1097)] Critical error found -8
08-29 09:29:58.029: W/chromium(545): external/chromium/net/disk_cache/storage_block-inl.h:119: [0829/092958:WARNING:storage_block-inl.h(119)] Failed data load.
08-29 09:29:58.029: W/chromium(545): external/chromium/net/disk_cache/storage_block-inl.h:119: [0829/092958:WARNING:storage_block-inl.h(119)] Failed data load.
08-29 09:29:58.039: W/chromium(545): external/chromium/net/disk_cache/storage_block-inl.h:119: [0829/092958:WARNING:storage_block-inl.h(119)] Failed data load.
08-29 09:29:58.059: E/chromium(545): external/chromium/net/disk_cache/entry_impl.cc:830: [0829/092958:ERROR:entry_impl.cc(830)] Failed to save user data
08-29 09:30:00.349: E/libEGL(545): call to OpenGL ES API with no current context (logged once per thread)
08-29 09:30:00.360: D/ShaderProgram(545): couldn't load the vertex shader!
08-29 09:30:00.360: E/libEGL(545): call to OpenGL ES API with no current context (logged once per thread)
08-29 09:30:00.360: D/ShaderProgram(545): couldn't load the vertex shader!
08-29 09:30:00.360: E/libEGL(545): call to OpenGL ES API with no current context (logged once per thread)
08-29 09:30:00.360: D/ShaderProgram(545): couldn't load the vertex shader!
08-29 09:30:00.360: E/libEGL(545): call to OpenGL ES API with no current context (logged once per thread)
08-29 09:30:00.360: D/ShaderProgram(545): couldn't load the vertex shader!
08-29 09:30:00.360: E/libEGL(545): call to OpenGL ES API with no current context (logged once per thread)
08-29 09:30:00.360: D/ShaderProgram(545): couldn't load the vertex shader!