这是我的代码:
btnSendSMS.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
final String phoneNo = txtPhoneNo.getText().toString();
final String message = '\u00AB' + "smsmks" + '\u00BB' + ' '
+ txtMessage.getText().toString();
if ((phoneNo.length() > 0) && (message.length() > 0)) {
//pilihan, mengirim citra gambar atau tidak
final CharSequence[] items = { "Text", "Image" };
AlertDialog.Builder kk = new AlertDialog.Builder(getBaseContext());
kk.setTitle("Pilih Metode Penginputan");
kk.setItems(items, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int x) {
Intent i = null;
if ("Text".equals(items[x])) {
sendSMS(phoneNo, message);
Toast.makeText(getBaseContext(), phoneNo,
Toast.LENGTH_SHORT).show();
} else {
i = new Intent(TulisPesanLontara.this,
KonversiGambar.class);
startActivity(i);
}
}
}).show();
} else
Toast.makeText(getBaseContext(),
"Please enter both phone number and message.",
Toast.LENGTH_SHORT).show();
}
}
没有发现错误,但是如果我运行并单击项目,我会强制关闭。你能帮我吗?谢谢大家(抱歉英语不好)
这是我的日志猫
11-06 15:48:27.658: D/fastDelete(5657): ============= 结束处理删除事件 ================ ============ 11-06 15:48:28.307: I/fastDelete(5657): !!!fastDelete 阶段结束!!!11-06 15:48:30.371: D/AndroidRuntime(5657): 关闭 VM 11-06 15:48:30.371: W/dalvikvm(5657): threadid=1: 线程退出未捕获异常 (group=0x40020648) 11 -06 15:48:30.373:E/AndroidRuntime(5657):致命异常:主要 11-06 15:48:30.373:E/AndroidRuntime(5657):android.view.WindowManager$BadTokenException:无法添加窗口 -- 令牌null 不适用于应用程序 11-06 15:48:30.373: E/AndroidRuntime(5657): at android.view.ViewRoot.setView(ViewRoot.java:568) 11-06 15:48:30.373: E/AndroidRuntime( 5657): 在 android.view.WindowManagerImpl.addView(WindowManagerImpl.java:209) 11-06 15:48:30.373: E/AndroidRuntime(5657): 在 android.view。Looper.loop(SourceFile:351) 11-06 15:48:30.373: E/AndroidRuntime(5657): 在 android.app.ActivityThread.main(ActivityThread.java:3850) 11-06 15:48:30.373: E/ AndroidRuntime(5657): 在 java.lang.reflect.Method.invokeNative(Native Method) 11-06 15:48:30.373: E/AndroidRuntime(5657): 在 java.lang.reflect.Method.invoke(Method.java: 538) 11-06 15:48:30.373: E/AndroidRuntime(5657): 在 com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901) 11-06 15:48:30.373: E/ AndroidRuntime(5657): 在 com.android.internal.os.ZygoteInit.main(ZygoteInit.java:659) 11-06 15:48:30.373: E/AndroidRuntime(5657): 在 dalvik.system.NativeStart.main(Native方法)11-06 15:48:37.789:I/Process(5657):发送信号。PID:5657 SIG:9 main(ActivityThread.java:3850) 11-06 15:48:30.373: E/AndroidRuntime(5657): at java.lang.reflect.Method.invokeNative(Native Method) 11-06 15:48:30.373: E/AndroidRuntime (5657):在 java.lang.reflect.Method.invoke(Method.java:538) 11-06 15:48:30.373:E/AndroidRuntime(5657):在 com.android.internal.os.ZygoteInit$MethodAndArgsCaller。运行(ZygoteInit.java:901)11-06 15:48:30.373:E/AndroidRuntime(5657):在 com.android.internal.os.ZygoteInit.main(ZygoteInit.java:659)11-06 15:48: 30.373: E/AndroidRuntime(5657): at dalvik.system.NativeStart.main(Native Method) 11-06 15:48:37.789: I/Process(5657): 发送信号。PID:5657 SIG:9 main(ActivityThread.java:3850) 11-06 15:48:30.373: E/AndroidRuntime(5657): at java.lang.reflect.Method.invokeNative(Native Method) 11-06 15:48:30.373: E/AndroidRuntime (5657):在 java.lang.reflect.Method.invoke(Method.java:538) 11-06 15:48:30.373:E/AndroidRuntime(5657):在 com.android.internal.os.ZygoteInit$MethodAndArgsCaller。运行(ZygoteInit.java:901)11-06 15:48:30.373:E/AndroidRuntime(5657):在 com.android.internal.os.ZygoteInit.main(ZygoteInit.java:659)11-06 15:48: 30.373: E/AndroidRuntime(5657): at dalvik.system.NativeStart.main(Native Method) 11-06 15:48:37.789: I/Process(5657): 发送信号。PID:5657 SIG:9 调用(Method.java:538)11-06 15:48:30.373:E/AndroidRuntime(5657):在 com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901)11-06 15: 48:30.373: E/AndroidRuntime(5657): 在 com.android.internal.os.ZygoteInit.main(ZygoteInit.java:659) 11-06 15:48:30.373: E/AndroidRuntime(5657): 在 dalvik.system .NativeStart.main(Native Method) 11-06 15:48:37.789: I/Process(5657): 发送信号。PID:5657 SIG:9 调用(Method.java:538)11-06 15:48:30.373:E/AndroidRuntime(5657):在 com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901)11-06 15: 48:30.373: E/AndroidRuntime(5657): 在 com.android.internal.os.ZygoteInit.main(ZygoteInit.java:659) 11-06 15:48:30.373: E/AndroidRuntime(5657): 在 dalvik.system .NativeStart.main(Native Method) 11-06 15:48:37.789: I/Process(5657): 发送信号。PID:5657 SIG:9