/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
This case, most of the time running, occasional error, APP restart,
Position error
SfhCamera. AutoFocusAndPreviewCallback ();
Please instruct
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
Package com. Bluetooth;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
Import the Java. IO. RandomAccessFile;
Import the Java. Text. DecimalFormat;
Import the Java. Util. The Timer;
Import the Java. Util. TimerTask;
The import com. Bluetooth. R;
The import com. Google. Zxing. BinaryBitmap;
The import com. Google. Zxing. MultiFormatReader;
The import com. Google. Zxing. Result;
The import com. Google. Zxing. Android. PlanarYUVLuminanceSource;
The import com.google.zxing.com mon. HybridBinarizer;
The import android. App. The Activity;
The import android. The content. The Context;
The import android. Content. Intent;
Import android. Content. SharedPreferences;
Import android. Content. SharedPreferences. Editor;
The import android. Graphics. Bitmap;
The import android. Hardware. Camera;
The import android. OS. Bundle;
The import android. OS. Handler;
The import android. OS. The Message;
The import android. Util. Log;
The import android. View. KeyEvent;
The import android. View. SurfaceView;
import android.view.View;
The import android. Widget. The Button;
The import android. Widget. ImageView;
The import android. Widget. TextView;
The import android. Widget. Toast;
Public class testCamera extends the Activity {
Private SurfaceView sfvCamera;
Private SFHCamera SFHCamera;
Private ImageView imgView;
Private View centerView;
Private TextView txtScanResult;
Private TextView txtScanResult2;
Private TextView textViewMessage;
Private Timer mTimer;
Private MyTimerTask mTimerTask;
//in accordance with the standard HVGA
Final static int width=800;
Final static int height=600;
Int dstLeft dstTop, dstWidth, dstHeight;
Boolean first=false;
Boolean close=false;
Long num=0;
Boolean getqrcode=false;
Boolean findQrcode=false;//identify the qr code
String strResult="";
String strPrint="";
String strItem="";
String strItemTmp="";
Boolean debug=false;
//a Boolean debug=true;
Int left=100;
Int top=150;
Int CommandOrder=1;
String card3name="sanlian card";
String card2name="duplex card";
String card3Type="3";
String card2Type="2";
Float a1val=(float) 0.5;
Float b1val=(float) 0.5;
Float c1val=(float) 0.5;
Float d1val=(float) 0.5;
Float reslimit1=(float) 0.5;
Float reskk1=(float) 0.5;
Float rescc1=(float) 0.5;
String testmode="";
String item1="";
String item2="";
String item3="";
@ Override
Public void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
The setContentView (R.l ayout. Qrcodedebug);
Enclosing setTitle (" identification standard curve ");//title
ImgView=(ImageView) enclosing the findViewById (R.i d.I mageView12);//image
CenterView=(View) enclosing the findViewById (R.i, dc enterView);
SfvCamera=(SurfaceView) enclosing the findViewById (R.i d.s fvCamera);//
SfhCamera=new sfhCamera (sfvCamera getHolder (), width, height,
PreviewCallback);
TxtScanResult=(TextView) enclosing the findViewById (R.i which xtScanResult);
TxtScanResult2=(TextView) enclosing the findViewById (R.i which xtScanResult2);
TextViewMessage=(TextView) enclosing the findViewById (R.i which extViewMessage);
StartActivity (new Intent (testCamera. This, ConsoleOpenLed2Activity. Class));
If (debug)
{
TextViewMessage. SetTextSize (16);
ImgView. SetVisibility (the VISIBLE);
}
//initialize the timer
MTimer=new Timer ();
MTimerTask=new MyTimerTask ();
MTimer. The schedule (mTimerTask, 0, 100);
}
The class MyTimerTask extends TimerTask {
@ Override
Public void the run () {
Num++;
If (dstLeft==0) {//assignment only one
* width dstLeft=centerView. GetLeft ()
/getWindowManager (.) getDefaultDisplay (.) getWidth ();
DstTop=centerView. GetTop () * height
/getWindowManager (.) getDefaultDisplay (.) getHeight ().
DstWidth=(centerView getRight () - centerView. GetLeft ()) * width
/getWindowManager (.) getDefaultDisplay (.) getWidth ();
DstHeight=(centerView getBottom () - centerView. GetTop ()) * height
/getWindowManager (.) getDefaultDisplay (.) getHeight ().
}
If (getqrcode==false)
{
If (sfhCamera!=null)
{
SfhCamera. AutoFocusAndPreviewCallback ();
The e (" testCamera AutoFocusAndPreviewCallback ", "" +", getqrcode="+ getqrcode +", ");
}
}
If (num==100)
{
If (CommandOrder==1)
{
//waiting time to
Message message=new Message();
Message. What=3;
handler.sendMessage(message);
Num=0;
CommandOrder=2;
}
}
Else if (num==200)
{
If (CommandOrder==2)
{
//waiting time to
Message message=new Message();
Message. What=2;
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull