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

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

源代码1 项目: crosswalk-cordova-android   文件: CordovaPlugin.java
/**
 * Call this after constructing to initialize the plugin.
 * Final because we want to be able to change args without breaking plugins.
 */
public final void privateInitialize(CordovaInterface cordova, CordovaWebView webView, CordovaPreferences preferences) {
    assert this.cordova == null;
    this.cordova = cordova;
    this.webView = webView;
    this.preferences = preferences;
    initialize(cordova, webView);
    pluginInitialize();
    // File Transfer API implementation leverages the android.webkit.CookieManager.
    // But trying to getinstance() of CookieManager before the webview
    // instantiated would cause crash. In the cordova with xwalk backend,
    // there doesn't exist webview. From the android official document
    // (http://developer.android.com/reference/android/webkit/CookieManager.html),
    // it requires to call following API first.
    // TODO: add condition only for xwalk backend when dynamic switch is ready.
    CookieSyncManager.createInstance(cordova.getActivity());
}
 
@Override
public void initialize(CordovaInterface cordova, CordovaWebView webView) {
    super.initialize(cordova, webView);
    Log.d(TAG, "initialize()");

    // initialize sound SoundPoolManager
    SoundPoolManager.getInstance(cordova.getActivity());

    Context context = cordova.getActivity().getApplicationContext();
    audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);

    // Handle an incoming call intent if launched from a notification
    Intent intent = cordova.getActivity().getIntent();
    if (intent.getAction().equals(ACTION_INCOMING_CALL)) {
        mIncomingCallIntent = intent;
    }
}
 
源代码3 项目: cordova-hot-code-push   文件: HotCodePushPlugin.java
@Override
public void initialize(final CordovaInterface cordova, final CordovaWebView webView) {
    super.initialize(cordova, webView);

    parseCordovaConfigXml();
    loadPluginInternalPreferences();

    Log.d("CHCP", "Currently running release version " + pluginInternalPrefs.getCurrentReleaseVersionName());

    // clean up file system
    cleanupFileSystemFromOldReleases();

    handler = new Handler();
    fileStructure = new PluginFilesStructure(cordova.getActivity(), pluginInternalPrefs.getCurrentReleaseVersionName());
    appConfigStorage = new ApplicationConfigStorage();
    defaultCallbackStoredResults = new ArrayList<PluginResult>();
}
 
源代码4 项目: cordova-plugin-wizpurchase   文件: WizPurchase.java
@Override
public void initialize(CordovaInterface cordova, CordovaWebView webView) {
	Log.d(TAG, "initialising plugin");

	/* base64EncodedPublicKey should be YOUR APPLICATION'S PUBLIC KEY
	 * (that you got from the Google Play developer console). This is not your
	 * developer public key, it's the *app-specific* public key.
	 *
	 * Instead of just storing the entire literal string here embedded in the
	 * program,  construct the key at runtime from pieces or
	 * use bit manipulation (for example, XOR with some other string) to hide
	 * the actual key.  The key itself is not secret information, but we don't
	 * want to make it easy for an attacker to replace the public key with one
	 * of their own and then fake messages from the server.
	 */

	// Assign base64 encoded public key
	int billingKey = cordova.getActivity().getResources().getIdentifier("billing_key", "string", cordova.getActivity().getPackageName());
	mBase64EncodedPublicKey = cordova.getActivity().getString(billingKey);

	super.initialize(cordova, webView);
}
 
源代码5 项目: BigDataPlatform   文件: CordovaPlugin.java
/**
 * Call this after constructing to initialize the plugin.
 * Final because we want to be able to change args without breaking plugins.
 */
public final void privateInitialize(String serviceName, CordovaInterface cordova, CordovaWebView webView, CordovaPreferences preferences) {
    assert this.cordova == null;
    this.serviceName = serviceName;
    this.cordova = cordova;
    this.webView = webView;
    this.preferences = preferences;
    initialize(cordova, webView);
    pluginInitialize();
}
 
