コード例 #1
0
  /**
   * Report an error to the host application. These errors are unrecoverable (i.e. the main resource
   * is unavailable). The errorCode parameter corresponds to one of the ERROR_* constants.
   *
   * @param errorCode The error code corresponding to an ERROR_* value.
   * @param description A String describing the error.
   * @param failingUrl The url that failed to load.
   */
  public void onReceivedError(
      final int errorCode, final String description, final String failingUrl) {
    final DroidGap me = this;

    // If errorUrl specified, then load it
    final String errorUrl = me.getStringProperty("errorUrl", null);
    if ((errorUrl != null)
        && (errorUrl.startsWith("file://")
            || errorUrl.indexOf(me.baseUrl) == 0
            || isUrlWhiteListed(errorUrl))
        && (!failingUrl.equals(errorUrl))) {

      // Load URL on UI thread
      me.runOnUiThread(
          new Runnable() {
            public void run() {
              me.showWebPage(errorUrl, false, true, null);
            }
          });
    }

    // If not, then display error dialog
    else {
      me.runOnUiThread(
          new Runnable() {
            public void run() {
              me.appView.setVisibility(View.GONE);
              me.displayError(
                  "Application Error", description + " (" + failingUrl + ")", "OK", true);
            }
          });
    }
  }
コード例 #2
0
 @Override
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   super.setIntegerProperty("splashscreen", R.drawable.splash);
   super.loadUrl("file:///asset/www/index.html", 50000);
   // setContentView(R.layout.activity_main);
 }
コード例 #3
0
ファイル: PkuJobActivity.java プロジェクト: taohex/ijsp
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    super.setBooleanProperty("loadInWebView", true);
    super.loadUrl("http://192.168.1.111:8080/ijsp/m/index.htm");
  }
コード例 #4
0
 @Override
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   // Set by <content src="index.html" /> in config.xml
   super.loadUrl(Config.getStartUrl());
   // super.loadUrl("file:///android_asset/www/app/index.html");
 }
コード例 #5
0
 /**
  * Display an error dialog and optionally exit application.
  *
  * @param title
  * @param message
  * @param button
  * @param exit
  */
 public void displayError(
     final String title, final String message, final String button, final boolean exit) {
   final DroidGap me = this;
   me.runOnUiThread(
       new Runnable() {
         public void run() {
           AlertDialog.Builder dlg = new AlertDialog.Builder(me);
           dlg.setMessage(message);
           dlg.setTitle(title);
           dlg.setCancelable(false);
           dlg.setPositiveButton(
               button,
               new AlertDialog.OnClickListener() {
                 public void onClick(DialogInterface dialog, int which) {
                   dialog.dismiss();
                   if (exit) {
                     me.endActivity();
                   }
                 }
               });
           dlg.create();
           dlg.show();
         }
       });
 }
コード例 #6
0
 @Override
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   super.setIntegerProperty("splashscreen", R.drawable.splash);
   // Set by <content src="index.html" /> in config.xml
   super.loadUrl(Config.getStartUrl(), 10000);
   // super.loadUrl("file:///android_asset/www/index.html")
 }
コード例 #7
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    super.loadUrl("file:///android_asset/www/index.html");

    // attach websocket factory
    appView.addJavascriptInterface(new WebSocketFactory(appView), "WebSocketFactory");
  }
コード例 #8
0
 @Override
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   // super.setIntegerProperty("splashscreen", R.drawable.splash);
   try {
     super.loadUrl(constantes.K_GetLocalUrl);
     // notificaciones.DoToast("Iniciando...", getApplicationContext());
   } catch (Exception e) {
     notificaciones.DoToast(e.getMessage(), getApplicationContext());
   }
 }
コード例 #9
0
 @Override
 public void onCreate(final Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.activity_main);
   webView = (CordovaWebView) findViewById(R.id.webView);
   webView.loadUrl("file:///android_asset/web/index.html");
 }
コード例 #10
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    super.init();

    // LogCat: onReceivedHttpAuthRequest(browserspy.dk:80,BrowserSpy.dk - HTTP Password Test)
    AuthenticationToken token = new AuthenticationToken();
    token.setUserName("test");
    token.setPassword("test");
    super.setAuthenticationToken(token, "browserspy.dk:80", "BrowserSpy.dk - HTTP Password Test");

    // Add web site to whitelist
    super.appView.addWhiteListEntry("http://browserspy.dk*", true);

    // Load test
    super.loadUrl("file:///android_asset/www/basicauth/index.html");
  }
