下面列出了android.util.Log#d ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private void handleDocumentsProvider(ProviderInfo info) {
// Ignore stopped packages for now; we might query them
// later during UI interaction.
if ((info.applicationInfo.flags & ApplicationInfo.FLAG_STOPPED) != 0) {
if (LOGD) Log.d(TAG, "Ignoring stopped authority " + info.authority);
mTaskStoppedAuthorities.add(info.authority);
return;
}
// Try using cached roots if filtering
boolean cacheHit = false;
if (mAuthority != null && !mAuthority.equals(info.authority)) {
synchronized (mLock) {
if (mTaskRoots.putAll(info.authority, mRoots.get(info.authority))) {
if (LOGD) Log.d(TAG, "Used cached roots for " + info.authority);
cacheHit = true;
}
}
}
// Cache miss, or loading everything
if (!cacheHit) {
mTaskRoots.putAll(info.authority,
loadRootsForAuthority(mContext.getContentResolver(), info.authority));
}
}
/**
* 修改滑动灵敏度
* @param flingDistance 滑动惯性,默认是75
* @param minimumVelocity 最小滑动值,默认是1200
*/
public void setScrollFling(int flingDistance , int minimumVelocity){
try {
Field mFlingDistance = ViewPager.class.getDeclaredField("mFlingDistance");
mFlingDistance.setAccessible(true);
Object o = mFlingDistance.get(this);
Log.d("setScrollFling",o.toString());
//默认值75
mFlingDistance.set(this, flingDistance);
Field mMinimumVelocity = ViewPager.class.getDeclaredField("mMinimumVelocity");
mMinimumVelocity.setAccessible(true);
Object o1 = mMinimumVelocity.get(this);
Log.d("setScrollFling",o1.toString());
//默认值1200
mMinimumVelocity.set(this,minimumVelocity);
} catch (Exception e){
e.printStackTrace();
}
}
private void getBtcAddress(final String walletNum) {
Log.d("flint", "PurchaseWemovecoinsActivity.getBtcAddress()...");
showProgress();
String code = "btc";
ChangellyNetworkManager.generateAddress(code.toLowerCase(), MAIN_CURRENCY, walletNum, null, new ApiMethods.RequestListener() {
@Override
public void onSuccess(Object response) {
ResponseGenerateAddress addressItem = (ResponseGenerateAddress) response;
if (addressItem.getAddress() != null && addressItem.getAddress().getAddress() != null) {
closeProgress();
onAddressGenerated(addressItem.getAddress().getAddress());
} else {
getBtcAddress_changenow(walletNum);
}
}
@Override
public void onFailure(String msg) {
getBtcAddress_changenow(walletNum);
}
});
}
public void onComplete(String url) {
Log.d(TAG, "onComplete called in fragment controller " + url);
// if (mWebView != null) {
// this.getAccessToken(mWebView, url);
// } else {
// this.dismissDialog();
// }
}
/**
* 存储新的数据库表 以及数据
*
* @param db
*/
private void restoreData(Database db,Class<? extends AbstractDao<?, ?>> bookChapterClass) {
DaoConfig daoConfig = new DaoConfig(db, bookChapterClass);
String tableName = daoConfig.tablename;
String tempTableName = daoConfig.tablename.concat("_TEMP");
ArrayList<String> properties = new ArrayList();
for (int j = 0; j < daoConfig.properties.length; j++) {
String columnName = daoConfig.properties[j].columnName;
if (getColumns(db, tableName).contains(columnName)) {
properties.add(columnName);
}
}
StringBuilder insertTableStringBuilder = new StringBuilder();
insertTableStringBuilder.append("INSERT INTO ").append(tableName).append(" (");
insertTableStringBuilder.append(TextUtils.join(",", properties));
insertTableStringBuilder.append(") SELECT ");
insertTableStringBuilder.append(TextUtils.join(",", properties));
insertTableStringBuilder.append(" FROM ").append(tempTableName).append(";");
Log.d(TAG, "restoreData: " + insertTableStringBuilder.toString());
StringBuilder dropTableStringBuilder = new StringBuilder();
dropTableStringBuilder.append("DROP TABLE ").append(tempTableName);
db.execSQL(insertTableStringBuilder.toString());
db.execSQL(dropTableStringBuilder.toString());
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
final ViewGroup.LayoutParams params = mTop.getLayoutParams();
Log.d(TAG, "onSizeChanged-mTopViewHeight:" + mTopViewHeight);
mTop.post(new Runnable() {
@Override
public void run() {
if (mTop instanceof ViewGroup) {
ViewGroup viewGroup = (ViewGroup) mTop;
int height = viewGroup.getChildAt(0).getHeight();
mTopViewHeight = height - stickOffset;
params.height = height;
mTop.setLayoutParams(params);
mTop.requestLayout();
} else {
mTopViewHeight = mTop.getMeasuredHeight() - stickOffset;
}
Log.d(TAG, "mTopViewHeight:" + mTopViewHeight);
if (null != mInnerScrollView) {
Log.d(TAG, "mInnerScrollViewHeight:" + mInnerScrollView.getMeasuredHeight());
}
if (isStickNav) {
scrollTo(0, mTopViewHeight);
}
}
});
}
/**
* Like {@link #launchIntent(Intent)} but will tell you if it is not handle-able
* via {@link ActivityNotFoundException}.
*
* @throws ActivityNotFoundException
*/
final void rawLaunchIntent(Intent intent) {
if (intent != null) {
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
Log.d(TAG, "Launching intent: " + intent + " with extras: " + intent.getExtras());
activity.startActivity(intent);
}
}
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Prevent invalid actions
final Intent intent = getIntent();
if (intent == null || intent.getAction() == null) {
Log.e(TAG, "Invalid intent. Activity will exit now.");
finish();
return;
}
if (!MediaStore.ACTION_IMAGE_CAPTURE.equals(intent.getAction())) {
Log.e(TAG, "ProxyCameraActivity can receive Media.ACTION_IMAGE_CAPTURE only. " +
"But its action is " + intent.getAction());
finish();
return;
}
// Get extras from current capture intent
getExtrasFromCaptureIntent(intent);
// Start process
shouldBeHandled = Settings.isSourceAppShouldBeHandled(getReferrerPackage());
if (shouldBeHandled) {
Log.d(TAG, "Receive an valid capture intent from WeChat. " +
"Now we start process it.");
processIntentForWeChat(intent);
} else {
Log.v(TAG, "Receive an valid capture intent from other apps. " +
"We should open a preferred camera application or start chooser.");
processIntentForOthers(intent);
}
}
private void stop(boolean temporary) {
if (vpn != null) {
stopNative(vpn);
stopVPN(vpn);
vpn = null;
unprepare();
}
if (state == State.enforcing && !temporary) {
Log.d(TAG, "Stop foreground state=" + state.toString());
last_allowed = -1;
last_blocked = -1;
last_hosts = -1;
stopForeground(true);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ServiceSinkhole.this);
if (prefs.getBoolean("show_stats", false)) {
startForeground(NOTIFY_WAITING, getWaitingNotification());
state = State.waiting;
Log.d(TAG, "Start foreground state=" + state.toString());
} else {
state = State.none;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
stopForeground(true);
} else {
stopSelf();
}
}
}
}
private void sendNotification(String path, String notification) {//KS add args
forceGoogleApiConnect();
if (googleApiClient.isConnected()) {
Log.d(TAG, "sendNotification Notification=" + notification + " Path=" + path);
PutDataMapRequest dataMapRequest = PutDataMapRequest.create(path);
//unique content
dataMapRequest.setUrgent();
dataMapRequest.getDataMap().putDouble("timestamp", System.currentTimeMillis());
dataMapRequest.getDataMap().putString(notification, notification);
PutDataRequest putDataRequest = dataMapRequest.asPutDataRequest();
Wearable.DataApi.putDataItem(googleApiClient, putDataRequest);
} else {
Log.e(TAG, "sendNotification No connection to wearable available!");
}
}
public void stop() {
Log.d(TAG,"Inside Stop");
mStartRequested = false;
if(usingCameraOne) {
if (mCameraSource != null) {
mCameraSource.stop();
}
} else {
if(mCamera2Source != null) {
mCamera2Source.stop();
}
}
}
protected void _setImageDrawable(final Drawable drawable, final Matrix initial_matrix, float min_zoom, float max_zoom ) {
if ( LOG_ENABLED ) {
Log.i( LOG_TAG, "_setImageDrawable" );
}
if ( drawable != null ) {
if ( LOG_ENABLED ) {
Log.d( LOG_TAG, "size: " + drawable.getIntrinsicWidth() + "x" + drawable.getIntrinsicHeight() );
}
super.setImageDrawable( drawable );
} else {
mBaseMatrix.reset();
super.setImageDrawable( null );
}
if ( min_zoom != ZOOM_INVALID && max_zoom != ZOOM_INVALID ) {
min_zoom = Math.min( min_zoom, max_zoom );
max_zoom = Math.max( min_zoom, max_zoom );
mMinZoom = min_zoom;
mMaxZoom = max_zoom;
mMinZoomDefined = true;
mMaxZoomDefined = true;
if ( mScaleType == DisplayType.FIT_TO_SCREEN || mScaleType == DisplayType.FIT_IF_BIGGER ) {
if ( mMinZoom >= 1 ) {
mMinZoomDefined = false;
mMinZoom = ZOOM_INVALID;
}
if ( mMaxZoom <= 1 ) {
mMaxZoomDefined = true;
mMaxZoom = ZOOM_INVALID;
}
}
} else {
mMinZoom = ZOOM_INVALID;
mMaxZoom = ZOOM_INVALID;
mMinZoomDefined = false;
mMaxZoomDefined = false;
}
if ( initial_matrix != null ) {
mNextMatrix = new Matrix( initial_matrix );
}
mBitmapChanged = true;
requestLayout();
}
public static void monitor(String message) {
if (isShowLog && isMonitorMode()) {
StackTraceElement stackTraceElement = Thread.currentThread().getStackTrace()[3];
Log.d(TAG + "::monitor", message + getExtInfo(stackTraceElement));
}
}
public static long logPassedTime(String name){
long ret=System.currentTimeMillis()-currentTime;
Log.d(TAG, name+" is finished, timePassed: "+ret);
return ret;
}
@Override
public void onFillRequest(FillRequest request, CancellationSignal cancellationSignal,
FillCallback callback) {
Log.d(TAG, "onFillRequest()");
// Find autofillable fields
AssistStructure structure = getLatestAssistStructure(request);
ArrayMap<String, AutofillId> fields = getAutofillableFields(structure);
Log.d(TAG, "autofillable fields:" + fields);
if (fields.isEmpty()) {
toast("No autofill hints found");
callback.onSuccess(null);
return;
}
// Create response...
FillResponse response;
if (mAuthenticateResponses) {
int size = fields.size();
String[] hints = new String[size];
AutofillId[] ids = new AutofillId[size];
for (int i = 0; i < size; i++) {
hints[i] = fields.keyAt(i);
ids[i] = fields.valueAt(i);
}
IntentSender authentication = SimpleAuthActivity.newIntentSenderForResponse(this, hints,
ids, mAuthenticateDatasets);
RemoteViews presentation = newDatasetPresentation(getPackageName(),
"Tap to auth response");
response = new FillResponse.Builder()
.setAuthentication(ids, authentication, presentation).build();
} else {
response = createResponse(this, fields, mNumberDatasets,mAuthenticateDatasets);
}
// ... and return it
callback.onSuccess(response);
}
private void log(String stage) {
Log.d("APP", stage + ":" + Thread.currentThread().getName());
}
/**
* Log the message at DEBUG level.
*/
public static void logd(String message, Throwable t) {
if (LOG_ENABLED) {
Log.d(getTag(), message, t);
}
}
private byte[] getExifSegment() throws IOException {
short segmentId, segmentType;
int segmentLength;
while (true) {
segmentId = streamReader.getUInt8();
if (segmentId != SEGMENT_START_ID) {
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "Unknown segmentId=" + segmentId);
}
return null;
}
segmentType = streamReader.getUInt8();
if (segmentType == SEGMENT_SOS) {
return null;
} else if (segmentType == MARKER_EOI) {
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "Found MARKER_EOI in exif segment");
}
return null;
}
// Segment length includes bytes for segment length.
segmentLength = streamReader.getUInt16() - 2;
if (segmentType != EXIF_SEGMENT_TYPE) {
long skipped = streamReader.skip(segmentLength);
if (skipped != segmentLength) {
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "Unable to skip enough data"
+ ", type: " + segmentType
+ ", wanted to skip: " + segmentLength
+ ", but actually skipped: " + skipped);
}
return null;
}
} else {
byte[] segmentData = new byte[segmentLength];
int read = streamReader.read(segmentData);
if (read != segmentLength) {
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "Unable to read segment data"
+ ", type: " + segmentType
+ ", length: " + segmentLength
+ ", actually read: " + read);
}
return null;
} else {
return segmentData;
}
}
}
}
void debug(String log) {
Log.d(this.mTag, log);
}
public static void setNonEncryptedKeyValue(String key, String val) {
Log.d(TAG, "Setting " + val + " for key: " + key);
if (val.equals("false")) { val = "0"; }
else if (val.equals("true")) { val = "1"; }
val = getAESObfuscator().obfuscateString(val);
getDatabase().setKeyVal(key, val);
}