我尝试使用我的 Android 按钮来更改 at_command 的值
如果我调用logcat 会"intOfFloat(float f)"
显示btnLeftListener
01-23 16:17:28.610: E/AndroidRuntime(1154): java.lang.NullPointerException
请帮我解决这个问题:)
String at_cmd = "";
FloatBuffer fb;
IntBuffer ib;
int PORT=5556;
float speed = (float)0.1;
int seq = 1;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
btnLeft=(Button)findViewById(R.id.LeftBtn);
btnLeft.setOnClickListener(btnLeftListener);
}
public Button.OnClickListener btnLeftListener=
new Button.OnClickListener(){
@Override
public void onClick(View arg0) {
at_cmd = "AT*PCMD=" + (seq++) + ",1," + intOfFloat(-speed)+",0,0,0";
}
};
public int intOfFloat(float f) {
fb.put(0, f);
return ib.get(0);
}
日志猫
01-23 16:17:28.591: W/dalvikvm(1154): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
01-23 16:17:28.610: E/AndroidRuntime(1154): FATAL EXCEPTION: main
01-23 16:17:28.610: E/AndroidRuntime(1154): java.lang.NullPointerException
01-23 16:17:28.610: E/AndroidRuntime(1154): at com.example.dronedivideandroid.DroneMain.intOfFloat(DroneMain.java:60)
01-23 16:17:28.610: E/AndroidRuntime(1154): at com.example.dronedivideandroid.DroneMain$1.onClick(DroneMain.java:70)
01-23 16:17:28.610: E/AndroidRuntime(1154): at android.view.View.performClick(View.java:4084)
01-23 16:17:28.610: E/AndroidRuntime(1154): at android.view.View$PerformClick.run(View.java:16966)
01-23 16:17:28.610: E/AndroidRuntime(1154): at android.os.Handler.handleCallback(Handler.java:615)
01-23 16:17:28.610: E/AndroidRuntime(1154): at android.os.Handler.dispatchMessage(Handler.java:92)
01-23 16:17:28.610: E/AndroidRuntime(1154): at android.os.Looper.loop(Looper.java:137)
01-23 16:17:28.610: E/AndroidRuntime(1154): at android.app.ActivityThread.main(ActivityThread.java:4745)
01-23 16:17:28.610: E/AndroidRuntime(1154): at java.lang.reflect.Method.invokeNative(Native Method)
01-23 16:17:28.610: E/AndroidRuntime(1154): at java.lang.reflect.Method.invoke(Method.java:511)
01-23 16:17:28.610: E/AndroidRuntime(1154): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
01-23 16:17:28.610: E/AndroidRuntime(1154): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
01-23 16:17:28.610: E/AndroidRuntime(1154): at dalvik.system.NativeStart.main(Native Method)
01-23 16:17:28.631: W/ActivityManager(163): Force finishing activity com.example.dronedivideandroid/.DroneMain
01-23 16:17:28.641: W/WindowManager(163): Failure taking screenshot for (246x410) to layer 21010
01-23 16:17:29.150: W/ActivityManager(163): Activity pause timeout for ActivityRecord{4154a830 com.example.dronedivideandroid/.DroneMain}
01-23 16:17:29.351: I/Choreographer(262): Skipped 37 frames! The application may be doing too much work on its main thread.
01-23 16:17:30.591: I/Process(1154): Sending signal. PID: 1154 SIG: 9
01-23 16:17:30.601: I/ActivityManager(163): Process com.example.dronedivideandroid (pid 1154) has died.
01-23 16:17:30.601: I/WindowState(163): WIN DEATH: Window{414043e0 com.example.dronedivideandroid/com.example.dronedivideandroid.DroneMain paused=false}
01-23 16:17:30.691: W/InputMethodManagerService(163): Got RemoteException sending setActive(false) notification to pid 1154 uid 10047
01-23 16:17:40.091: W/ActivityManager(163): Activity destroy timeout for ActivityRecord{4154a830 com.example.dronedivideandroid/.DroneMain}
01-23 16:19:52.800: D/dalvikvm(248): GC_CONCURRENT freed 383K, 7% free 8537K/9095K, paused 6ms+5ms, total 46ms
01-23 16:23:49.971: E/ThrottleService(163): problem during onPollAlarm: java.lang.IllegalStateException: problem parsing stats: java.io.FileNotFoundException: /proc/net/xt_qtaguid/iface_stat_all: open failed: ENOENT (No such file or directory)
01-23 16:27:27.310: D/dalvikvm(248): GC_CONCURRENT freed 384K, 7% free 8537K/9095K, paused 17ms+6ms, total 56ms