當前位置: 首頁>>代碼示例>>Java>>正文


Java CordovaInterface類代碼示例

本文整理匯總了Java中org.apache.cordova.CordovaInterface的典型用法代碼示例。如果您正苦於以下問題:Java CordovaInterface類的具體用法?Java CordovaInterface怎麽用?Java CordovaInterface使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


CordovaInterface類屬於org.apache.cordova包,在下文中一共展示了CordovaInterface類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: activityStart

import org.apache.cordova.CordovaInterface; //導入依賴的package包/類
/**
 * Show the spinner.
 *
 * @param title     Title of the dialog
 * @param message   The message of the dialog
 */
public synchronized void activityStart(final String title, final String message) {
    if (this.spinnerDialog != null) {
        this.spinnerDialog.dismiss();
        this.spinnerDialog = null;
    }
    final Notification notification = this;
    final CordovaInterface cordova = this.cordova;
    Runnable runnable = new Runnable() {
        public void run() {
            notification.spinnerDialog = createProgressDialog(cordova); // new ProgressDialog(cordova.getActivity(), AlertDialog.THEME_DEVICE_DEFAULT_LIGHT);
            notification.spinnerDialog.setTitle(title);
            notification.spinnerDialog.setMessage(message);
            notification.spinnerDialog.setCancelable(true);
            notification.spinnerDialog.setIndeterminate(true);
            notification.spinnerDialog.setOnCancelListener(
                    new DialogInterface.OnCancelListener() {
                        public void onCancel(DialogInterface dialog) {
                            notification.spinnerDialog = null;
                        }
                    });
            notification.spinnerDialog.show();
        }
    };
    this.cordova.getActivity().runOnUiThread(runnable);
}
 
開發者ID:Andy-Ta,項目名稱:COB,代碼行數:32,代碼來源:Notification.java

示例2: requestPermissions

import org.apache.cordova.CordovaInterface; //導入依賴的package包/類
/**
 * 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);
    }
}
 
開發者ID:Andy-Ta,項目名稱:COB,代碼行數:32,代碼來源:PermissionHelper.java

示例3: initialize

import org.apache.cordova.CordovaInterface; //導入依賴的package包/類
@Override
public void initialize(CordovaInterface cordova, CordovaWebView webView) {
    cordovaInterface = cordova;
    super.initialize(cordova, webView);
    appName = getApplicationName(this.cordova.getActivity().getApplicationContext());
    handle = new PhoneAccountHandle(new ComponentName(this.cordova.getActivity().getApplicationContext(),MyConnectionService.class),appName);
    tm = (TelecomManager)this.cordova.getActivity().getApplicationContext().getSystemService(this.cordova.getActivity().getApplicationContext().TELECOM_SERVICE);
    phoneAccount = new PhoneAccount.Builder(handle, appName)
            .setCapabilities(PhoneAccount.CAPABILITY_CALL_PROVIDER)
            .build();
    callbackContextMap.put("answer",new ArrayList<CallbackContext>());
    callbackContextMap.put("reject",new ArrayList<CallbackContext>());
    callbackContextMap.put("hangup",new ArrayList<CallbackContext>());
    callbackContextMap.put("sendCall",new ArrayList<CallbackContext>());
    callbackContextMap.put("receiveCall",new ArrayList<CallbackContext>());
}
 
開發者ID:WebsiteBeaver,項目名稱:CordovaCall,代碼行數:17,代碼來源:CordovaCall.java

示例4: getRealPath

import org.apache.cordova.CordovaInterface; //導入依賴的package包/類
/**
 * 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;
}
 
開發者ID:aabognah,項目名稱:LoRaWAN-Smart-Parking,代碼行數:34,代碼來源:FileHelper.java

示例5: NetworkLocationController

import org.apache.cordova.CordovaInterface; //導入依賴的package包/類
public NetworkLocationController(
        CordovaInterface cordova,
        CallbackContext callbackContext,
        long minDistance,
        long minTime,
        boolean returnCache,
        boolean buffer,
        int bufferSize
){
    _cordova = cordova;
    _callbackContext = callbackContext;
    _minDistance = minDistance;
    _minTime = minTime;
    _returnCache = returnCache;
    _buffer = buffer;
    _bufferSize = bufferSize;
}
 
開發者ID:SUTFutureCoder,項目名稱:localcloud_fe,代碼行數:18,代碼來源:NetworkLocationController.java

示例6: initialize

import org.apache.cordova.CordovaInterface; //導入依賴的package包/類
/**
 * 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.
 */
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);
    }

}
 
開發者ID:disit,項目名稱:siiMobilityAppKit,代碼行數:29,代碼來源:NetworkManager.java

示例7: execute

import org.apache.cordova.CordovaInterface; //導入依賴的package包/類
/**
 * Executes the request.
 *
 * @param action  The action to execute.
 * @param cordova The cordova interface.
 * @param webView The cordova web view.
 */
static void execute(String action, CordovaInterface cordova,
                    CordovaWebView webView) {

    BackgroundExt ext = new BackgroundExt(cordova, webView);

    if (action.equalsIgnoreCase("optimizations")) {
        ext.disableWebViewOptimizations();
    }

    if (action.equalsIgnoreCase("background")) {
        ext.moveToBackground();
    }

    if (action.equalsIgnoreCase("foreground")) {
        ext.moveToForeground();
    }

    if (action.equalsIgnoreCase("tasklist")) {
        ext.excludeFromTaskList();
    }
}
 
開發者ID:SUTFutureCoder,項目名稱:localcloud_fe,代碼行數:29,代碼來源:BackgroundExt.java

示例8: GPSController

import org.apache.cordova.CordovaInterface; //導入依賴的package包/類
public GPSController(
        CordovaInterface cordova,
        CallbackContext callbackContext,
        long minDistance,
        long minTime,
        boolean returnCache,
        boolean returnSatelliteData,
        boolean buffer,
        int bufferSize
){
    _cordova = cordova;
    _callbackContext = callbackContext;
    _minDistance = minDistance;
    _minTime = minTime;
    _returnCache = returnCache;
    _returnSatelliteData = returnSatelliteData;
    _buffer = buffer;
    _bufferSize = bufferSize;
}
 
開發者ID:SUTFutureCoder,項目名稱:localcloud_fe,代碼行數:20,代碼來源:GPSController.java

示例9: privateInitialize

import org.apache.cordova.CordovaInterface; //導入依賴的package包/類
/**
 * 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();
}
 
開發者ID:SUTFutureCoder,項目名稱:localcloud_fe,代碼行數:14,代碼來源:CordovaPlugin.java

示例10: initialize

import org.apache.cordova.CordovaInterface; //導入依賴的package包/類
@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>();
}
 
開發者ID:SUTFutureCoder,項目名稱:localcloud_fe,代碼行數:18,代碼來源:HotCodePushPlugin.java

示例11: getRealPath

import org.apache.cordova.CordovaInterface; //導入依賴的package包/類
/**
 * 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(Uri uri, CordovaInterface cordova) {
    String realPath = null;

    if (Build.VERSION.SDK_INT < 11)
        realPath = FileHelper.getRealPathFromURI_BelowAPI11(cordova.getActivity(), uri);

    // SDK >= 11
    else
        realPath = FileHelper.getRealPathFromURI_API11_And_Above(cordova.getActivity(), uri);

    return realPath;
}
 
開發者ID:Andy-Ta,項目名稱:COB,代碼行數:22,代碼來源:FileHelper.java

示例12: progressStart

import org.apache.cordova.CordovaInterface; //導入依賴的package包/類
/**
 * Show the progress dialog.
 *
 * @param title     Title of the dialog
 * @param message   The message of the dialog
 */
public synchronized void progressStart(final String title, final String message) {
    if (this.progressDialog != null) {
        this.progressDialog.dismiss();
        this.progressDialog = null;
    }
    final Notification notification = this;
    final CordovaInterface cordova = this.cordova;
    Runnable runnable = new Runnable() {
        public void run() {
            notification.progressDialog = createProgressDialog(cordova); // new ProgressDialog(cordova.getActivity(), AlertDialog.THEME_DEVICE_DEFAULT_LIGHT);
            notification.progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
            notification.progressDialog.setTitle(title);
            notification.progressDialog.setMessage(message);
            notification.progressDialog.setCancelable(true);
            notification.progressDialog.setMax(100);
            notification.progressDialog.setProgress(0);
            notification.progressDialog.setOnCancelListener(
                    new DialogInterface.OnCancelListener() {
                        public void onCancel(DialogInterface dialog) {
                            notification.progressDialog = null;
                        }
                    });
            notification.progressDialog.show();
        }
    };
    this.cordova.getActivity().runOnUiThread(runnable);
}
 
開發者ID:disit,項目名稱:siiMobilityAppKit,代碼行數:34,代碼來源:Notification.java

示例13: getMimeType

import org.apache.cordova.CordovaInterface; //導入依賴的package包/類
/**
 * Returns the mime type of the data specified by the given URI string.
 *
 * @param uriString the URI string of the data
 * @return the mime type of the specified data
 */
public static String getMimeType(String uriString, CordovaInterface cordova) {
    String mimeType = null;

    Uri uri = Uri.parse(uriString);
    if (uriString.startsWith("content://")) {
        mimeType = cordova.getActivity().getContentResolver().getType(uri);
    } else {
        mimeType = getMimeTypeForExtension(uri.getPath());
    }

    return mimeType;
}
 
開發者ID:Andy-Ta,項目名稱:COB,代碼行數:19,代碼來源:FileHelper.java

示例14: initialize

import org.apache.cordova.CordovaInterface; //導入依賴的package包/類
@Override
public void initialize(final CordovaInterface cordova, final CordovaWebView webView) {
    Log.v(TAG, "Init");
    this.webView = super.webView;
    this.cordovaInstance = super.cordova;
    this.context = cordovaInstance.getActivity().getApplicationContext();
    this.internalStorage = this.context.getFilesDir();
    this.externalStorage = new File(Environment.getExternalStorageDirectory() +
            File.separator + EXTERNAL_STORAGE_FOLDER);
}
 
開發者ID:kolbasa,項目名稱:cordova-logcat-filelogger,代碼行數:11,代碼來源:LogCatPlugin.java

示例15: createProgressDialog

import org.apache.cordova.CordovaInterface; //導入依賴的package包/類
@SuppressLint("InlinedApi")
private ProgressDialog createProgressDialog(CordovaInterface cordova) {
    int currentapiVersion = android.os.Build.VERSION.SDK_INT;
    if (currentapiVersion >= android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        return new ProgressDialog(cordova.getActivity(), AlertDialog.THEME_DEVICE_DEFAULT_LIGHT);
    } else {
        return new ProgressDialog(cordova.getActivity());
    }
}
 
開發者ID:Andy-Ta,項目名稱:COB,代碼行數:10,代碼來源:Notification.java


注:本文中的org.apache.cordova.CordovaInterface類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。