类org.apache.cordova.LOG源码实例Demo

下面列出了怎么用org.apache.cordova.LOG的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: BigDataPlatform   文件: SystemWebViewClient.java
/**
 * 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 view          The WebView that is initiating the callback.
 * @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.
 */
@Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
    // Ignore error due to stopLoading().
    if (!isCurrentlyLoading) {
        return;
    }
    LOG.d(TAG, "CordovaWebViewClient.onReceivedError: Error code=%s Description=%s URL=%s", errorCode, description, failingUrl);

    // If this is a "Protocol Not Supported" error, then revert to the previous
    // page. If there was no previous page, then punt. The application's config
    // is likely incorrect (start page set to sms: or something like that)
    if (errorCode == WebViewClient.ERROR_UNSUPPORTED_SCHEME) {
        parentEngine.client.clearLoadTimeoutTimer();

        if (view.canGoBack()) {
            view.goBack();
            return;
        } else {
            super.onReceivedError(view, errorCode, description, failingUrl);
        }
    }
    parentEngine.client.onReceivedError(errorCode, description, failingUrl);
}
 
源代码2 项目: cordova-plugin-dbmeter   文件: PermissionHelper.java
/**
 * Requests "dangerous" permissions for the application at runtime. This is a helper method
 * alternative to cordovaInterface.requestPermissions() that does not require the project to be
 * built with cordova-android 5.0.0+
 *
 * @param plugin        The plugin the permissions are being requested for
 * @param requestCode   A requestCode to be passed to the plugin's onRequestPermissionResult()
 *                      along with the result of the permissions request
 * @param permissions   The permissions to be requested
 */
public static void requestPermissions(CordovaPlugin plugin, int requestCode, String[] permissions) {
    try {
        Method requestPermission = CordovaInterface.class.getDeclaredMethod(
                "requestPermissions", CordovaPlugin.class, int.class, String[].class);

        // If there is no exception, then this is cordova-android 5.0.0+
        requestPermission.invoke(plugin.cordova, plugin, requestCode, permissions);
    } catch (NoSuchMethodException noSuchMethodException) {
        // cordova-android version is less than 5.0.0, so permission is implicitly granted
        LOG.d(LOG_TAG, "No need to request permissions " + Arrays.toString(permissions));

        // Notify the plugin that all were granted by using more reflection
        deliverPermissionResult(plugin, requestCode, permissions);
    } catch (IllegalAccessException illegalAccessException) {
        // Should never be caught; this is a public method
        LOG.e(LOG_TAG, "IllegalAccessException when requesting permissions " + Arrays.toString(permissions), illegalAccessException);
    } catch(InvocationTargetException invocationTargetException) {
        // This method does not throw any exceptions, so this should never be caught
        LOG.e(LOG_TAG, "invocationTargetException when requesting permissions " + Arrays.toString(permissions), invocationTargetException);
    }
}
 
/**
 * Notify the host application that a page has started loading.
 * This method is called once for each main frame load so a page with iframes or framesets will call onPageStarted
 * one time for the main frame. This also means that onPageStarted will not be called when the contents of an
 * embedded frame changes, i.e. clicking a link whose target is an iframe.
 *
 * @param view          The webview initiating the callback.
 * @param url           The url of the page.
 */
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
    super.onPageStarted(view, url, favicon);
    isCurrentlyLoading = true;
    LOG.d(TAG, "onPageStarted(" + url + ")");
    // Flush stale messages.
    this.appView.jsMessageQueue.reset();

    // Broadcast message that page has loaded
    this.appView.postMessage("onPageStarted", url);

    // Notify all plugins of the navigation, so they can clean up if necessary.
    if (this.appView.pluginManager != null) {
        this.appView.pluginManager.onReset();
    }
}
 
