本文整理汇总了Java中org.apache.cordova.LOG.e方法的典型用法代码示例。如果您正苦于以下问题:Java LOG.e方法的具体用法?Java LOG.e怎么用?Java LOG.e使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.cordova.LOG
的用法示例。
在下文中一共展示了LOG.e方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setAudioOutputDevice
import org.apache.cordova.LOG; //导入方法依赖的package包/类
/**
* Set the audio device to be used for playback.
*
* @param output 1=earpiece, 2=speaker
*/
@SuppressWarnings("deprecation")
public void setAudioOutputDevice(int output) {
String TAG1 = "AudioHandler.setAudioOutputDevice(): Error : ";
AudioManager audiMgr = (AudioManager) this.cordova.getActivity().getSystemService(Context.AUDIO_SERVICE);
if (output == 2) {
audiMgr.setRouting(AudioManager.MODE_NORMAL, AudioManager.ROUTE_SPEAKER, AudioManager.ROUTE_ALL);
}
else if (output == 1) {
audiMgr.setRouting(AudioManager.MODE_NORMAL, AudioManager.ROUTE_EARPIECE, AudioManager.ROUTE_ALL);
}
else {
LOG.e(TAG1," Unknown output device");
}
}
示例2: deliverPermissionResult
import org.apache.cordova.LOG; //导入方法依赖的package包/类
private static void deliverPermissionResult(CordovaPlugin plugin, int requestCode, String[] permissions) {
// Generate the request results
int[] requestResults = new int[permissions.length];
Arrays.fill(requestResults, PackageManager.PERMISSION_GRANTED);
try {
Method onRequestPermissionResult = CordovaPlugin.class.getDeclaredMethod(
"onRequestPermissionResult", int.class, String[].class, int[].class);
onRequestPermissionResult.invoke(plugin, requestCode, permissions, requestResults);
} catch (NoSuchMethodException noSuchMethodException) {
// Should never be caught since the plugin must be written for cordova-android 5.0.0+ if it
// made it to this point
LOG.e(LOG_TAG, "NoSuchMethodException when delivering permissions results", noSuchMethodException);
} catch (IllegalAccessException illegalAccessException) {
// Should never be caught; this is a public method
LOG.e(LOG_TAG, "IllegalAccessException when delivering permissions results", illegalAccessException);
} catch(InvocationTargetException invocationTargetException) {
// This method may throw a JSONException. We are just duplicating cordova-android's
// exception handling behavior here; all it does is log the exception in CordovaActivity,
// print the stacktrace, and ignore it
LOG.e(LOG_TAG, "InvocationTargetException when delivering permissions results", invocationTargetException);
}
}
示例3: 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);
}
}
示例4: getRealPath
import org.apache.cordova.LOG; //导入方法依赖的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;
}
示例5: onMediaScannerConnected
import org.apache.cordova.LOG; //导入方法依赖的package包/类
public void onMediaScannerConnected() {
try {
this.conn.scanFile(this.scanMe.toString(), "image/*");
} catch (java.lang.IllegalStateException e) {
LOG.e(LOG_TAG, "Can't scan file in MediaScanner after taking picture");
}
}
示例6: onActivityResult
import org.apache.cordova.LOG; //导入方法依赖的package包/类
/**
* Called when user picks contact.
* @param requestCode The request code originally supplied to startActivityForResult(),
* allowing you to identify who this result came from.
* @param resultCode The integer result code returned by the child activity through its setResult().
* @param intent An Intent, which can return result data to the caller (various data can be attached to Intent "extras").
* @throws JSONException
*/
public void onActivityResult(int requestCode, int resultCode, final Intent intent) {
if (requestCode == CONTACT_PICKER_RESULT) {
if (resultCode == Activity.RESULT_OK) {
String contactId = intent.getData().getLastPathSegment();
// to populate contact data we require Raw Contact ID
// so we do look up for contact raw id first
Cursor c = this.cordova.getActivity().getContentResolver().query(RawContacts.CONTENT_URI,
new String[] {RawContacts._ID}, RawContacts.CONTACT_ID + " = " + contactId, null, null);
if (!c.moveToFirst()) {
this.callbackContext.error("Error occured while retrieving contact raw id");
return;
}
String id = c.getString(c.getColumnIndex(RawContacts._ID));
c.close();
try {
JSONObject contact = contactAccessor.getContactById(id);
this.callbackContext.success(contact);
return;
} catch (JSONException e) {
LOG.e(LOG_TAG, "JSON fail.", e);
}
} else if (resultCode == Activity.RESULT_CANCELED) {
callbackContext.error(OPERATION_CANCELLED_ERROR);
return;
}
this.callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.ERROR, UNKNOWN_ERROR));
}
}
示例7: shouldInterceptRequest
import org.apache.cordova.LOG; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override
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);
}
}
示例8: parse
import org.apache.cordova.LOG; //导入方法依赖的package包/类
public void parse(Activity action) {
// First checking the class namespace for config.xml
int id = action.getResources().getIdentifier("config", "xml", action.getClass().getPackage().getName());
if (id == 0) {
// If we couldn't find config.xml there, we'll look in the namespace from AndroidManifest.xml
id = action.getResources().getIdentifier("config", "xml", action.getPackageName());
if (id == 0) {
LOG.e(TAG, "res/xml/config.xml is missing!");
return;
}
}
parse(action.getResources().getXml(id));
}
示例9: destroy
import org.apache.cordova.LOG; //导入方法依赖的package包/类
@Override
public void destroy() {
webView.chromeClient.destroyLastDialog();
webView.destroy();
// unregister the receiver
if (receiver != null) {
try {
webView.getContext().unregisterReceiver(receiver);
} catch (Exception e) {
LOG.e(TAG, "Error unregistering configuration receiver: " + e.getMessage(), e);
}
}
}
示例10: onDestroy
import org.apache.cordova.LOG; //导入方法依赖的package包/类
/**
* Stop network receiver.
*/
public void onDestroy() {
if (this.receiver != null) {
try {
webView.getContext().unregisterReceiver(this.receiver);
} catch (Exception e) {
LOG.e(LOG_TAG, "Error unregistering network receiver: " + e.getMessage(), e);
} finally {
receiver = null;
}
}
}
示例11: removeStateListener
import org.apache.cordova.LOG; //导入方法依赖的package包/类
private void removeStateListener() {
if (this.stateReceiver != null) {
try {
webView.getContext().unregisterReceiver(this.stateReceiver);
} catch (Exception e) {
LOG.e(TAG, "Error unregistering state receiver: " + e.getMessage(), e);
}
}
this.stateCallback = null;
this.stateReceiver = null;
}
示例12: onServicesDiscovered
import org.apache.cordova.LOG; //导入方法依赖的package包/类
@Override
public void onServicesDiscovered(BluetoothGatt gatt, int status) {
super.onServicesDiscovered(gatt, status);
if (status == BluetoothGatt.GATT_SUCCESS) {
PluginResult result = new PluginResult(PluginResult.Status.OK, this.asJSONObject(gatt));
result.setKeepCallback(true);
connectCallback.sendPluginResult(result);
} else {
LOG.e(TAG, "Service discovery failed. status = " + status);
connectCallback.error(this.asJSONObject("Service discovery failed"));
disconnect();
}
}
示例13: shouldInterceptRequest
import org.apache.cordova.LOG; //导入方法依赖的package包/类
@Override
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 (isUrlHarmful(url)) {
LOG.w(TAG, "URL blocked by whitelist: " + url);
// Results in a 404.
return new WebResourceResponse("text/plain", "UTF-8", null);
}
CordovaResourceApi resourceApi = appView.getResourceApi();
Uri origUri = Uri.parse(url);
// Allow plugins to intercept WebView requests.
Uri remappedUri = resourceApi.remapUri(origUri);
if (!origUri.equals(remappedUri) || needsSpecialsInAssetUrlFix(origUri) || needsKitKatContentUrlFix(origUri)) {
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("IceCreamCordovaWebViewClient", "Error occurred while loading a file (returning a 404).", e);
}
// Results in a 404.
return new WebResourceResponse("text/plain", "UTF-8", null);
}
}
示例14: populateContact
import org.apache.cordova.LOG; //导入方法依赖的package包/类
/**
* Create a new contact using a JSONObject to hold all the data.
* @param contact
* @param organizations array of organizations
* @param addresses array of addresses
* @param phones array of phones
* @param emails array of emails
* @param ims array of instant messenger addresses
* @param websites array of websites
* @param photos
* @return
*/
private JSONObject populateContact(JSONObject contact, JSONArray organizations,
JSONArray addresses, JSONArray phones, JSONArray emails,
JSONArray ims, JSONArray websites, JSONArray photos) {
try {
// Only return the array if it has at least one entry
if (organizations.length() > 0) {
contact.put("organizations", organizations);
}
if (addresses.length() > 0) {
contact.put("addresses", addresses);
}
if (phones.length() > 0) {
contact.put("phoneNumbers", phones);
}
if (emails.length() > 0) {
contact.put("emails", emails);
}
if (ims.length() > 0) {
contact.put("ims", ims);
}
if (websites.length() > 0) {
contact.put("urls", websites);
}
if (photos.length() > 0) {
contact.put("photos", photos);
}
} catch (JSONException e) {
LOG.e(LOG_TAG, e.getMessage(), e);
}
return contact;
}
示例15: buildPopulationSet
import org.apache.cordova.LOG; //导入方法依赖的package包/类
/**
* Create a hash map of what data needs to be populated in the Contact object
* @param fields the list of fields to populate
* @return the hash map of required data
*/
protected HashMap<String, Boolean> buildPopulationSet(JSONObject options) {
HashMap<String, Boolean> map = new HashMap<String, Boolean>();
String key;
try {
JSONArray desiredFields = null;
if (options!=null && options.has("desiredFields")) {
desiredFields = options.getJSONArray("desiredFields");
}
if (desiredFields == null || desiredFields.length() == 0) {
map.put("displayName", true);
map.put("name", true);
map.put("nickname", true);
map.put("phoneNumbers", true);
map.put("emails", true);
map.put("addresses", true);
map.put("ims", true);
map.put("organizations", true);
map.put("birthday", true);
map.put("note", true);
map.put("urls", true);
map.put("photos", true);
map.put("categories", true);
} else {
for (int i = 0; i < desiredFields.length(); i++) {
key = desiredFields.getString(i);
if (key.startsWith("displayName")) {
map.put("displayName", true);
} else if (key.startsWith("name")) {
map.put("displayName", true);
map.put("name", true);
} else if (key.startsWith("nickname")) {
map.put("nickname", true);
} else if (key.startsWith("phoneNumbers")) {
map.put("phoneNumbers", true);
} else if (key.startsWith("emails")) {
map.put("emails", true);
} else if (key.startsWith("addresses")) {
map.put("addresses", true);
} else if (key.startsWith("ims")) {
map.put("ims", true);
} else if (key.startsWith("organizations")) {
map.put("organizations", true);
} else if (key.startsWith("birthday")) {
map.put("birthday", true);
} else if (key.startsWith("note")) {
map.put("note", true);
} else if (key.startsWith("urls")) {
map.put("urls", true);
} else if (key.startsWith("photos")) {
map.put("photos", true);
} else if (key.startsWith("categories")) {
map.put("categories", true);
}
}
}
} catch (JSONException e) {
LOG.e(LOG_TAG, e.getMessage(), e);
}
return map;
}