编程经验分享

笑看嫣红染半山,
逐风万里白云间,
逍遥此身不为客,
天地三才任平凡。

0%

转自:https://techblog.badoo.com/blog/2014/08/28/android-handler-memory-leaks

Android uses Java as a platform for development. This helps us with many low level issues including memory management, platform type dependencies, and so on. However we still sometimes get crashes with OutOfMemory. So where’s the garbage collector?

I’m going to focus on one of the cases where big objects in memory can’t be cleared for a lengthy period of time. This case is not ultimately a memory leak - objects will be collected at some point - so we sometimes ignore it. This is not advisable as it can sometimes lead to OOM errors.

The case I’m describing is the Handler leak, which is usually detected as a warning by Lint.

阅读全文 »

正確的實作生命週期方法、確保 APP 行為正常,有以下幾個重點:

  • 使用你的 APP 時、不會因為一通來電、或者切換到其它 APP 而造成當機。
  • 避免你的 APP 不在前景執行時佔用寶貴的系統資源。
  • 不會因為使用者短暫離開你的 APP 後再度返回、而失去原有的進度。
  • 不會因為使用者把螢幕轉正或打橫、而失去原有的進度或當機。
阅读全文 »

这张图列出了Activity生命周期最主要的一些方法,启动后依次执行:

1
onCreate --> onStart --> onResume --> onPause --> onStop --> onDestroy

相信很多人也都已经知道以上方法与执行顺序,但是Activity还有其他方法,如onContentChanged, onPostCreate, onPostResume, onConfigurationChanged, onSaveInstanceState, onRestoreInstanceState,没有什么比自己做个Demo亲自试验研究下更有说服力了,下面我做了一个Demo来彻底研究下这些生命周期的方法,建议大家也亲自试验下:

阅读全文 »

 

http://stackoverflow.com/questions/31042852/ffmpeg-command-to-crop-and-transpose-video-comes-out-zoomed-in-bad-quality

原问题:

I’m trying to convert an mp4 video with dimensions usually 960x720 into a sqaure 480:480 video but it comes out looking squished usually, the command is

"-y -i %s -vf crop=480:480,transpose=%d -threads 5 -metadata:s:v rotate=0 -c:v libx264 -crf 27 -preset ultrafast -c:a copy -bsf:a aac_adtstoasc %s";

Am I missing something, do I need to down scale first or something?

阅读全文 »

一、MediaRecorder类概述

Android的MediaRecorder包含了Audio和video的记录功能,在Android的界面上,Music和Video两个应用程序都是调用MediaRecorder实现的。MediaRecorder在底层是基于OpenCore(PacketVideo)的库实现的,为了构建一个MediaRecorder程序,上层还包含了进程间通讯等内容,这种进程间通讯的基础是Android基本库中的Binder机制。

阅读全文 »