源代码4 项目: keemob   文件: FileUtils.java
private JSONObject requestAllPaths() throws JSONException {
    Context context = cordova.getActivity();
    JSONObject ret = new JSONObject();
    ret.put("applicationDirectory", "file:///android_asset/");
    ret.put("applicationStorageDirectory", toDirUrl(context.getFilesDir().getParentFile()));
    ret.put("dataDirectory", toDirUrl(context.getFilesDir()));
    ret.put("cacheDirectory", toDirUrl(context.getCacheDir()));
    if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
      try {
        ret.put("externalApplicationStorageDirectory", toDirUrl(context.getExternalFilesDir(null).getParentFile()));
        ret.put("externalDataDirectory", toDirUrl(context.getExternalFilesDir(null)));
        ret.put("externalCacheDirectory", toDirUrl(context.getExternalCacheDir()));
        ret.put("externalRootDirectory", toDirUrl(Environment.getExternalStorageDirectory()));
      }
      catch(NullPointerException e) {
        /* If external storage is unavailable, context.getExternal* returns null */
          LOG.d(LOG_TAG, "Unable to access these paths, most liklely due to USB storage");
      }
    }
    return ret;
}
 
源代码5 项目: keemob   文件: FileUtils.java
/**
 * Write contents of file.
 *
 * @param data				The contents of the file.
 * @param offset			The position to begin writing the file.
 * @param isBinary          True if the file contents are base64-encoded binary data
 */
/**/
public long write(String srcURLstr, String data, int offset, boolean isBinary) throws FileNotFoundException, IOException, NoModificationAllowedException {
    try {
    	LocalFilesystemURL inputURL = LocalFilesystemURL.parse(srcURLstr);
    	Filesystem fs = this.filesystemForURL(inputURL);
    	if (fs == null) {
    		throw new MalformedURLException("No installed handlers for this URL");
    	}

        long x = fs.writeToFileAtURL(inputURL, data, offset, isBinary); LOG.d("TEST",srcURLstr + ": "+x); return x;
    } catch (IllegalArgumentException e) {
        MalformedURLException mue = new MalformedURLException("Unrecognized filesystem URL");
        mue.initCause(e);
    	throw mue;
    }

}
 
public void printBackForwardList() {

        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                AmazonWebBackForwardList currentList = copyBackForwardList();
                int currentSize = currentList.getSize();
                for (int i = 0; i < currentSize; ++i) {
                    AmazonWebHistoryItem item = currentList.getItemAtIndex(i);
                    String url = item.getUrl();
                    LOG.d("cordovaamzn", "The URL at index: " + Integer.toString(i)
                        + "is " + url);
                }
            }
        });
    }
 
源代码7 项目: phonegapbootcampsite   文件: CordovaActivity.java
@Override
/**
 * The final call you receive before your activity is destroyed.
 */
public void onDestroy() {
    LOG.d(TAG, "CordovaActivity.onDestroy()");
    super.onDestroy();

    // hide the splash screen to avoid leaking a window
    this.removeSplashScreen();

    if (this.appView != null) {
        appView.handleDestroy();
    }
    else {
        this.activityState = ACTIVITY_EXITING; 
    }
}
 
源代码8 项目: bluemix-parking-meter   文件: FileHelper.java
/**
 * Returns the real path of the given URI string.
 * If the given URI string represents a content:// URI, the real path is retrieved from the media store.
 *
 * @param uriString the URI string of the audio/image/video
 * @param cordova the current application context
 * @return the full path to the file
 */
@SuppressWarnings("deprecation")
public static String getRealPath(String uriString, CordovaInterface cordova) {
    String realPath = null;

    if (uriString.startsWith("content://")) {
        String[] proj = { _DATA };
        Cursor cursor = cordova.getActivity().managedQuery(Uri.parse(uriString), proj, null, null, null);
        int column_index = cursor.getColumnIndexOrThrow(_DATA);
        cursor.moveToFirst();
        realPath = cursor.getString(column_index);
        if (realPath == null) {
            LOG.e(LOG_TAG, "Could get real path for URI string %s", uriString);
        }
    } else if (uriString.startsWith("file://")) {
        realPath = uriString.substring(7);
        if (realPath.startsWith("/android_asset/")) {
            LOG.e(LOG_TAG, "Cannot get real path for URI string %s because it is a file:///android_asset/ URI.", uriString);
            realPath = null;
        }
    } else {
        realPath = uriString;
    }

    return realPath;
}
 