コード例 #11
0
ファイル: DelveActivity.java プロジェクト: hopesfish/Game
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    try {
      this.wwwRoot =
          new File(
              this.getFilesDir().getAbsolutePath() + File.separator + LocationUtils.assetsFlag);
      if (this.wwwRoot.exists()) {
        this.wwwRoot.delete();
      }
      LocationUtils.copyAsset(this.getContext(), this.getFilesDir());
      this.httpServer = new DelveHTTPD(8080, this.wwwRoot);
    } catch (Exception e) {
      e.toString();
    }

    // Initialize activity
    super.init();

    // Clear cache if you want
    super.appView.clearCache(true);

    super.appView.getSettings().setAllowFileAccess(true);
    super.appView.getSettings().setAllowContentAccess(true);

    super.setStringProperty("errorUrl", "file:///android_asset/www/error.html"); // if error loading
    // file in
    // super.loadUrl().
    super.loadUrl("http://localhost:8080/");
    // super.loadUrl("file:///android_asset/www/index.html");
    // super.loadUrl("http://192.168.1.102/");
  }
コード例 #12
0
 @Override
 protected void onResume() {
   super.onResume();
 }
コード例 #13
0
ファイル: geolocation.java プロジェクト: pavel23/Geolocation
 @Override
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   super.loadUrl("file:///android_asset/www/index.html");
 }
コード例 #14
0
ファイル: FiveD.java プロジェクト: nafiskhan/five-d
 /** Called when the activity is first created. */
 @Override
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   // setContentView(R.layout.main);
   super.loadUrl("file:///android_asset/www/index.html");
 }
コード例 #15
0
  /**
   * Tell the client to display a prompt dialog to the user. If the client returns true, WebView
   * will assume that the client will handle the prompt dialog and call the appropriate
   * JsPromptResult method.
   *
   * <p>Since we are hacking prompts for our own purposes, we should not be using them for this
   * purpose, perhaps we should hack console.log to do this instead!
   *
   * @param view
   * @param url
   * @param message
   * @param defaultValue
   * @param result
   */
  @Override
  public boolean onJsPrompt(
      WebView view, String url, String message, String defaultValue, JsPromptResult result) {

    // Security check to make sure any requests are coming from the page initially
    // loaded in webview and not another loaded in an iframe.
    boolean reqOk = false;
    if (url.startsWith("file://")
        || url.indexOf(this.ctx.baseUrl) == 0
        || ctx.isUrlWhiteListed(url)) {
      reqOk = true;
    }

    // Calling PluginManager.exec() to call a native service using
    // prompt(this.stringify(args), "gap:"+this.stringify([service, action, callbackId, true]));
    if (reqOk
        && defaultValue != null
        && defaultValue.length() > 3
        && defaultValue.substring(0, 4).equals("gap:")) {
      JSONArray array;
      try {
        array = new JSONArray(defaultValue.substring(4));
        String service = array.getString(0);
        String action = array.getString(1);
        String callbackId = array.getString(2);
        boolean async = array.getBoolean(3);
        String r = ctx.pluginManager.exec(service, action, callbackId, message, async);
        result.confirm(r);
      } catch (JSONException e) {
        e.printStackTrace();
      }
    }

    // Polling for JavaScript messages
    else if (reqOk && defaultValue != null && defaultValue.equals("gap_poll:")) {
      String r = ctx.callbackServer.getJavascript();
      result.confirm(r);
    }

    // Calling into CallbackServer
    else if (reqOk && defaultValue != null && defaultValue.equals("gap_callbackServer:")) {
      String r = "";
      if (message.equals("usePolling")) {
        r = "" + ctx.callbackServer.usePolling();
      } else if (message.equals("restartServer")) {
        ctx.callbackServer.restartServer();
      } else if (message.equals("getPort")) {
        r = Integer.toString(ctx.callbackServer.getPort());
      } else if (message.equals("getToken")) {
        r = ctx.callbackServer.getToken();
      }
      result.confirm(r);
    }

    // Cordova JS has initialized, so show webview
    // (This solves white flash seen when rendering HTML)
    else if (reqOk && defaultValue != null && defaultValue.equals("gap_init:")) {
      ctx.appView.setVisibility(View.VISIBLE);
      ctx.spinnerStop();
      result.confirm("OK");
    }

    // Show dialog
    else {
      final JsPromptResult res = result;
      AlertDialog.Builder dlg = new AlertDialog.Builder(this.ctx);
      dlg.setMessage(message);
      final EditText input = new EditText(this.ctx);
      if (defaultValue != null) {
        input.setText(defaultValue);
      }
      dlg.setView(input);
      dlg.setCancelable(false);
      dlg.setPositiveButton(
          android.R.string.ok,
          new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
              String usertext = input.getText().toString();
              res.confirm(usertext);
            }
          });
      dlg.setNegativeButton(
          android.R.string.cancel,
          new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
              res.cancel();
            }
          });
      dlg.create();
      dlg.show();
    }
    return true;
  }
コード例 #16
0
 /** Called when the activity is first created. */
 @Override
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   super.setIntegerProperty("splashscreen", R.drawable.splash);
   super.loadUrl("file:///android_asset/www/index.html", 3000);
 }
コード例 #17
0
 @Override
 public void onCreate(Bundle savedInstanceState)
 {
     super.onCreate(savedInstanceState);