源代码6 项目: xmall   文件: CordovaPlugin.java
/**
 * Call this after constructing to initialize the plugin.
 * Final because we want to be able to change args without breaking plugins.
 */
public final void privateInitialize(String serviceName, CordovaInterface cordova, CordovaWebView webView, CordovaPreferences preferences) {
    assert this.cordova == null;
    this.serviceName = serviceName;
    this.cordova = cordova;
    this.webView = webView;
    this.preferences = preferences;
    initialize(cordova, webView);
    pluginInitialize();
}
 
源代码7 项目: app-icon   文件: CordovaPlugin.java
/**
 * Call this after constructing to initialize the plugin.
 * Final because we want to be able to change args without breaking plugins.
 */
public final void privateInitialize(String serviceName, CordovaInterface cordova, CordovaWebView webView, CordovaPreferences preferences) {
    assert this.cordova == null;
    this.serviceName = serviceName;
    this.cordova = cordova;
    this.webView = webView;
    this.preferences = preferences;
    initialize(cordova, webView);
    pluginInitialize();
}
 
源代码8 项目: reacteu-app   文件: StatusBar.java
/**
 * Sets the context of the Command. This can then be used to do things like
 * get file paths associated with the Activity.
 *
 * @param cordova The context of the main Activity.
 * @param webView The CordovaWebView Cordova is running in.
 */
@Override
public void initialize(final CordovaInterface cordova, CordovaWebView webView) {
    Log.v(TAG, "StatusBar: initialization");
    super.initialize(cordova, webView);

    this.cordova.getActivity().runOnUiThread(new Runnable() {
        @Override
        public void run() {
            // Clear flag FLAG_FORCE_NOT_FULLSCREEN which is set initially
            // by the Cordova.
            Window window = cordova.getActivity().getWindow();
            window.clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);

            // Read 'StatusBarBackgroundColor' from config.xml, default is #000000.
            setStatusBarBackgroundColor(preferences.getString("StatusBarBackgroundColor", "#000000"));
        }
    });
}
 
protected void setUp() throws Exception {
  super.setUp();
  testActivity = this.getActivity();
  containerView = (FrameLayout) testActivity.findViewById(android.R.id.content);
  innerContainer = (LinearLayout) containerView.getChildAt(0);
  testView = (CordovaWebView) innerContainer.getChildAt(0);
}
 
/**
 * Constructor.
 *
 * @param app
 * @param ctx
 */
public PluginManager(CordovaWebView app, CordovaInterface ctx) {
    this.ctx = ctx;
    this.app = app;
    this.firstRun = true;
    this.numPendingUiExecs = new AtomicInteger(0);
}
 
源代码11 项目: bluemix-parking-meter   文件: PluginManager.java
PluginManager(CordovaWebView cordovaWebView, CordovaInterface cordova, List<PluginEntry> pluginEntries) {
    this.ctx = cordova;
    this.app = cordovaWebView;
    if (pluginEntries == null) {
        ConfigXmlParser parser = new ConfigXmlParser();
        parser.parse(ctx.getActivity());
        pluginEntries = parser.getPluginEntries();
    }
    setPluginEntries(pluginEntries);
}
 
源代码12 项目: reader   文件: PluginManager.java
PluginManager(CordovaWebView cordovaWebView, CordovaInterface cordova, List<PluginEntry> pluginEntries) {
    this.ctx = cordova;
    this.app = cordovaWebView;
    if (pluginEntries == null) {
        ConfigXmlParser parser = new ConfigXmlParser();
        parser.parse(ctx.getActivity());
        pluginEntries = parser.getPluginEntries();
    }
    setPluginEntries(pluginEntries);
}
 
/** --------------------------------------------------------------- */

    public void initialize(CordovaInterface cordova, CordovaWebView webView) {
        cordovaWebView = webView;
        bannerLoaded = false;
        bannerShowing = false;
        super.initialize(cordova, webView);
    }
 
源代码14 项目: cordova-plugin-inappbrowser   文件: InAppBrowser.java
/**
 * Constructor.
 *
 * @param webView
 * @param mEditText
 */