源代码9 项目: reader   文件: FileHelper.java
/**
 * Returns the real path of the given URI string.
 * If the given URI string represents a content:// URI, the real path is retrieved from the media store.
 *
 * @param uriString the URI string of the audio/image/video
 * @param cordova the current application context
 * @return the full path to the file
 */
@SuppressWarnings("deprecation")
public static String getRealPath(String uriString, CordovaInterface cordova) {
    String realPath = null;

    if (uriString.startsWith("content://")) {
        String[] proj = { _DATA };
        Cursor cursor = cordova.getActivity().managedQuery(Uri.parse(uriString), proj, null, null, null);
        int column_index = cursor.getColumnIndexOrThrow(_DATA);
        cursor.moveToFirst();
        realPath = cursor.getString(column_index);
        if (realPath == null) {
            LOG.e(LOG_TAG, "Could get real path for URI string %s", uriString);
        }
    } else if (uriString.startsWith("file://")) {
        realPath = uriString.substring(7);
        if (realPath.startsWith("/android_asset/")) {
            LOG.e(LOG_TAG, "Cannot get real path for URI string %s because it is a file:///android_asset/ URI.", uriString);
            realPath = null;
        }
    } else {
        realPath = uriString;
    }

    return realPath;
}
 
源代码10 项目: lona   文件: SystemWebViewClient.java
/**
 * 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 view          The WebView that is initiating the callback.
 * @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.
 */
@Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
    // Ignore error due to stopLoading().
    if (!isCurrentlyLoading) {
        return;
    }
    LOG.d(TAG, "CordovaWebViewClient.onReceivedError: Error code=%s Description=%s URL=%s", errorCode, description, failingUrl);

    // If this is a "Protocol Not Supported" error, then revert to the previous
    // page. If there was no previous page, then punt. The application's config
    // is likely incorrect (start page set to sms: or something like that)
    if (errorCode == WebViewClient.ERROR_UNSUPPORTED_SCHEME) {
        parentEngine.client.clearLoadTimeoutTimer();

        if (view.canGoBack()) {
            view.goBack();
            return;
        } else {
            super.onReceivedError(view, errorCode, description, failingUrl);
        }
    }
    parentEngine.client.onReceivedError(errorCode, description, failingUrl);
}
 
/**
 * Requests "dangerous" permissions for the application at runtime. This is a helper method
 * alternative to cordovaInterface.requestPermissions() that does not require the project to be
 * built with cordova-android 5.0.0+
 *
 * @param plugin        The plugin the permissions are being requested for
 * @param requestCode   A requestCode to be passed to the plugin's onRequestPermissionResult()
 *                      along with the result of the permissions request
 * @param permissions   The permissions to be requested
 */
public static void requestPermissions(CordovaPlugin plugin, int requestCode, String[] permissions) {
    try {
        Method requestPermission = CordovaInterface.class.getDeclaredMethod(
                "requestPermissions", CordovaPlugin.class, int.class, String[].class);

        // If there is no exception, then this is cordova-android 5.0.0+
        requestPermission.invoke(plugin.cordova, plugin, requestCode, permissions);
    } catch (NoSuchMethodException noSuchMethodException) {
        // cordova-android version is less than 5.0.0, so permission is implicitly granted
        LOG.d(LOG_TAG, "No need to request permissions " + Arrays.toString(permissions));

        // Notify the plugin that all were granted by using more reflection
        deliverPermissionResult(plugin, requestCode, permissions);
    } catch (IllegalAccessException illegalAccessException) {
        // Should never be caught; this is a public method
        LOG.e(LOG_TAG, "IllegalAccessException when requesting permissions " + Arrays.toString(permissions), illegalAccessException);
    } catch(InvocationTargetException invocationTargetException) {
        // This method does not throw any exceptions, so this should never be caught
        LOG.e(LOG_TAG, "invocationTargetException when requesting permissions " + Arrays.toString(permissions), invocationTargetException);
    }
}
 
