我正在使用startActivity调用另一个Activity,并且收到“Activity Not Found Exception”(找不到 Activity )。这是我的代码:

  TextView textView = (TextView) itemClicked;
  String strText = textView.getText().toString();
  String key = "symptom";
  Intent mIntent = new Intent(symptomActivity.this, symptomRemedyActivity.class);
  Bundle mBundle = new Bundle();
  mBundle.putString(key, strText);
  mIntent.putExtras(mBundle);
  startActivity(mIntent);

这是Logcat的输出:
INFO/ActivityManager(59): Displayed activity com.android.homeopathy/.HomeopathyActivity: 5542 ms (total 39089 ms)
INFO/ARMAssembler(59): generated scanline__00000077:03545404_00000004_00000000 [ 47 ipp] (67 ins) at [0x3283e0:0x3284ec] in 627000 ns
INFO/ActivityManager(59): Starting activity: Intent { cmp=com.android.homeopathy/.symptomActivity }
INFO/ActivityManager(59): Displayed activity com.android.homeopathy/.symptomActivity: 2706 ms (total 2706 ms)
INFO/ActivityManager(59): Starting activity: Intent { cmp=com.android.homeopathy/.symptomRemedyActivity (has extras) }

这是调试窗口输出:
    Thread [<1> main] (Suspended (exception ActivityNotFoundException))
Instrumentation.checkStartActivityResult(int, Object) line: 1404
Instrumentation.execStartActivity(Context, IBinder, IBinder, Activity, Intent, int) line: 1378
symptomActivity(Activity).startActivityForResult(Intent, int) line: 2817
symptomActivity(Activity).startActivity(Intent) line: 2923
symptomActivity$1.onItemClick(AdapterView, View, int, long) line: 67
ListView(AdapterView).performItemClick(View, int, long) line: 284
ListView.performItemClick(View, int, long) line: 3382
AbsListView$PerformClick.run() line: 1696
ViewRoot(Handler).handleCallback(Message) line: 587
ViewRoot(Handler).dispatchMessage(Message) line: 92
Looper.loop() line: 123
ActivityThread.main(String[]) line: 4627
Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method]
Method.invoke(Object, Object...) line: 521
ZygoteInit$MethodAndArgsCaller.run() line: 868
ZygoteInit.main(String[]) line: 626
NativeStart.main(String[]) line: not available [native method]

symptomRemedyActivity是我项目中的另一项 Activity 。是否需要执行一些操作,例如导入symptomRemedyActivity,以便startActivity可以看到symptomRemedyActivity,以删除此“未找到 Activity 异常”?

最佳答案

我知道这是一篇旧文章,但目前在google搜索之上,因此对于以后再来的任何人:ActivityNotFound可能是由于您要创建的 Activity 中onCreate中未处理的异常所致。我花了一段时间才注意到我在那儿造成了nullPointerException,因为我没有在找它。

10-08 13:57