バック オフィス サイトに接続するアプリケーションを作成しています。バックオフィス サイトには、平均的なサイトの少なくとも 100 倍に相当する多数の JavaScript 関数が含まれています。残念ながら、それらはロードされず、多くの機能が適切に動作しなくなります。だから私はテストを実行しています。FireBugLite JavaScript テキストをロードするサーバーにページを配置しました。その多くの JavaScript は、Android WebView がそれをロードするかどうかをテストして確認するのに最適です。WebView は何もロードしませんが、ブラウザーは Firebug アイコンをロードします。一体何が違いを生むのでしょうか?なぜそれは私のWebViewではなくブラウザで実行できるのでしょうか? 助言がありますか。
バックオフィス アプリケーションを Droid (または Windows 以外の他のプラットフォーム) で利用できるようにするために、バックオフィス アプリケーションをだまして、Web サイトにアクセスしているのは Internet Explorer であると信じ込ませる必要がありました。これを行うには、WebView ユーザー エージェントを変更します。
また、このアプリケーションのランディング ページをスリム化したので、ソースを提供して支援を提供することができました。
package ksc.myKMB;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.Window;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebSettings;
import android.webkit.WebViewClient;
import android.widget.Toast;
public class myKMB extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); /** Performs base set up */
/** Create a Activity of this Activity, IE myProcess */
myProcess = this;
/*** Create global objects and web browsing objects */
HideDialogOnce = true;
webview = new WebView(this) {
};
webChromeClient = new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
// Activities and WebViews measure progress with different scales.
// The progress meter will automatically disappear when we reach 100%
myProcess.setProgress((progress * 100));
//CreateMessage("Progress is : " + progress);
}
};
webViewClient = new WebViewClient() {
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
Toast.makeText(myProcess, MessageBegText + description + MessageEndText, Toast.LENGTH_SHORT).show();
}
public void onPageFinished (WebView view, String url) {
/** Hide dialog */
try {
// loadingDialog.dismiss();
} finally {
}
//myProcess.setProgress(1000);
/** Fon't show the dialog while I'm performing fixes */
//HideDialogOnce = true;
view.loadUrl("javascript:document.getElementById('JTRANS011').style.visibility='visible';");
}
public void onPageStarted(WebView view, String url, Bitmap favicon) {
if (HideDialogOnce == false) {
//loadingDialog = ProgressDialog.show(myProcess, "",
// "One moment, the page is laoding...", true);
} else {
//HideDialogOnce = true;
}
}
};
getWindow().requestFeature(Window.FEATURE_PROGRESS);
webview.setWebChromeClient(webChromeClient);
webview.setWebViewClient(webViewClient);
setContentView(webview);
/** Load the Keynote Browser Settings */
LoadSettings();
webview.loadUrl(LandingPage);
}
/** Get Menu */
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu, menu);
return true;
}
/** an item gets pushed */
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
// We have only one menu option
case R.id.quit:
System.exit(0);
break;
case R.id.back:
webview.goBack();
case R.id.refresh:
webview.reload();
case R.id.info:
//IncludeJavascript("");
}
return true;
}
/** Begin Globals */
public WebView webview;
public WebChromeClient webChromeClient;
public WebViewClient webViewClient;
public ProgressDialog loadingDialog;
public Boolean HideDialogOnce;
public Activity myProcess;
public String OverideUserAgent_IE = "Mozilla/5.0 (Windows; MSIE 6.0; Android 1.6; en-US) AppleWebKit/525.10+ (KHTML, like Gecko) Version/3.0.4 Safari/523.12.2 myKMB/1.0";
public String LandingPage = "http://kscserver.com/main-leap-slim.html";
public String MessageBegText = "Problem making a connection, Details: ";
public String MessageEndText = " For Support Call: (xxx) xxx - xxxx.";
public void LoadSettings() {
webview.getSettings().setUserAgentString(OverideUserAgent_IE);
webview.getSettings().setJavaScriptEnabled(true);
webview.getSettings().setBuiltInZoomControls(true);
webview.getSettings().setSupportZoom(true);
}
/** Creates a message alert dialog */
public void CreateMessage(String message) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage(message)
.setCancelable(true)
.setNegativeButton("Close", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
AlertDialog alert = builder.create();
alert.show();
}
}
私のアプリケーションはバックグラウンドで実行されており、右下隅に Firebug が表示されていません。ただし、ブラウザー (上部のエミュレーター) には同じページがありますが、firebug が表示されます。私は何を間違っていますか?アプリケーションに十分なメモリが割り当てられていないか、プロセスの電力割り当て、または物理メモリのいずれかが原因であると想定しています。何とも言えませんが、私が知っているのは、結果が奇妙であるということだけです。
Androidデバイスから同じことを取得します。アプリケーションにはfirebugは表示されませんが、ブラウザにはfirebugが表示されます。
私はすでに Web ブラウザーで JavaScript をオンにしています。問題は、Web ビューが Web ブラウザーとは異なる動作をしていることです。