源代码12 项目: phonegapbootcampsite   文件: CordovaActivity.java
@Override
/**
 * Called when the system is about to start resuming a previous activity.
 */
protected void onPause() {
    super.onPause();

    LOG.d(TAG, "Paused the application!");

    // Don't process pause if shutting down, since onDestroy() will be called
    if (this.activityState == ACTIVITY_EXITING) {
        return;
    }

    if (this.appView == null) {
        return;
    }
    else
    {
        this.appView.handlePause(this.keepRunning);
    }

    // hide the splash screen to avoid leaking a window
    this.removeSplashScreen();
}
 
源代码13 项目: reader   文件: CordovaActivity.java
@SuppressLint("NewApi")
@Deprecated // Call init() instead and override makeWebView() to customize.
public void init(CordovaWebView webView, CordovaWebViewClient webViewClient, CordovaChromeClient webChromeClient) {
    LOG.d(TAG, "CordovaActivity.init()");

    appView = webView != null ? webView : makeWebView();
    if (appView.pluginManager == null) {
        appView.init(this, webViewClient != null ? webViewClient : makeWebViewClient(appView),
                webChromeClient != null ? webChromeClient : makeChromeClient(appView),
                pluginEntries, internalWhitelist, externalWhitelist, preferences);
    }

    // TODO: Have the views set this themselves.
    if (preferences.getBoolean("DisallowOverscroll", false)) {
        appView.setOverScrollMode(View.OVER_SCROLL_NEVER);
    }
    createViews();

    // TODO: Make this a preference (CB-6153)
    // Setup the hardware volume controls to handle volume control
    setVolumeControlStream(AudioManager.STREAM_MUSIC);
}
 
/**
 * Updates the JavaScript side whenever the connection changes
 *
 * @param info the current active network info
 * @return
 */
private void updateConnectionInfo(NetworkInfo info) {
    // send update to javascript "navigator.network.connection"
    // Jellybean sends its own info
    JSONObject thisInfo = this.getConnectionInfo(info);
    if(!thisInfo.equals(lastInfo))
    {
        String connectionType = "";
        try {
            connectionType = thisInfo.get("type").toString();
        } catch (JSONException e) {
            LOG.d(LOG_TAG, e.getLocalizedMessage());
        }

        sendUpdate(connectionType);
        lastInfo = thisInfo;
    }
}
 
/**
 * 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 view          The WebView that is initiating the callback.
 * @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.
 */
@Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
    LOG.d(TAG, "CordovaWebViewClient.onReceivedError: Error code=%s Description=%s URL=%s", errorCode, description, failingUrl);

    // Clear timeout flag
    this.appView.loadUrlTimeout++;

    // Handle error
    JSONObject data = new JSONObject();
    try {
        data.put("errorCode", errorCode);
        data.put("description", description);
        data.put("url", failingUrl);
    } catch (JSONException e) {
        e.printStackTrace();
    }
    this.appView.postMessage("onReceivedError", data);
}
 
源代码16 项目: app-icon   文件: SystemWebViewClient.java
/**
 * 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 view          The WebView that is initiating the callback.
 * @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.
 */
@Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
    // Ignore error due to stopLoading().
    if (!isCurrentlyLoading) {
        return;
    }
    LOG.d(TAG, "CordovaWebViewClient.onReceivedError: Error code=%s Description=%s URL=%s", errorCode, description, failingUrl);

    // If this is a "Protocol Not Supported" error, then revert to the previous
    // page. If there was no previous page, then punt. The application's config
    // is likely incorrect (start page set to sms: or something like that)
    if (errorCode == WebViewClient.ERROR_UNSUPPORTED_SCHEME) {
        parentEngine.client.clearLoadTimeoutTimer();

        if (view.canGoBack()) {
            view.goBack();
            return;
        } else {
            super.onReceivedError(view, errorCode, description, failingUrl);
        }
    }
    parentEngine.client.onReceivedError(errorCode, description, failingUrl);
}
 
源代码17 项目: phonegapbootcampsite   文件: InAppChromeClient.java
/**
 * Handle database quota exceeded notification.
 *
 * @param url
 * @param databaseIdentifier
 * @param currentQuota
 * @param estimatedSize
 * @param totalUsedQuota
 * @param quotaUpdater
 */
@Override
public void onExceededDatabaseQuota(String url, String databaseIdentifier, long currentQuota, long estimatedSize,
        long totalUsedQuota, AmazonWebStorage.QuotaUpdater quotaUpdater)
{
    LOG.d(LOG_TAG, "onExceededDatabaseQuota estimatedSize: %d  currentQuota: %d  totalUsedQuota: %d", estimatedSize, currentQuota, totalUsedQuota);

    if (estimatedSize < MAX_QUOTA)
    {
        //increase for 1Mb
        long newQuota = estimatedSize;
        LOG.d(LOG_TAG, "calling quotaUpdater.updateQuota newQuota: %d", newQuota);
        quotaUpdater.updateQuota(newQuota);
    }
    else
    {
        // Set the quota to whatever it is and force an error
        // TODO: get docs on how to handle this properly
        quotaUpdater.updateQuota(currentQuota);
    }
}
 
public void onPageFinished(WebView view, String url) {
    super.onPageFinished(view, url);

    // CB-10395 InAppBrowser's WebView not storing cookies reliable to local device storage
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
        CookieManager.getInstance().flush();
    } else {
        CookieSyncManager.getInstance().sync();
    }

    // https://issues.apache.org/jira/browse/CB-11248
    view.clearFocus();
    view.requestFocus();

    try {
        JSONObject obj = new JSONObject();
        obj.put("type", LOAD_STOP_EVENT);
        obj.put("url", url);

        sendUpdate(obj, true);
    } catch (JSONException ex) {
        LOG.d(LOG_TAG, "Should never happen");
    }
}
 
/**
 * 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 view          The WebView that is initiating the callback.
 * @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.
 */
@Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
    // Ignore error due to stopLoading().
    if (!isCurrentlyLoading) {
        return;
    }
    LOG.d(TAG, "CordovaWebViewClient.onReceivedError: Error code=%s Description=%s URL=%s", errorCode, description, failingUrl);

    // If this is a "Protocol Not Supported" error, then revert to the previous
    // page. If there was no previous page, then punt. The application's config
    // is likely incorrect (start page set to sms: or something like that)
    if (errorCode == WebViewClient.ERROR_UNSUPPORTED_SCHEME) {
        parentEngine.client.clearLoadTimeoutTimer();

        if (view.canGoBack()) {
            view.goBack();
            return;
        } else {
            super.onReceivedError(view, errorCode, description, failingUrl);
        }
    }
    parentEngine.client.onReceivedError(errorCode, description, failingUrl);
}
 
源代码20 项目: reader   文件: InAppChromeClient.java
/**
 * Handle database quota exceeded notification.
 *
 * @param url
 * @param databaseIdentifier
 * @param currentQuota
 * @param estimatedSize
 * @param totalUsedQuota
 * @param quotaUpdater
 */
