[英]android.content.ActivityNotFoundException but declared in Manifest
I have the following in my manifest file: 我的清单文件中包含以下内容:
<activity
android:name="org.sipdroid.codecs.Codecs$CodecSettings"
android:label="@string/app_name" >
</activity>
And this is the class: 这是课程:
public static class CodecSettings extends PreferenceActivity {
private static final int MENU_UP = 0;
private static final int MENU_DOWN = 1;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.codec_settings);
// for long-press gesture on a profile preference
registerForContextMenu(getListView());
addPreferences(getPreferenceScreen());
}
@Override
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
menu.setHeaderTitle(R.string.codecs_move);
menu.add(Menu.NONE, MENU_UP, 0,
R.string.codecs_move_up);
menu.add(Menu.NONE, MENU_DOWN, 0,
R.string.codecs_move_down);
}
@Override
public boolean onContextItemSelected(MenuItem item) {
int posn = (int)((AdapterContextMenuInfo)item.getMenuInfo()).position;
Codec c = codecs.elementAt(posn);
if (item.getItemId() == MENU_UP) {
if (posn == 0)
return super.onContextItemSelected(item);
Codec tmp = codecs.elementAt(posn - 1);
codecs.set(posn - 1, c);
codecs.set(posn, tmp);
} else if (item.getItemId() == MENU_DOWN) {
if (posn == codecs.size() - 1)
return super.onContextItemSelected(item);
Codec tmp = codecs.elementAt(posn + 1);
codecs.set(posn + 1, c);
codecs.set(posn, tmp);
}
PreferenceScreen ps = getPreferenceScreen();
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(Receiver.mContext);
String v = "";
SharedPreferences.Editor e = sp.edit();
for (Codec d : codecs)
v = v + d.number() + " ";
e.putString(Settings.PREF_CODECS, v);
e.commit();
ps.removeAll();
addPreferences(ps);
return super.onContextItemSelected(item);
}
@Override
public boolean onPreferenceTreeClick(PreferenceScreen ps, Preference p) {
ListPreference l = (ListPreference) p;
for (Codec c : codecs)
if (c.key().equals(l.getKey())) {
c.init();
if (!c.isLoaded()) {
l.setValue("never");
c.fail();
l.setEnabled(false);
l.setSummary(l.getEntry());
if (l.getDialog() != null)
l.getDialog().dismiss();
}
}
return super.onPreferenceTreeClick(ps,p);
}
@Override
public void onDestroy() {
super.onDestroy();
unregisterForContextMenu(getListView());
}
}
I'm getting : Unable to find explicit activity class {org.sipdroid.sipua/org.sipdroid.codecs.Codecs$CodecSettings}; 我得到:无法找到显式活动类{org.sipdroid.sipua / org.sipdroid.codecs.Codecs $ CodecSettings}; have you declared this activity in your AndroidManifest.xml? 您是否在AndroidManifest.xml中声明了此活动?
What's wrong? 怎么了?
1 Activity shouldn't be a static class. 1活动不应该是静态类。
2 Activity shouldn't be an inner class. 2活动不应该是内部类。
When it comes to your problem, it shows that, you declared package name twice. 谈到您的问题时,它表明您两次声明了程序包名称。
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.yourpackage.activities">
<application
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
If you declared package name in <manifest ../>
, you don't need declare it again in <activity android:name=".MainActivity">
. 如果您在<manifest ../>
声明了程序包名称,则无需在<activity android:name=".MainActivity">
再次声明它。 Just use "." 只需使用“。” instead of that. 而不是那个。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.