Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - Activity Not Found Exception

Tags:

android

I am using startActivity to call another Activity and I get the "Activity Not Found Exception". Here is my code:

  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);

Here is the Logcat output:

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) }

Here is the debug window output:

    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 is another activity in my project. Is there something I need to do like importing symptomRemedyActivity so that startActivity can see symptomRemedyActivity, to remove this "Activity Not Found Exception"?

like image 609
James Testa Avatar asked Aug 20 '10 17:08

James Testa


2 Answers

I know this is an old post, but it's on top of the google search at the moment, so for anyone who would come here later: ActivityNotFound can be caused by unhandled exceptions in your onCreate in the activity you're trying to create. It took me a while to notice that I was causing a nullPointerException there, because I wasn't looking for it.

like image 108
Unfrog Avatar answered Nov 12 '22 09:11

Unfrog


Did you list the activity (symtomRemedyActivity) within your AndroidManifest.xml file?

like image 33
I82Much Avatar answered Nov 12 '22 08:11

I82Much