ActivityNotFoundException (YES, this activity is declared in AndroidManifest.xml)

筅森魡賤 提交于 2019-12-03 06:20:13

I just solved the problem.

All I had to do was add the FQN to the Application project's AndroidManifest.xml:

<activity android:name="com.example.baseapp.MyEditPreferences"
          android:label="com.example.baseapp.MyActivityLib:string/app_name">
</activity>

In fact, I removed any reference to MyEditPreferences in the Library project's AndroidManifest.xml completely and it still works.

It also works with the original startActivity 1-line statement:

mActivity.startActivity(new Intent(mActivity, MyEditPreferences.class));

Conclusion: It's the application's AndroidManifest.xml that matters, not the library's.

Maybe this will work?

Intent mIntent = new Intent();
mIntent.setClassName(mActivity, "com.example.baseapp.MyEditPreferences");
mActivity.startActivity(mIntent);

If you use classes which names are included in an android package (Settings, Preferences, Activity, ...), you will need to put this:

Intent i = new Intent(this, <name_of_your_package>.classname.class);

If you don't put "name_of_your_package", the compiler will think that you are refering to the class in android package (android.*).

I know this is a very old thread, but I've just had the same problem. In my case all I had to do was to delete a spurious

import java.util.prefs.Preferences;

Just check your manifest for errors that your IDE not pointed.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!