下面列出了android.util.Log#e ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public Map<Uri, StructStat> doInBackground(Void... args) {
Map<Uri, StructStat> stats = new HashMap<>(mMetadataMap.size());
for (DocumentMetadata metadata : mMetadataMap.values()) {
try {
metadata.loadStat(mClient);
if (isCancelled()) {
return stats;
}
} catch(Exception e) {
// Failed to load a stat for a child... Just eat this exception, the only consequence it may
// have is constantly retrying to fetch the stat.
Log.e(TAG, "Failed to load stat for " + metadata.getUri());
}
}
return stats;
}
@Override
public void onReceive(Context arg0, Intent intent) {
Runnable r = new Runnable() {
public void run() {
try {
if (currentDir == null) {
listRoots();
} else {
listFiles(currentDir);
}
} catch (Exception e) {
Log.e("tmessages", e.toString());
}
}
};
if (Intent.ACTION_MEDIA_UNMOUNTED.equals(intent.getAction())) {
listView.postDelayed(r, 1000);
} else {
r.run();
}
}
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
ComplexActivity activity = activityWeakReference.get();
if (activity != null) {
switch (msg.what) {
case 0:
activity.main_image_view.setImageResource(R.mipmap.ic_launcher);
break;
case 100:
count++;
Log.e("Edwin", "count = " + count);
break;
}
}
}
@Override
public void onItemDismiss(int position, int dir) {
Log.d (TAG, String.format("swipped %s pos to %s (%s)",
position, dir == START ? "left" : dir == END ? "right" : "??", dir));
final long itemId = listUtil.getItem(position).id;
switch (dir) {
case START: // left swipe
editItem(itemId);
break;
case END: // right swipe
deleteItem(itemId, position);
break;
default:
Log.e(TAG, "unknown move: " + dir);
}
}
public static void loadExtension(Context context, String apkFile, String packageName) {
Log.i(TAG, "Trying to load new class from apk.");
final File dexInternalStoragePath = new File(context.getDir("extensions", Context.MODE_PRIVATE),
apkFile + ".apk");
final File optimizedDexOutputPath = context.getDir("outdex", Context.MODE_PRIVATE);
Log.i(TAG, "dexInternalStoragePath: " + dexInternalStoragePath.getAbsolutePath());
if (dexInternalStoragePath.exists()) {
Log.i(TAG, "New apk found! " + apkFile);
DexClassLoader dexLoader = new DexClassLoader(dexInternalStoragePath.getAbsolutePath(),
optimizedDexOutputPath.getAbsolutePath(),
null,
ClassLoader.getSystemClassLoader().getParent());
try {
Class klazz = dexLoader.loadClass("ai.mycroft.extension." + packageName);
Constructor constructor = klazz.getConstructor(String.class);
Method method = klazz.getDeclaredMethod("getInfo");
Object newObject = constructor.newInstance("New object info");
Log.i(TAG, "New object has class: " + newObject.getClass().getName());
Log.i(TAG, "Invoking getInfo on new object: " + method.invoke(newObject));
} catch (Exception e) {
Log.e(TAG, "Exception:", e);
}
} else {
Log.i(TAG, "Sorry new apk doesn't exist.");
}
}
/**
* Adds a new LimitLine to this axis.
*
* @param l
*/
public void addLimitLine(LimitLine l) {
mLimitLines.add(l);
if (mLimitLines.size() > 6) {
Log.e("MPAndroiChart",
"Warning! You have more than 6 LimitLines on your axis, do you really want " +
"that?");
}
}
/**
* Stops the background thread and its {@link Handler}.
*/
private void stopBackgroundThread() {
backgroundThread.quitSafely();
try {
backgroundThread.join();
backgroundThread = null;
backgroundHandler = null;
} catch (final InterruptedException e) {
Log.e(TAG, "Exception!" + e);
}
}
@Override
public void onClick(View v) {
//tryVibrate();
Log.e("DATEPICKERDIALOG", "just to checking if its working or not" + v.getId());
if (v.getId() == R.id.mdtp_date_picker_year) {
Log.e("DATEPICKERDIALOG", "just to checking if its working or not: YEAR_VIEW");
setCurrentView(YEAR_VIEW);
} else if (v.getId() == R.id.mdtp_date_picker_month_and_day) {
Log.e("DATEPICKERDIALOG", "just to checking if its working or not: datePickerMonthAndDay");
setCurrentView(MONTH_AND_DAY_VIEW);
}
}
public Target<Drawable> loadWithShadowCircleTransform(String url, ImageView imageView,
@ColorInt int shadowColor) {
Context context = weakContext.get();
if (context != null) {
return Glide.with(context)
.load(AptoideUtils.IconSizeU.generateSizeStoreString(url, resources, windowManager))
.apply(getRequestOptions().transform(
new ShadowCircleTransformation(context, imageView, shadowColor)))
.transition(DrawableTransitionOptions.withCrossFade())
.into(imageView);
} else {
Log.e(TAG, "::loadWithShadowCircleTransform() Context is null");
}
return null;
}
/** 底层回调 */
public static int ndkNotify(int key, int value) {
if (mOnNativeListener != null) {
mOnNativeListener.ndkNotify(key, value);
} else {
Log.e("ndkNotify", "ndkNotify key:" + key + ", value: " + value);
}
return 0;
}
/**
* 根据相机id获取相机对象
* @param cameraId
* @return
*/
public static Camera getCameraInstance(int cameraId){
Camera c = null;
try {
c = Camera.open(cameraId); // attempt to get a Camera instance
}
catch (Exception e){
Log.e(TAG, "open camera failed: " + e.getMessage());
// Camera is not available (in use or does not exist)
}
return c; // returns null if camera is unavailable
}
public static Class<?> findClass(final String classname,
final ClassLoader loader) {
try {
return loader.loadClass(classname);
} catch (final Exception e) {
Log.e(AndHook.LOG_TAG, "failed to find class " + classname
+ " on ClassLoader " + loader, e);
}
return null;
}
public synchronized boolean addNetdEventCallback(int callerType, INetdEventCallback callback) {
if (!isValidCallerType(callerType)) {
Log.e(TAG, "Invalid caller type: " + callerType);
return false;
}
mNetdEventCallbackList[callerType] = callback;
return true;
}
public void uncaughtException(Thread thread, Throwable ex) {
if (handleException(ex) || this.mDefaultHandler == null) {
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
Log.e(TAG, "error : ", e);
}
Process.killProcess(Process.myPid());
System.exit(1);
return;
}
this.mDefaultHandler.uncaughtException(thread, ex);
}
public AutoTextView(Context context, AttributeSet attrs) {
super(context, attrs);
mContext = context;
mHandler = new Handler(mContext.getMainLooper());
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.AutoTextView);
mTextSize = a.getInt(R.styleable.AutoTextView_autoTextSize, 13);
Log.e(TAG, "mTextSize: " + mTextSize);
mTextColor = a.getColor(R.styleable.AutoTextView_autoTextColor, 0xFF999999);
a.recycle();
setFactory(this);
}
private void reportError(final String errorMessage) {
Log.e(TAG, "Peerconnection error: " + errorMessage);
executor.execute(new Runnable() {
@Override
public void run() {
if (!isError) {
events.onPeerConnectionError(errorMessage);
isError = true;
}
}
});
}
@Override
public boolean onItemMove(int fromPosition, int toPosition) {
if (getListItem() == null) return false;
Log.e("fromPosition: " + fromPosition, "toPosition: " + toPosition);
// Collections.swap(getListItem(), fromPosition, toPosition);
moveList(getListItem(), fromPosition, toPosition);
// if (toPosition == 0 || toPosition == 1){
// notifyDataSetChanged();
// }
// else {
notifyItemMoved(fromPosition, toPosition);
// }
return true;
}
@Override
protected void onRestart() {
Log.e("Edwin", TAG + " —> onRestart");
super.onRestart();
}
@Override
public void onError(@NonNull CameraDevice camera, int error) {
camera.close();
cameraDevice = null;
Log.e(TAG, "ERROR = " + error);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_error);
Intent intent = getIntent();
androidx.appcompat.widget.Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
Utility.setActionBarColor(this);
Utility.setToolbar(this, toolbar, getResources().getString(R.string.error_report_title));
toolbar.setTitleTextColor(getColor(R.color.black));
androidx.appcompat.app.ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setTitle(R.string.error_report_title);
actionBar.setDisplayShowTitleEnabled(true);
}
Button reportButton = findViewById(R.id.errorReportButton);
userCommentBox = findViewById(R.id.errorCommentBox);
TextView errorView = findViewById(R.id.errorView);
TextView infoView = findViewById(R.id.errorInfosView);
TextView errorMessageView = findViewById(R.id.errorMessageView);
ActivityCommunicator ac = ActivityCommunicator.getCommunicator();
returnActivity = ac.returnActivity;
errorInfo = intent.getParcelableExtra(ERROR_INFO);
errorList = intent.getStringArrayExtra(ERROR_LIST);
// important add guru meditation
addGuruMeditaion();
currentTimeStamp = getCurrentTimeStamp();
reportButton.setOnClickListener((View v) -> {
Context context = this;
new AlertDialog.Builder(context)
.setIcon(android.R.drawable.ic_dialog_alert)
.setTitle(R.string.privacy_policy_title)
.setMessage(R.string.start_accept_privacy_policy)
.setCancelable(false)
.setNeutralButton(R.string.read_privacy_policy, (dialog, which) -> {
Intent webIntent = new Intent(Intent.ACTION_VIEW,
Uri.parse(context.getString(R.string.privacy_policy_url))
);
context.startActivity(webIntent);
})
.setPositiveButton(R.string.accept, (dialog, which) -> {
Intent i = new Intent(Intent.ACTION_SENDTO);
i.setType("text/html");
i.setData(Uri.parse("mailto:" + ERROR_EMAIL_ADDRESS))
.putExtra(Intent.EXTRA_SUBJECT, ERROR_EMAIL_SUBJECT)
.putExtra(Intent.EXTRA_TEXT,
Html.fromHtml(buildHtml()));
startActivity(Intent.createChooser(i, "Send Email"));
})
.setNegativeButton(R.string.decline, (dialog, which) -> {
// do nothing
})
.show();
});
// normal bugreport
buildInfo(errorInfo);
if (errorInfo.message != 0) {
errorMessageView.setText(errorInfo.message);
} else {
errorMessageView.setVisibility(View.GONE);
findViewById(R.id.messageWhatHappenedView).setVisibility(View.GONE);
}
errorView.setText(formErrorText(errorList));
//print stack trace once again for debugging:
for (String e : errorList) {
Log.e("Debugging Error :", e);
}
}