@Override
public void handleMessage(Message msg) {
String[] strMsg;
switch (msg.what) {
case MsgNumber.UPTIME_UI:
strMsg = (String[]) msg.obj;
chronograph.setText(strMsg[0]);
if(!recordOver){
int percent = Integer.parseInt(strMsg[1]);
if(percent==-1){
recordOver = true;
schedule.setProgress(60);
Toast.makeText(RecordVideoActivity.this, "已录制一分钟!", Toast.LENGTH_SHORT).show();
return;
}
percent = percent>60?60:percent;
schedule.setProgress(percent);
}
break;
default:
break;
}
}
};
// 闪光灯判断
public boolean isSurportFlashlight(Context context) {
boolean flag = false;
PackageManager pm = context.getPackageManager();
FeatureInfo[] features = pm.getSystemAvailableFeatures();
for (FeatureInfo f : features) {
if (PackageManager.FEATURE_CAMERA_FLASH.equals(f.name)) {
flag = true;
break;
}
}
return flag;
}
}
Activity代码,因为非常简单,就没有封装多线程什么的。
import java.io.File;
import java.text.SimpleDateFormat;