public InAppBrowserClient(CordovaWebView webView, EditText mEditText, String beforeload) {
    this.webView = webView;
    this.edittext = mEditText;
    this.beforeload = beforeload;
    this.waitForBeforeload = beforeload != null;
}
 
源代码15 项目: countly-sdk-cordova   文件: SystemWebViewEngine.java
@Override
public void init(CordovaWebView parentWebView, CordovaInterface cordova, CordovaWebViewEngine.Client client,
          CordovaResourceApi resourceApi, PluginManager pluginManager,
          NativeToJsMessageQueue nativeToJsMessageQueue) {
    if (this.cordova != null) {
        throw new IllegalStateException();
    }
    // Needed when prefs are not passed by the constructor
    if (preferences == null) {
        preferences = parentWebView.getPreferences();
    }
    this.parentWebView = parentWebView;
    this.cordova = cordova;
    this.client = client;
    this.resourceApi = resourceApi;
    this.pluginManager = pluginManager;
    this.nativeToJsMessageQueue = nativeToJsMessageQueue;
    webView.init(this, cordova);

    initWebViewSettings();

    nativeToJsMessageQueue.addBridgeMode(new NativeToJsMessageQueue.OnlineEventsBridgeMode(new NativeToJsMessageQueue.OnlineEventsBridgeMode.OnlineEventsBridgeModeDelegate() {
        @Override
        public void setNetworkAvailable(boolean value) {
            //sometimes this can be called after calling webview.destroy() on destroy()
            //thus resulting in a NullPointerException
            if(webView!=null) {
               webView.setNetworkAvailable(value); 
            }
        }
        @Override
        public void runOnUiThread(Runnable r) {
            SystemWebViewEngine.this.cordova.getActivity().runOnUiThread(r);
        }
    }));
    nativeToJsMessageQueue.addBridgeMode(new NativeToJsMessageQueue.EvalBridgeMode(this, cordova));
    bridge = new CordovaBridge(pluginManager, nativeToJsMessageQueue);
    exposeJsInterface(webView, bridge);
}
 
源代码16 项目: crosswalk-cordova-android   文件: IFrameTest.java
protected void setUp() throws Exception {
  super.setUp();
  mInstr = this.getInstrumentation();
  testActivity = this.getActivity();
  containerView = (FrameLayout) testActivity.findViewById(android.R.id.content);
  innerContainer = (LinearLayout) containerView.getChildAt(0);
  testView = (CordovaWebView) innerContainer.getChildAt(0);
  touch = new TouchUtils();
  touchTool = new Purity(testActivity, getInstrumentation());
}
 
源代码17 项目: reader   文件: CordovaPlugin.java
/**
 * Call this after constructing to initialize the plugin.
 * Final because we want to be able to change args without breaking plugins.
 */
public final void privateInitialize(CordovaInterface cordova, CordovaWebView webView, CordovaPreferences preferences) {
    assert this.cordova == null;
    this.cordova = cordova;
    this.webView = webView;
    this.preferences = preferences;
    initialize(cordova, webView);
    pluginInitialize();
}
 
protected void setUp() throws Exception {
  super.setUp();
  testActivity = this.getActivity();
  containerView = (FrameLayout) testActivity.findViewById(android.R.id.content);
  innerContainer = (LinearLayout) containerView.getChildAt(0);
  testView = (CordovaWebView) innerContainer.getChildAt(0);
}
 
源代码19 项目: cordova-android-chromeview   文件: PluginManager.java
/**
 * Constructor.
 *
 * @param app
 * @param ctx
 */
public PluginManager(CordovaWebView app, CordovaInterface ctx) {
    this.ctx = ctx;
    this.app = app;
    this.firstRun = true;
    this.numPendingUiExecs = new AtomicInteger(0);
}
 
源代码20 项目: keemob   文件: CordovaPlugin.java
/**
 * Call this after constructing to initialize the plugin.
 * Final because we want to be able to change args without breaking plugins.
 */
