本文整理匯總了Java中org.appcelerator.kroll.common.Log類的典型用法代碼示例。如果您正苦於以下問題:Java Log類的具體用法?Java Log怎麽用?Java Log使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Log類屬於org.appcelerator.kroll.common包,在下文中一共展示了Log類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onReceivedSslError
import org.appcelerator.kroll.common.Log; //導入依賴的package包/類
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error)
{
/*
* in theory this should be checked to make sure it's not null but if there is some failure
* in the association then usage of webViewProxy should trigger a NPE to make sure the issue
* is not ignored
*/
KrollProxy webViewProxy = this.webView.getProxy();
KrollDict data = new KrollDict();
data.put(TiC.ERROR_PROPERTY_CODE, error.getPrimaryError());
webView.getProxy().fireSyncEvent(TiC.EVENT_SSL_ERROR, data);
boolean ignoreSslError = false;
try {
ignoreSslError = webViewProxy.getProperties().optBoolean(TiC.PROPERTY_WEBVIEW_IGNORE_SSL_ERROR, false);
} catch(IllegalArgumentException e) {
Log.e(TAG, TiC.PROPERTY_WEBVIEW_IGNORE_SSL_ERROR + " property does not contain a boolean value, ignoring");
}
if (ignoreSslError == true) {
Log.w(TAG, "ran into SSL error but ignoring...");
handler.proceed();
} else {
Log.e(TAG, "SSL error occurred: " + error.toString());
handler.cancel();
}
}
示例2: start
import org.appcelerator.kroll.common.Log; //導入依賴的package包/類
@Kroll.method
public void start()
{
setState(STATE_RUNNING);
// App opens analytics
ParseAnalytics.trackAppOpenedInBackground(TiApplication.getAppRootOrCurrentActivity().getIntent());
ParseInstallation.getCurrentInstallation().put("androidId", getAndroidId());
ParseInstallation.getCurrentInstallation().saveInBackground(new SaveCallback() {
public void done(ParseException e) {
if (e != null) {
Log.e(TAG, "Installation initialization failed: " + e.getMessage());
}
// fire event
try {
JSONObject pnData = new JSONObject();
pnData.put("objectId", getObjectId());
pnData.put("installationId", getCurrentInstallationId());
KrollDict data = new KrollDict(pnData);
module.fireEvent("installationId", data);
} catch (JSONException e1) {
Log.e(TAG, "InstallationId event failed: " + e1.getMessage());
}
}
});
}
示例3: openURL
import org.appcelerator.kroll.common.Log; //導入依賴的package包/類
@Kroll.method
public boolean openURL(KrollDict options) {
if ( (options != null) && options.containsKeyAndNotNull(Params.URL)) {
Context context = TiApplication.getAppCurrentActivity();
List<ResolveInfo> browsersList = Utils.allBrowsers(context);
if (!browsersList.isEmpty()) {
List<String> customTabBrowsers = getCustomTabBrowsers(context, browsersList);
// show supported browsers list or open directly if only 1 supported browser is available
openCustomTab(context, customTabBrowsers, options);
return true;
} else {
Log.i(Params.LCAT, "No browsers available in this device.");
return false;
}
}
Log.i(Params.LCAT, "Check your paramters. URL parameter is mandatory.");
return false;
}
示例4: getJSValue
import org.appcelerator.kroll.common.Log; //導入依賴的package包/類
synchronized public String getJSValue(String expression)
{
// Don't try to evaluate js code again if the binding has already been destroyed
if (!destroyed && interfacesAdded) {
String code = "_TiReturn.setValue((function(){try{return " + expression
+ "+\"\";}catch(ti_eval_err){return '';}})());";
Log.d(TAG, "getJSValue:" + code, Log.DEBUG_MODE);
returnSemaphore.drainPermits();
synchronized (codeSnippets) {
codeSnippets.push(code);
}
try {
if (!returnSemaphore.tryAcquire(3500, TimeUnit.MILLISECONDS)) {
synchronized (codeSnippets) {
codeSnippets.removeElement(code);
}
Log.w(TAG, "Timeout waiting to evaluate JS");
}
return returnValue;
} catch (InterruptedException e) {
Log.e(TAG, "Interrupted", e);
}
}
return null;
}
示例5: isHTCSenseDevice
import org.appcelerator.kroll.common.Log; //導入依賴的package包/類
private boolean isHTCSenseDevice()
{
boolean isHTC = false;
FeatureInfo[] features = TiApplication.getInstance().getApplicationContext().getPackageManager().getSystemAvailableFeatures();
if(features == null) {
return isHTC;
}
for (FeatureInfo f : features) {
String fName = f.name;
if (fName != null) {
isHTC = fName.contains("com.htc.software.Sense");
if (isHTC) {
Log.i(TAG, "Detected com.htc.software.Sense feature "+fName);
break;
}
}
}
return isHTC;
}
示例6: reload
import org.appcelerator.kroll.common.Log; //導入依賴的package包/類
public void reload()
{
switch (reloadMethod) {
case DATA:
if (reloadData != null && reloadData instanceof TiBlob) {
setData((TiBlob) reloadData);
} else {
Log.d(TAG, "reloadMethod points to data but reloadData is null or of wrong type. Calling default", Log.DEBUG_MODE);
getWebView().reload();
}
break;
case HTML:
if (reloadData == null || (reloadData instanceof HashMap<?,?>) ) {
setHtml(TiConvert.toString(getProxy().getProperty(TiC.PROPERTY_HTML)), (HashMap<String,Object>)reloadData);
} else {
Log.d(TAG, "reloadMethod points to html but reloadData is of wrong type. Calling default", Log.DEBUG_MODE);
getWebView().reload();
}
break;
case URL:
if (reloadData != null && reloadData instanceof String) {
setUrl((String) reloadData);
} else {
Log.d(TAG, "reloadMethod points to url but reloadData is null or of wrong type. Calling default", Log.DEBUG_MODE);
getWebView().reload();
}
break;
default:
getWebView().reload();
}
}
示例7: onMessageReceived
import org.appcelerator.kroll.common.Log; //導入依賴的package包/類
@Override
public void onMessageReceived(String from, Bundle rawData) {
Log.d(TAG, "Received message from: " + from);
HashMap<String, Object> data = CttimekogcmModule.bundleToHashMap(rawData);
boolean forceCreateNotification = false;
if (data.containsKey("forceCreateNotification")) {
if (data.get("forceCreateNotification").equals("true")) {
forceCreateNotification = true;
}
}
try {
CttimekogcmModule module = CttimekogcmModule.getInstance();
if(module != null && !forceCreateNotification) {
if(KrollRuntime.isInitialized() && TiApplication.isCurrentActivityInForeground()) {
module.fireMessage(data, true);
return;
}
}
} catch (Exception e) {
Log.d(TAG, "Couldn't send fireMessage to CttimekogcmModule");
}
NotificationPublisher.createNotification(this, data);
}
示例8: clearSchedule
import org.appcelerator.kroll.common.Log; //導入依賴的package包/類
@Kroll.method
public void clearSchedule() {
TiApplication app = TiApplication.getInstance();
int ntfCount = app.getAppProperties().getInt(PROPERTY_NOTIFICATION_COUNTER, 0);
Log.d(TAG, "Clearing " + ntfCount + " notifications");
if(ntfCount > 0) {
Intent intent = new Intent(app.getApplicationContext(), NotificationPublisher.class);
for(int i = 0; i < ntfCount; i++) {
PendingIntent pendingIntent = PendingIntent.getBroadcast(app.getApplicationContext(), i, intent, PendingIntent.FLAG_ONE_SHOT);
AlarmManager alarmManager = (AlarmManager)app.getApplicationContext().getSystemService(Context.ALARM_SERVICE);
alarmManager.cancel(pendingIntent);
pendingIntent.cancel();
}
app.getAppProperties().setInt(PROPERTY_NOTIFICATION_COUNTER, 0);
}
}
示例9: schedule
import org.appcelerator.kroll.common.Log; //導入依賴的package包/類
@Kroll.method
public void schedule(long time, HashMap data) {
TiApplication app = TiApplication.getInstance();
int ntfId = app.getAppProperties().getInt(PROPERTY_NOTIFICATION_COUNTER, 0);
Log.d(TAG, "Scheduling notification " + ntfId + " at " + time);
Intent intent = new Intent(app.getApplicationContext(), NotificationPublisher.class);
intent.putExtra(PROPERTY_NOTIFICATION_DATA, data);
PendingIntent pendingIntent = PendingIntent.getBroadcast(app.getApplicationContext(), ntfId, intent, PendingIntent.FLAG_ONE_SHOT);
AlarmManager alarmManager = (AlarmManager)app.getApplicationContext().getSystemService(Context.ALARM_SERVICE);
alarmManager.set(AlarmManager.RTC_WAKEUP, time, pendingIntent);
app.getAppProperties().setInt(PROPERTY_NOTIFICATION_COUNTER, ntfId+1);
}
示例10: BluetoothClientThread
import org.appcelerator.kroll.common.Log; //導入依賴的package包/類
public BluetoothClientThread(BluetoothConnection connection)
{
super();
Log.d(LCAT, "Creating new Client thread.");
mConnection = connection;
mDevice = connection.getDevice();
try{
// using reflection in an effort to make it work - no different from calling createRfcommSocketToServiceRecord directly
Class<?> cls = Class.forName("android.bluetooth.BluetoothDevice");
Class<?> arg = Class.forName("java.util.UUID");
java.lang.reflect.Method method = cls.getMethod("createRfcommSocketToServiceRecord", new Class[]{arg});
mSocket = (BluetoothSocket) method.invoke(mDevice, mConnection.getServiceId().mUuid);
//mSocket = mDevice.createRfcommSocketToServiceRecord(mConnection.getServiceId().mUuid);
start();
}
catch(Exception e){
e.printStackTrace();
mConnection.relayError(e.getMessage());
}
}
示例11: onReceive
import org.appcelerator.kroll.common.Log; //導入依賴的package包/類
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
Log.d(LCAT, action);
// When discovery finds a device
if (BluetoothDevice.ACTION_FOUND.equals(action)) {
// Get the BluetoothDevice object from the Intent
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
if(device != null)
{
Log.d(LCAT, device.getName());
Log.d(LCAT, "Adding device to array.");
// Add the name and address to an array adapter to show in a ListView
mArray[counter] = device;
counter++;
}
}
}
示例12: connectBluetooth
import org.appcelerator.kroll.common.Log; //導入依賴的package包/類
public void connectBluetooth()
{
if (mBluetoothAdapter == null)
{
Log.d(LCAT, "********** Device does not support Bluetooth");
mModule.sendMessage("This device does not support bluetooth.");
}
else if(mBluetoothAdapter.isEnabled())
{
Log.d(LCAT, "********** Bluetooth is enabled");
mModule.sendMessage("Bluetooth is already enabled!");
}
else
{
Log.d(LCAT, "********** Bluetooth is disabled");
Log.d(LCAT, "********** Attempting to enable Bluetooth");
Intent intentBluetooth = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
intentBluetooth.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mContext.startActivity(intentBluetooth);
}
}
示例13: hasPermission
import org.appcelerator.kroll.common.Log; //導入依賴的package包/類
/**
* check, if given permission is currently granted
*
* @param requestedPermission - permission as defined in Manifest
* @return
*/
@Kroll.method
public boolean hasPermission(@Kroll.argument() String requestedPermission) {
Log.d(LCAT, "check for granted permission: " + requestedPermission);
// TODO really depends on Build or Platform???
if (Build.VERSION.SDK_INT < 23) {
return true;
}
Context ctx = TiApplication.getInstance().getApplicationContext();
if (ContextCompat.checkSelfPermission(ctx,
requestedPermission) != PackageManager.PERMISSION_GRANTED) {
return false;
}
return true;
}
示例14: requestPermission
import org.appcelerator.kroll.common.Log; //導入依賴的package包/類
/**
* Request a permission and optionally register a callback for the current activity
*
* @param requestedPermission permission as defined in Manifest
* @param permissionCallback function called with result of permission prompt
* @param requestCode - 8 Bit value to associate callback with request - if none is provided a system generated will used
* @return true in case of valid request, false if requested permission is not a valid one
*/
@Kroll.method
public boolean requestPermission(String requestedPermission,
@Kroll.argument(optional = true) KrollFunction permissionCallback,
@Kroll.argument(optional = true) Integer requestCode) {
Log.d(LCAT, "Requesting permission: " + requestedPermission);
if (!isValidPermissionString(requestedPermission)) {
Log.e(LCAT, "Requested permission is not supported :"
+ requestedPermission);
return false;
}
return handleRequest(new String[]{requestedPermission}, requestCode, permissionCallback);
}
示例15: requestPermissions
import org.appcelerator.kroll.common.Log; //導入依賴的package包/類
/**
* Request a permission and optionally register a callback for the current activity
*
* @param requestedPermissions Array of permissions as defined in Manifest
* @param permissionCallback function called with result of permission prompt
* @param requestCode - 8 Bit value to associate callback with request - if none is provided, a system generated one is used
* @return true in case of valid request, false if requested permission is not a valid one
*/
@Kroll.method
public boolean requestPermissions(@Kroll.argument String[] requestedPerms,
@Kroll.argument(optional = true) KrollFunction permissionCallback,
@Kroll.argument(optional = true) Integer requestCode)
{
// String[] requestedPermissions = new String[]{requestedPerms};//(String[])requestedPerms;
for(String permission:requestedPerms) {
Log.d(LCAT, "Requesting permission: " + permission);
if (!isValidPermissionString(permission)) {
Log.e(LCAT, "Requested permission is not supported :"
+ permission);
return false;
}
}
return handleRequest(requestedPerms, requestCode, permissionCallback);
}