Example usage for org.apache.cordova CordovaWebView getContext

List of usage examples for org.apache.cordova CordovaWebView getContext

Introduction

In this page you can find the example usage for org.apache.cordova CordovaWebView getContext.

Prototype

Context getContext();

Source Link

Usage

From source file:android.WeChat.java

License:Open Source License

@Override
public void initialize(CordovaInterface cordova, CordovaWebView webView) {
    String appId = preferences.getString(WECHAT_APPID_KEY, "");
    api = WXAPIFactory.createWXAPI(webView.getContext(), appId, true);
    api.registerApp(appId);/*from   w  ww .java 2s .c o  m*/
}

From source file:com.example.testplayer.NetworkManager.java

License:Apache License

/**
 * 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.
 *//*w  ww  . ja v  a2 s  .  c o  m*/
public void initialize(CordovaInterface cordova, CordovaWebView webView) {
    super.initialize(cordova, webView);
    this.sockMan = (ConnectivityManager) cordova.getActivity().getSystemService(Context.CONNECTIVITY_SERVICE);
    this.connectionCallbackContext = null;

    // We need to listen to connectivity events to update navigator.connection
    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
    if (this.receiver == null) {
        this.receiver = new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                // (The null check is for the ARM Emulator, please use Intel Emulator for better results)
                if (NetworkManager.this.webView != null)
                    updateConnectionInfo(sockMan.getActiveNetworkInfo());
            }
        };
        webView.getContext().registerReceiver(this.receiver, intentFilter);
    }

}

From source file:com.ionicsdk.discovery.Discovery.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.
 *//*from www .  java 2s  .  c o m*/
public void initialize(CordovaInterface cordova, CordovaWebView webView) {
    super.initialize(cordova, webView);

    Log.d(TAG, "Discovery plugin initializing");

    mContext = webView.getContext();

    /*
    NsdServiceInfo serviceInfo  = new NsdServiceInfo();
    serviceInfo.setServiceName("NsdChat");
    serviceInfo.setServiceType("_http._tcp.");
    serviceInfo.setPort();
    */

    //mNsdManager = (NsdManager) webView.getContext().getSystemService(Context.NSD_SERVICE);

    /*
    mNsdManager.registerService(
        serviceInfo, NsdManager.PROTOCOL_DNS_SD, mRegistrationListener);
    */

    //initializeDiscoveryListener();
    //mNsdManager.discoverServices(SERVICE_TYPE, NsdManager.PROTOCOL_DNS_SD, mDiscoveryListener);
}

From source file:com.lexiscn.balabala.Echo.java

License:Apache License

@Override
public void initialize(CordovaInterface cordova, CordovaWebView webView) {
    super.initialize(cordova, webView);
    // your init code here
    tst = Toast.makeText(webView.getContext(), "This is a toast.", Toast.LENGTH_SHORT);

    toast("initialize");
    println("initialize");

    SpeechUtility.createUtility(this.webView.getContext(), SpeechConstant.APPID + "=" + iflytekAPPID);
}

From source file:de.zertapps.dvhma.plugins.storage.DVHMAStorage.java

License:Apache License

@Override
public void initialize(CordovaInterface cordova, CordovaWebView webView) {
    super.initialize(cordova, webView);

    mDbHelper = new DVHMAStorageDbHelper(webView.getContext());
}

From source file:labs.marsala.trackinfo.CurrentlyPlaying.java

License:Apache License

/**
 * 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.
 *//*  ww w .j a  v  a  2 s . c  o m*/
public void initialize(CordovaInterface cordova, CordovaWebView webView) {
    super.initialize(cordova, webView);
    this.musicCallbackContext = null;

    // We need to listen to connectivity events to update navigator.connection
    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction("com.android.music.metachanged");
    intentFilter.addAction("com.android.music.playstatechanged");
    intentFilter.addAction("com.android.music.playbackcomplete");
    intentFilter.addAction("com.android.music.queuechanged");

    if (this.receiver == null) {
        this.receiver = new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                String artist = intent.getStringExtra("artist");
                String album = intent.getStringExtra("album");
                String track = intent.getStringExtra("track");
                String musicInfo = artist + " - " + track;

                // (The null check is for the ARM Emulator, please use Intel Emulator for better results)
                if (CurrentlyPlaying.this.webView != null)
                    sendUpdate(musicInfo);
            }
        };
        webView.getContext().registerReceiver(this.receiver, intentFilter);
    }

}