本文整理汇总了Java中org.apache.cordova.LOG.d方法的典型用法代码示例。如果您正苦于以下问题:Java LOG.d方法的具体用法?Java LOG.d怎么用?Java LOG.d使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.cordova.LOG
的用法示例。
在下文中一共展示了LOG.d方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getUriFromMediaStore
import org.apache.cordova.LOG; //导入方法依赖的package包/类
/**
* 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;
}
示例2: remove
import org.apache.cordova.LOG; //导入方法依赖的package包/类
@Override
/**
* This method will remove a Contact from the database based on ID.
* @param id the unique ID of the contact to remove
*/
public boolean remove(String id) {
int result = 0;
Cursor cursor = mApp.getActivity().getContentResolver().query(ContactsContract.Contacts.CONTENT_URI,
null,
ContactsContract.Contacts._ID + " = ?",
new String[] { id }, null);
if (cursor.getCount() == 1) {
cursor.moveToFirst();
String lookupKey = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.LOOKUP_KEY));
Uri uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_LOOKUP_URI, lookupKey);
result = mApp.getActivity().getContentResolver().delete(uri, null, null);
} else {
LOG.d(LOG_TAG, "Could not find contact with ID");
}
return (result > 0) ? true : false;
}
示例3: onExceededDatabaseQuota
import org.apache.cordova.LOG; //导入方法依赖的package包/类
/**
* 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);
}
}
示例4: onReceivedError
import org.apache.cordova.LOG; //导入方法依赖的package包/类
/**
* 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);
}
示例5: stopRecording
import org.apache.cordova.LOG; //导入方法依赖的package包/类
/**
* Stop/Pause recording and save to the file specified when recording started.
*/
public void stopRecording(boolean stop) {
if (this.recorder != null) {
try{
if (this.state == STATE.MEDIA_RUNNING) {
this.recorder.stop();
}
this.recorder.reset();
if (!this.tempFiles.contains(this.tempFile)) {
this.tempFiles.add(this.tempFile);
}
if (stop) {
LOG.d(LOG_TAG, "stopping recording");
this.setState(STATE.MEDIA_STOPPED);
this.moveFile(this.audioFile);
} else {
LOG.d(LOG_TAG, "pause recording");
this.setState(STATE.MEDIA_PAUSED);
}
}
catch (Exception e) {
e.printStackTrace();
}
}
}
示例6: requestPermissions
import org.apache.cordova.LOG; //导入方法依赖的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);
}
}
示例7: requestAllPaths
import org.apache.cordova.LOG; //导入方法依赖的package包/类
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;
}
示例8: execute
import org.apache.cordova.LOG; //导入方法依赖的package包/类
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
LOG.d(TAG, "We are entering execute");
context = callbackContext;
if(action.equals("getPermission"))
{
if(hasPermisssion())
{
PluginResult r = new PluginResult(PluginResult.Status.OK);
context.sendPluginResult(r);
return true;
}
else {
PermissionHelper.requestPermissions(this, 0, permissions);
}
return true;
}
return false;
}
示例9: addWhiteListEntry
import org.apache.cordova.LOG; //导入方法依赖的package包/类
public void addWhiteListEntry(String origin, boolean subdomains) {
if (whiteList != null) {
try {
// Unlimited access to network resources
if (origin.compareTo("*") == 0) {
LOG.d(TAG, "Unlimited access to network resources");
whiteList = null;
}
else { // specific access
Pattern parts = Pattern.compile("^((\\*|[A-Za-z-]+):(//)?)?(\\*|((\\*\\.)?[^*/:]+))?(:(\\d+))?(/.*)?");
Matcher m = parts.matcher(origin);
if (m.matches()) {
String scheme = m.group(2);
String host = m.group(4);
// Special case for two urls which are allowed to have empty hosts
if (("file".equals(scheme) || "content".equals(scheme)) && host == null) host = "*";
String port = m.group(8);
String path = m.group(9);
if (scheme == null) {
// XXX making it stupid friendly for people who forget to include protocol/SSL
whiteList.add(new URLPattern("http", host, port, path));
whiteList.add(new URLPattern("https", host, port, path));
} else {
whiteList.add(new URLPattern(scheme, host, port, path));
}
}
}
} catch (Exception e) {
LOG.d(TAG, "Failed to add origin %s", origin);
}
}
}
示例10: onExceededDatabaseQuota
import org.apache.cordova.LOG; //导入方法依赖的package包/类
/**
* Handle database quota exceeded notification.
*/
@Override
public void onExceededDatabaseQuota(String url, String databaseIdentifier, long currentQuota, long estimatedSize,
long totalUsedQuota, WebStorage.QuotaUpdater quotaUpdater)
{
LOG.d(LOG_TAG, "onExceededDatabaseQuota estimatedSize: %d currentQuota: %d totalUsedQuota: %d", estimatedSize, currentQuota, totalUsedQuota);
quotaUpdater.updateQuota(MAX_QUOTA);
}
示例11: getPathFromUri
import org.apache.cordova.LOG; //导入方法依赖的package包/类
/**
* Get an input stream based on file path or uri content://, http://, file://
*
* @param path path to file
* @return an input stream
* @throws IOException
*/
private InputStream getPathFromUri(String path) throws IOException {
if (path.startsWith("data:")) { // data:image/png;base64,[ENCODED_IMAGE]
String dataInfos = path.substring(0, path.indexOf(','));
dataInfos = dataInfos.substring(dataInfos.indexOf(':') + 1);
String baseEncoding = dataInfos.substring(dataInfos.indexOf(';') + 1);
// [ENCODED_IMAGE]
if("base64".equalsIgnoreCase(baseEncoding)) {
String img = path.substring(path.indexOf(',') + 1);
byte[] encodedData = img.getBytes();
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(encodedData, 0, encodedData.length);
Base64InputStream base64InputStream = new Base64InputStream(byteArrayInputStream, Base64.DEFAULT);
return base64InputStream;
} else {
LOG.d(LOG_TAG, "Could not decode image. The found base encoding is " + baseEncoding);
}
}
if (path.startsWith("content:")) {
Uri uri = Uri.parse(path);
return mApp.getActivity().getContentResolver().openInputStream(uri);
}
if (path.startsWith(ASSET_URL_PREFIX)) {
String assetRelativePath = path.replace(ASSET_URL_PREFIX, "");
return mApp.getActivity().getAssets().open(assetRelativePath);
}
if (path.startsWith("http:") || path.startsWith("https:") || path.startsWith("file:")) {
URL url = new URL(path);
return url.openStream();
}
return new FileInputStream(path);
}
示例12: getConnectionInfo
import org.apache.cordova.LOG; //导入方法依赖的package包/类
/**
* Get the latest network connection information
*
* @param info the current active network info
* @return a JSONObject that represents the network info
*/
private JSONObject getConnectionInfo(NetworkInfo info) {
String type = TYPE_NONE;
String extraInfo = "";
if (info != null) {
// If we are not connected to any network set type to none
if (!info.isConnected()) {
type = TYPE_NONE;
}
else {
type = getType(info);
}
extraInfo = info.getExtraInfo();
}
LOG.d(LOG_TAG, "Connection Type: " + type);
LOG.d(LOG_TAG, "Connection Extra Info: " + extraInfo);
JSONObject connectionInfo = new JSONObject();
try {
connectionInfo.put("type", type);
connectionInfo.put("extraInfo", extraInfo);
} catch (JSONException e) {
LOG.d(LOG_TAG, e.getLocalizedMessage());
}
return connectionInfo;
}
示例13: enableRemoteDebugging
import org.apache.cordova.LOG; //导入方法依赖的package包/类
@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();
}
}
示例14: queueCommand
import org.apache.cordova.LOG; //导入方法依赖的package包/类
private void queueCommand(BLECommand command) {
LOG.d(TAG,"Queuing Command " + command);
commandQueue.add(command);
PluginResult result = new PluginResult(PluginResult.Status.NO_RESULT);
result.setKeepCallback(true);
command.getCallbackContext().sendPluginResult(result);
if (!bleProcessing) {
processCommands();
}
}
示例15: onActivityResult
import org.apache.cordova.LOG; //导入方法依赖的package包/类
/**
* Receive File Data from File Chooser
*
* @param requestCode the requested code from chromeclient
* @param resultCode the result code returned from android system
* @param intent the data from android file chooser
*/
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
// For Android >= 5.0
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
LOG.d(LOG_TAG, "onActivityResult (For Android >= 5.0)");
// If RequestCode or Callback is Invalid
if(requestCode != FILECHOOSER_REQUESTCODE_LOLLIPOP || mUploadCallbackLollipop == null) {
super.onActivityResult(requestCode, resultCode, intent);
return;
}
mUploadCallbackLollipop.onReceiveValue(WebChromeClient.FileChooserParams.parseResult(resultCode, intent));
mUploadCallbackLollipop = null;
}
// For Android < 5.0
else {
LOG.d(LOG_TAG, "onActivityResult (For Android < 5.0)");
// If RequestCode or Callback is Invalid
if(requestCode != FILECHOOSER_REQUESTCODE || mUploadCallback == null) {
super.onActivityResult(requestCode, resultCode, intent);
return;
}
if (null == mUploadCallback) return;
Uri result = intent == null || resultCode != cordova.getActivity().RESULT_OK ? null : intent.getData();
mUploadCallback.onReceiveValue(result);
mUploadCallback = null;
}
}