public final void privateInitialize(String serviceName, CordovaInterface cordova, CordovaWebView webView, CordovaPreferences preferences) {
    assert this.cordova == null;
    this.serviceName = serviceName;
    this.cordova = cordova;
    this.webView = webView;
    this.preferences = preferences;
    initialize(cordova, webView);
    pluginInitialize();
}
 
源代码21 项目: cordova-plugin-uid   文件: UID.java
/**
 * Sets the context of the Command. This can then be used to do things like
 * get file paths associated with the Activity.
 *
 * @param cordova The context of the main Activity.
 * @param webView The CordovaWebView Cordova is running in.
 */
@Override
public void initialize(CordovaInterface cordova, CordovaWebView webView) {
	super.initialize(cordova, webView);
	Context context = cordova.getActivity().getApplicationContext();
	UID.uuid = getUuid(context);
	UID.imei = getImei(context);
	UID.imsi = getImsi(context);
	UID.iccid = getIccid(context);
	UID.mac = getMac(context);
}
 
源代码22 项目: keemob   文件: BackButtonMultipageTest.java
@Test
public void testViaHref() throws Throwable {
    final CordovaWebView webInterface = mActivity.getWebInterface();
    assertEquals(START_URL, mActivity.onPageFinishedUrl.take());

    mActivityRule.runOnUiThread(new Runnable() {
        public void run() {
            webInterface.sendJavascript("window.location = 'sample2.html';");
        }
    });
    assertEquals("file:///android_asset/www/backbuttonmultipage/sample2.html", mActivity.onPageFinishedUrl.take());
    mActivityRule.runOnUiThread(new Runnable() {
        public void run() {
            webInterface.sendJavascript("window.location = 'sample3.html';");
        }
    });
    assertEquals("file:///android_asset/www/backbuttonmultipage/sample3.html", mActivity.onPageFinishedUrl.take());
    mActivityRule.runOnUiThread(new Runnable() {
        public void run() {
            assertTrue(webInterface.backHistory());
        }
    });
    assertEquals("file:///android_asset/www/backbuttonmultipage/sample2.html", mActivity.onPageFinishedUrl.take());
    mActivityRule.runOnUiThread(new Runnable() {
        public void run() {
            assertTrue(webInterface.backHistory());
        }
    });
    assertEquals(START_URL, mActivity.onPageFinishedUrl.take());
    mActivityRule.runOnUiThread(new Runnable() {
        public void run() {
            assertFalse(webInterface.backHistory());
        }
    });
}
 
源代码23 项目: keemob   文件: StandardActivityTest.java
@Test
public void checkBackgroundIntentCheck() {
    StandardActivity activity = (StandardActivity) mActivityRule.getActivity();
    final SystemWebView webView = (SystemWebView) activity.getWindow().getCurrentFocus();
    CordovaWebView webInterface = webView.getCordovaWebView();
    CordovaPreferences prefs = webInterface.getPreferences();
    assertFalse(prefs.getInteger("backgroundcolor", Color.BLACK) == Color.GREEN);
}
 
源代码24 项目: cordova-plugin-admob-free   文件: BannerExecutor.java
private View getWebView() {
    CordovaWebView webView = plugin.webView;
    try {
        return (View) webView.getClass().getMethod("getView").invoke(webView);
    } catch (Exception e) {
        return (View) webView;
    }
}
 
源代码25 项目: IoTgo_Android_App   文件: WebSocket.java
@Override
public void initialize(CordovaInterface cordova, CordovaWebView webView) {
    super.initialize(cordova, webView);
    _factory = new WebSocketClientFactory();
    _conn = new SparseArray<Connection>();
    _create = new ConnectionTask(_factory, _conn);
    _send = new SendingTask(_conn);
    _close = new DisconnectionTask(_conn);
    try {
        start();
    } catch (Exception e) {
    }
}
 
