我现在已经解决了这个问题一段时间了。
我在程序代码中尝试了什么:
text_notice.setOnClickListener(new OnClickListener(){ public void onClick(查看v){
context = getParent();
Log.i("", "Parent " + context.toString());
edit_notice = new Dialog(context);
edit_notice.setContentView(R.layout.edit_notice);
edit_notice.setTitle(R.string.notice);
final Button ok_button = (Button) edit_notice.findViewById(R.id.ok_button);
final EditText notice_text = (EditText) edit_notice.findViewById(R.id.notice);
ok_button.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
race.setNotice(notice_text.getText().toString());
raceDao = HelperSingleton.getInstance().getHelper().getRaceDaoException();
raceDao.update(race);
text_notice.setText(race.getNotice());
edit_notice.dismiss();
}
});
edit_notice.show();
}
});
所以基本上是在ActivityGroup中添加一个窗口。
如果我走这条路,这段代码工作正常: RowCoachActivity - >结果活动 - > ShowDetailsActivity
一旦我尝试这条道路: SettingsActivity - > RowCoachActivity - >结果活动 - > ShowDetailsActivity
应用程序崩溃。
有人可以帮助我吗?
来自设置的来电: //结束前一个RowCoachActivity RowCoachActivity.h.sendEmptyMessage(0);
Intent result_intent = new Intent(SettingsActivity.this, RowCoachActivity.class);
Window window = getLocalActivityManager().startActivity("RowCoachActivity", result_intent);
这是我的日志:
10-28 15:08:46.662:D / dalvikvm(611):GC_EXTERNAL_ALLOC在44ms内释放了1157个对象/ 81424个字节 10-28 15:08:53.262:I / dalvikvm(611):threadid = 3:对信号3作出反应 10-28 15:08:53.282:I / dalvikvm(611):将堆栈跟踪写入'/data/anr/traces.txt' 10-28 15:08:56.513:W / KeyCharacterMap(611):没有用于id 0的键盘 10-28 15:08:56.513:W / KeyCharacterMap(611):使用默认键映射:/system/usr/keychars/qwerty.kcm.bin 10-28 15:08:59.063:I /(611):完成了活动RowCoach 10-28 15:09:00.963:D / dalvikvm(611):GC_FOR_MALLOC在46ms内释放2864个对象/ 174056个字节 10-28 15:09:04.133:I /(611):家长com.rowcoachultra.ResultsActivity@44f83e08 10-28 15:09:04.183:D / AndroidRuntime(611):关闭VM 10-28 15:09:04.183:W / dalvikvm(611):threadid = 1:线程退出未捕获异常(组= 0x4001d800) 10-28 15:09:04.192:E / AndroidRuntime(611):致命异常:主要 10-28 15:09:04.192:E / AndroidRuntime(611):android.view.WindowManager $ BadTokenException:无法添加窗口 - 令牌android.app.LocalActivityManager $ LocalActivityRecord@44f68e40无效;你的活动在运行吗? 10-28 15:09:04.192:E / AndroidRuntime(611):在android.view.ViewRoot.setView(ViewRoot.java:505) 10-28 15:09:04.192:E / AndroidRuntime(611):在android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177) 10-28 15:09:04.192:E / AndroidRuntime(611):在android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91) 10-28 15:09:04.192:E / AndroidRuntime(611):在android.view.Window $ LocalWindowManager.addView(Window.java:424) 10-28 15:09:04.192:E / AndroidRuntime(611):在android.app.Dialog.show(Dialog.java:241) 10-28 15:09:04.192:E / AndroidRuntime(611):at com.rowcoachultra.ShowDetailsActivity $ 2.onClick(ShowDetailsActivity.java:111) 10-28 15:09:04.192:E / AndroidRuntime(611):在android.view.View.performClick(View.java:2408) 10-28 15:09:04.192:E / AndroidRuntime(611):在android.view.View $ PerformClick.run(View.java:8816) 10-28 15:09:04.192:E / AndroidRuntime(611):在android.os.Handler.handleCallback(Handler.java:587) 10-28 15:09:04.192:E / AndroidRuntime(611):在android.os.Handler.dispatchMessage(Handler.java:92) 10-28 15:09:04.192:E / AndroidRuntime(611):在android.os.Looper.loop(Looper.java:123) 10-28 15:09:04.192:E / AndroidRuntime(611):在android.app.ActivityThread.main(ActivityThread.java:4627) 10-28 15:09:04.192:E / AndroidRuntime(611):at java.lang.reflect.Method.invokeNative(Native Method) 10-28 15:09:04.192:E / AndroidRuntime(611):at java.lang.reflect.Method.invoke(Method.java:521) 10-28 15:09:04.192:E / AndroidRuntime(611):at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:868) 10-28 15:09:04.192:E / AndroidRuntime(611):at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 10-28 15:09:04.192:E / AndroidRuntime(611):at dalvik.system.NativeStart.main(Native Method)