@Override
public void onExceededDatabaseQuota(String url, String databaseIdentifier, long currentQuota, long estimatedSize,
        long totalUsedQuota, AmazonWebStorage.QuotaUpdater quotaUpdater)
{
    LOG.d(LOG_TAG, "onExceededDatabaseQuota estimatedSize: %d  currentQuota: %d  totalUsedQuota: %d", estimatedSize, currentQuota, totalUsedQuota);

    if (estimatedSize < MAX_QUOTA)
    {
        //increase for 1Mb
        long newQuota = estimatedSize;
        LOG.d(LOG_TAG, "calling quotaUpdater.updateQuota newQuota: %d", newQuota);
        quotaUpdater.updateQuota(newQuota);
    }
    else
    {
        // Set the quota to whatever it is and force an error
        // TODO: get docs on how to handle this properly
        quotaUpdater.updateQuota(currentQuota);
    }
}
 
源代码21 项目: jpHolo   文件: CameraLauncher.java
/**
 * Create entry in media store for image
 *
 * @return uri
 */
private Uri getUriFromMediaStore() {
    ContentValues values = new ContentValues();
    values.put(android.provider.MediaStore.Images.Media.MIME_TYPE, "image/jpeg");
    Uri uri;
    try {
        uri = this.cordova.getActivity().getContentResolver().insert(android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
    } catch (RuntimeException e) {
        LOG.d(LOG_TAG, "Can't write to external media storage.");
        try {
            uri = this.cordova.getActivity().getContentResolver().insert(android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI, values);
        } catch (RuntimeException ex) {
            LOG.d(LOG_TAG, "Can't write to internal media storage.");
            return null;
        }
    }
    return uri;
}
 
/**
 * 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 view          The WebView that is initiating the callback.
 * @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.
 */
@Override
public void onReceivedLoadError(XWalkView view, int errorCode, String description,
        String failingUrl) {
    LOG.d(TAG, "CordovaWebViewClient.onReceivedError: Error code=%s Description=%s URL=%s", errorCode, description, failingUrl);

    // Clear timeout flag
    this.appView.loadUrlTimeout++;

    // Handle error
    JSONObject data = new JSONObject();
    try {
        data.put("errorCode", errorCode);
        data.put("description", description);
        data.put("url", failingUrl);
    } catch (JSONException e) {
        e.printStackTrace();
    }
    this.appView.postMessage("onReceivedError", data);
}
 
源代码23 项目: x5webview-cordova-plugin   文件: X5WebViewClient.java
/**
 * 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 view          The WebView that is initiating the callback.
 * @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.
 */
@Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
    // Ignore error due to stopLoading().
    if (!isCurrentlyLoading) {
        return;
    }
    LOG.d(TAG, "CordovaWebViewClient.onReceivedError: Error code=%s Description=%s URL=%s", errorCode, description, failingUrl);

    // If this is a "Protocol Not Supported" error, then revert to the previous
    // page. If there was no previous page, then punt. The application's config
    // is likely incorrect (start page set to sms: or something like that)
    if (errorCode == WebViewClient.ERROR_UNSUPPORTED_SCHEME) {
        parentEngine.client.clearLoadTimeoutTimer();

        if (view.canGoBack()) {
            view.goBack();
            return;
        } else {
            super.onReceivedError(view, errorCode, description, failingUrl);
        }
    }
    parentEngine.client.onReceivedError(errorCode, description, failingUrl);
}
 
源代码24 项目: pychat   文件: SystemWebViewClient.java
/**
 * 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 view          The WebView that is initiating the callback.
 * @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.
 */
@Override
@SuppressWarnings("deprecation")
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
    // Ignore error due to stopLoading().
    if (!isCurrentlyLoading) {
        return;
    }
    LOG.d(TAG, "CordovaWebViewClient.onReceivedError: Error code=%s Description=%s URL=%s", errorCode, description, failingUrl);

    // If this is a "Protocol Not Supported" error, then revert to the previous
    // page. If there was no previous page, then punt. The application's config
    // is likely incorrect (start page set to sms: or something like that)
    if (errorCode == WebViewClient.ERROR_UNSUPPORTED_SCHEME) {
        parentEngine.client.clearLoadTimeoutTimer();

        if (view.canGoBack()) {
            view.goBack();
            return;
        } else {
            super.onReceivedError(view, errorCode, description, failingUrl);
        }
    }
    parentEngine.client.onReceivedError(errorCode, description, failingUrl);
}
 