源代码26 项目: keemob   文件: SystemWebViewEngine.java
@Override
public void init(CordovaWebView parentWebView, CordovaInterface cordova, CordovaWebViewEngine.Client client,
          CordovaResourceApi resourceApi, PluginManager pluginManager,
          NativeToJsMessageQueue nativeToJsMessageQueue) {
    if (this.cordova != null) {
        throw new IllegalStateException();
    }
    // Needed when prefs are not passed by the constructor
    if (preferences == null) {
        preferences = parentWebView.getPreferences();
    }
    this.parentWebView = parentWebView;
    this.cordova = cordova;
    this.client = client;
    this.resourceApi = resourceApi;
    this.pluginManager = pluginManager;
    this.nativeToJsMessageQueue = nativeToJsMessageQueue;
    webView.init(this, cordova);

    initWebViewSettings();

    nativeToJsMessageQueue.addBridgeMode(new NativeToJsMessageQueue.OnlineEventsBridgeMode(new NativeToJsMessageQueue.OnlineEventsBridgeMode.OnlineEventsBridgeModeDelegate() {
        @Override
        public void setNetworkAvailable(boolean value) {
            //sometimes this can be called after calling webview.destroy() on destroy()
            //thus resulting in a NullPointerException
            if(webView!=null) {
               webView.setNetworkAvailable(value); 
            }
        }
        @Override
        public void runOnUiThread(Runnable r) {
            SystemWebViewEngine.this.cordova.getActivity().runOnUiThread(r);
        }
    }));
    nativeToJsMessageQueue.addBridgeMode(new NativeToJsMessageQueue.EvalBridgeMode(this, cordova));
    bridge = new CordovaBridge(pluginManager, nativeToJsMessageQueue);
    exposeJsInterface(webView, bridge);
}
 
protected void setUp() throws Exception {
    super.setUp();
    mInstr = this.getInstrumentation();
    testActivity = this.getActivity();
    containerView = (FrameLayout) testActivity.findViewById(android.R.id.content);
    innerContainer = (LinearLayout) containerView.getChildAt(0);
    testView = (CordovaWebView) innerContainer.getChildAt(0);
    
}
 
源代码28 项目: cordova-plugin-x5-tbs   文件: X5WebViewEngine.java
@Override
public void init(CordovaWebView parentWebView, CordovaInterface cordova, Client client,
                 CordovaResourceApi resourceApi, PluginManager pluginManager,
                 NativeToJsMessageQueue nativeToJsMessageQueue) {
  if (this.cordova != null) {
    throw new IllegalStateException();
  }
  // Needed when prefs are not passed by the constructor
  if (preferences == null) {
    preferences = parentWebView.getPreferences();
  }
  this.parentWebView = parentWebView;
  this.cordova = cordova;
  this.client = client;
  this.resourceApi = resourceApi;
  this.pluginManager = pluginManager;
  this.nativeToJsMessageQueue = nativeToJsMessageQueue;
  webView.init(this, cordova);

  initWebViewSettings();

  nativeToJsMessageQueue.addBridgeMode(new NativeToJsMessageQueue.OnlineEventsBridgeMode(new NativeToJsMessageQueue.OnlineEventsBridgeMode.OnlineEventsBridgeModeDelegate() {
    @Override
    public void setNetworkAvailable(boolean value) {
      webView.setNetworkAvailable(value);
    }

    @Override
    public void runOnUiThread(Runnable r) {
      X5WebViewEngine.this.cordova.getActivity().runOnUiThread(r);
    }
  }));
  if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN_MR2)
    nativeToJsMessageQueue.addBridgeMode(new NativeToJsMessageQueue.EvalBridgeMode(this, cordova));
  bridge = new CordovaBridge(pluginManager, nativeToJsMessageQueue);
  exposeJsInterface(webView, bridge);
}
 
@Override
public CordovaWebView getCordovaWebView() {
    return parentEngine != null ? parentEngine.getCordovaWebView() : null;
}
 
源代码30 项目: reacteu-app   文件: InAppChromeClient.java
public InAppChromeClient(CordovaWebView webView) {
    super();
    this.webView = webView;
}