Don't wrap full activities. It will make things more complicated.
Can you post the full error message?
main_button7_click (java line: 995)
java.lang.IllegalStateException: System services not available to Activities before onCreate()
at android.app.Activity.getSystemService(Activity.java:4532)
at com.zj.usbsdk.UsbController.<init>(UsbController.java:40)
at cn.com.zj.usbdemo.PrintDemo.connectusb(PrintDemo.java:1039)
at b4a.example1.main._button7_click(main.java:995)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:186)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:170)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:166)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:4443)
at android.view.View$PerformClick.run(View.java:18443)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5009)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:811)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:627)
at dalvik.system.NativeStart.main(Native Method)
BA myba;
public void initialize(BA ba) // ba is a hidden parameter
{
myba = ba; //save it if you need to
Activity a = myba.activity; // get the Activity
h = new Handler(); // get a handler for the current thread
}
public void connectusb (){
// onCreate(null, null);
// usbCtrl.close();
usbCtrl = new UsbController(this,h);
u_infor = new int[8][2];
u_infor[0][0] = 0x1CBE;
u_infor[0][1] = 0x0003;
u_infor[1][0] = 0x1CB0;
u_infor[1][1] = 0x0003;
u_infor[2][0] = 0x0483;
u_infor[2][1] = 0x5740;
u_infor[3][0] = 0x0493;
u_infor[3][1] = 0x8760;
u_infor[4][0] = 0x0416;
u_infor[4][1] = 0x5011;
u_infor[5][0] = 0x0416;
u_infor[5][1] = 0xAABB;
u_infor[6][0] = 0x1659;
u_infor[6][1] = 0x8965;
u_infor[7][0] = 0x0483;
u_infor[7][1] = 0x5741;
// int i = 0;
// for( i = 0 ; i < 8 ; i++ ){
// dev = usbCtrl.getDev(u_infor[i][0],u_infor[i][1]);
// if(dev != null)
// break;
// }
//
// if( dev != null ){
// if( !(usbCtrl.isHasPermission(dev))){
//
// usbCtrl.getPermission(dev);
// }else{
//
//
//
// }
//}
}