汽车力量关闭?

时间:2012-04-17 15:33:13

标签: android

我在这里遇到了问题,因为当我看到某个地方有计算器代码并以某种方式使用它时,当我开始键入数字时,应用程序始终强制关闭。帮助

public void onClickListener8(View v)
{
    vibrator.vibrate(30);
    if(press=='=')
    {
        onClickListenerReset(buttonClear);
    }
    eight=(String)button8.getText();
    sum=sum+eight;
    editText.setText(sum);
}


04-17 15:38:23.110: E/AndroidRuntime(678): FATAL EXCEPTION: main
04-17 15:38:23.110: E/AndroidRuntime(678): java.lang.IllegalStateException: Could not     execute method of the activity
04-17 15:38:23.110: E/AndroidRuntime(678):  at     android.view.View$1.onClick(View.java:2144)
04-17 15:38:23.110: E/AndroidRuntime(678):  at     android.view.View.performClick(View.java:2485)
04-17 15:38:23.110: E/AndroidRuntime(678):  at     android.view.View$PerformClick.run(View.java:9080)
04-17 15:38:23.110: E/AndroidRuntime(678):  at     android.os.Handler.handleCallback(Handler.java:587)
04-17 15:38:23.110: E/AndroidRuntime(678):  at     android.os.Handler.dispatchMessage(Handler.java:92)
04-17 15:38:23.110: E/AndroidRuntime(678):  at android.os.Looper.loop(Looper.java:123)
04-17 15:38:23.110: E/AndroidRuntime(678):  at     android.app.ActivityThread.main(ActivityThread.java:3683)
04-17 15:38:23.110: E/AndroidRuntime(678):  at     java.lang.reflect.Method.invokeNative(Native Method)
04-17 15:38:23.110: E/AndroidRuntime(678):  at     java.lang.reflect.Method.invoke(Method.java:507)
04-17 15:38:23.110: E/AndroidRuntime(678):  at     com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
04-17 15:38:23.110: E/AndroidRuntime(678):  at     com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
04-17 15:38:23.110: E/AndroidRuntime(678):  at dalvik.system.NativeStart.main(Native     Method)
04-17 15:38:23.110: E/AndroidRuntime(678): Caused by:     java.lang.reflect.InvocationTargetException
04-17 15:38:23.110: E/AndroidRuntime(678):  at     java.lang.reflect.Method.invokeNative(Native Method)
04-17 15:38:23.110: E/AndroidRuntime(678):  at     java.lang.reflect.Method.invoke(Method.java:507)
04-17 15:38:23.110: E/AndroidRuntime(678):  at     android.view.View$1.onClick(View.java:2139)
04-17 15:38:23.110: E/AndroidRuntime(678):  ... 11 more
04-17 15:38:23.110: E/AndroidRuntime(678): Caused by: java.lang.SecurityException:     Requires VIBRATE permission
04-17 15:38:23.110: E/AndroidRuntime(678):  at     android.os.Parcel.readException(Parcel.java:1322)
04-17 15:38:23.110: E/AndroidRuntime(678):  at     android.os.Parcel.readException(Parcel.java:1276)
04-17 15:38:23.110: E/AndroidRuntime(678):  at     android.os.IVibratorService$Stub$Proxy.vibrate(IVibratorService.java:106)
04-17 15:38:23.110: E/AndroidRuntime(678):  at     android.os.Vibrator.vibrate(Vibrator.java:52)
04-17 15:38:23.110: E/AndroidRuntime(678):  at     com.mypackage.Calculator.onClickListener8(Calculator.java:232)
04-17 15:38:23.110: E/AndroidRuntime(678):  ... 14 more

2 个答案:

答案 0 :(得分:1)

确保您的应用具有Vibrate权限。清单中应该有以下行:

<uses-permission android:name="android.permission.VIBRATE"/>

答案 1 :(得分:-3)

我认为你必须使用模拟器。只要注意振动;不知怎的,这就是问题的原因。