I am getting this exception while I am trying to call an activity from another one. The complete exception is
android.content.ActivityNotFoundExcept
when i have same issue. if you are using library class files and writing it into android manifest files write it like and then remove the library projects manifest files this portion>> then it will work absolutely..
This exception also occurs if you include a library in your app and if the library is calling an activity defined in the library project. In this case we need to merge library's manifest with calling app's manifest.
With ADT version 20, we can do this by adding the below statement in project.properties of calling app.
manifestmerger.enabled=true
I was using getActivityContext()
(instead of Activity.this
) for the menu code to save some work, and copy-and-paste it to each activity without editing each time.
I replaced them with Activity.this
, and the issue is gone.
I have a feeling a smarter Android guy could work-around not having to do that. Would like to hear what it would be.
Restart the Eclipse and check your Manifestfile again. If you find missing the respective Activity, then add it and try again. It solved my similar issue.
intent.setClass takes parameters as "Package Context" and "Class". an example would be:
intent.setClass(CurrentActivity.this, TargetActivity.class);
also you need to check if the activity is registered in manifest file.
Activity you're calling sholdn't contain "sheme" and contain intent-filter:
<activity android:name=".SecondActivity">
<intent-filter>
<action android:name="com.example.sj.myapplication.SecondActivity"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
so in calling code:
Intent intent=new Intent("com.example.sj.myapplication.SecondActivity");
startActivity(intent);