源代码25 项目: keemob   文件: SystemWebViewClient.java
@Override
@SuppressWarnings("deprecation")
public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
    try {
        // Check the against the whitelist and lock out access to the WebView directory
        // Changing this will cause problems for your application
        if (!parentEngine.pluginManager.shouldAllowRequest(url)) {
            LOG.w(TAG, "URL blocked by whitelist: " + url);
            // Results in a 404.
            return new WebResourceResponse("text/plain", "UTF-8", null);
        }

        CordovaResourceApi resourceApi = parentEngine.resourceApi;
        Uri origUri = Uri.parse(url);
        // Allow plugins to intercept WebView requests.
        Uri remappedUri = resourceApi.remapUri(origUri);

        if (!origUri.equals(remappedUri) || needsSpecialsInAssetUrlFix(origUri) || needsKitKatContentUrlFix(origUri)) {
            CordovaResourceApi.OpenForReadResult result = resourceApi.openForRead(remappedUri, true);
            return new WebResourceResponse(result.mimeType, "UTF-8", result.inputStream);
        }
        // If we don't need to special-case the request, let the browser load it.
        return null;
    } catch (IOException e) {
        if (!(e instanceof FileNotFoundException)) {
            LOG.e(TAG, "Error occurred while loading a file (returning a 404).", e);
        }
        // Results in a 404.
        return new WebResourceResponse("text/plain", "UTF-8", null);
    }
}
 
源代码26 项目: wildfly-samples   文件: CordovaActivity.java
@Override
/**
 * Called when the system is about to start resuming a previous activity.
 */
protected void onPause() {
    super.onPause();

    LOG.d(TAG, "Paused the application!");

    // Don't process pause if shutting down, since onDestroy() will be called
    if (this.activityState == ACTIVITY_EXITING) {
        return;
    }

    if (this.appView == null) {
        return;
    }
    else
    {
        this.appView.handlePause(this.keepRunning);
    }

    // hide the splash screen to avoid leaking a window
    this.removeSplashScreen();
}
 
源代码27 项目: wildfly-samples   文件: CordovaActivity.java
@Override
/**
 * The final call you receive before your activity is destroyed.
 */
public void onDestroy() {
    LOG.d(TAG, "CordovaActivity.onDestroy()");
    super.onDestroy();

    // hide the splash screen to avoid leaking a window
    this.removeSplashScreen();

    if (this.appView != null) {
        appView.handleDestroy();
    }
    else {
        this.activityState = ACTIVITY_EXITING; 
    }
}
 
源代码28 项目: BigDataPlatform   文件: SystemWebViewEngine.java
@TargetApi(Build.VERSION_CODES.KITKAT)
private void enableRemoteDebugging() {
    try {
        WebView.setWebContentsDebuggingEnabled(true);
    } catch (IllegalArgumentException e) {
        LOG.d(TAG, "You have one job! To turn on Remote Web Debugging! YOU HAVE FAILED! ");
        e.printStackTrace();
    }
}
 
源代码29 项目: keemob   文件: SystemWebViewEngine.java
private void enableRemoteDebugging() {
    try {
        WebView.setWebContentsDebuggingEnabled(true);
    } catch (IllegalArgumentException e) {
        LOG.d(TAG, "You have one job! To turn on Remote Web Debugging! YOU HAVE FAILED! ");
        e.printStackTrace();
    }
}
 
源代码30 项目: BigDataPlatform   文件: SystemWebViewEngine.java
@Override
public void evaluateJavascript(String js, ValueCallback<String> callback) {
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        webView.evaluateJavascript(js, callback);
    }
    else
    {
        LOG.d(TAG, "This webview is using the old bridge");
    }
}
 
 类所在包