gpt4 book ai didi

android - 当我尝试从 ItemOptions 打开 MapActivity 时出现 fatal error

转载 作者:行者123 更新时间:2023-11-30 03:04:29 26 4
gpt4 key购买 nike

我尝试在有主要 Activity 的地方创建应用程序,并在单击选项项 - map 后创建 MapActivity。我无法解决这个问题。

02-25 22:39:48.956: E/AndroidRuntime(22525): FATAL EXCEPTION: main
02-25 22:39:48.956: E/AndroidRuntime(22525): android.content.ActivityNotFoundException: Unable to find explicit activity class **{pl.pawelfrydrych.flyingball/pl.pawelfrydrych.flyingball.Map}; have you declared this activity in your AndroidManifest.xml?**
02-25 22:39:48.956: E/AndroidRuntime(22525): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1645)
02-25 22:39:48.956: E/AndroidRuntime(22525): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1441)
02-25 22:39:48.956: E/AndroidRuntime(22525): at android.app.Activity.startActivityForResult(Activity.java:3464)
02-25 22:39:48.956: E/AndroidRuntime(22525): at android.app.Activity.startActivityForResult(Activity.java:3425)
02-25 22:39:48.956: E/AndroidRuntime(22525): at android.app.Activity.startActivity(Activity.java:3661)
02-25 22:39:48.956: E/AndroidRuntime(22525): at android.app.Activity.startActivity(Activity.java:3629)
02-25 22:39:48.956: E/AndroidRuntime(22525): at pl.pawelfrydrych.flyingball.MainActivity.onOptionsItemSelected(MainActivity.java:166)
02-25 22:39:48.956: E/AndroidRuntime(22525): at android.app.Activity.onMenuItemSelected(Activity.java:2640)
02-25 22:39:48.956: E/AndroidRuntime(22525): at com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected(PhoneWindow.java:1171)
02-25 22:39:48.956: E/AndroidRuntime(22525): at com.android.internal.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:735)
02-25 22:39:48.956: E/AndroidRuntime(22525): at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:152)
02-25 22:39:48.956: E/AndroidRuntime(22525): at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:874)
02-25 22:39:48.956: E/AndroidRuntime(22525): at com.android.internal.view.menu.ListMenuPresenter.onItemClick(ListMenuPresenter.java:178)
02-25 22:39:48.956: E/AndroidRuntime(22525): at android.widget.AdapterView.performItemClick(AdapterView.java:301)
02-25 22:39:48.956: E/AndroidRuntime(22525): at android.widget.AbsListView.performItemClick(AbsListView.java:1510)
02-25 22:39:48.956: E/AndroidRuntime(22525): at android.widget.AbsListView$PerformClick.run(AbsListView.java:3333)
02-25 22:39:48.956: E/AndroidRuntime(22525): at android.os.Handler.handleCallback(Handler.java:730)
02-25 22:39:48.956: E/AndroidRuntime(22525): at android.os.Handler.dispatchMessage(Handler.java:92)
02-25 22:39:48.956: E/AndroidRuntime(22525): at android.os.Looper.loop(Looper.java:137)
02-25 22:39:48.956: E/AndroidRuntime(22525): at android.app.ActivityThread.main(ActivityThread.java:5419)
02-25 22:39:48.956: E/AndroidRuntime(22525): at java.lang.reflect.Method.invokeNative(Native Method)
02-25 22:39:48.956: E/AndroidRuntime(22525): at java.lang.reflect.Method.invoke(Method.java:525)
02-25 22:39:48.956: E/AndroidRuntime(22525): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1187)

我看到这个错误,你是否在 AndroidManifest 中声明了这个 Activity ,但我无法做到。

public boolean onOptionsItemSelected(MenuItem item) {
switch(item.getItemId()){
case R.id.Mapy:

Intent intent = new Intent(this,Map.class);
startActivity(intent);


break;
default:
return super.onOptionsItemSelected(item);
}
return true;
}

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="pl.pawelfrydrych.flyingball"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

<application

android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="pl.pawelfrydrych.flyingball.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<uses-library android:name="com.google.android.maps" />
</application>
<uses-permission android:name="android.permission.INTERNET" />
</manifest>

public class Map extends MapActivity {

private MapView mapView;

@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.mapactivity);

mapView = (MapView) findViewById(R.id.mapview);

mapView.setBuiltInZoomControls(true);
mapView.setTraffic(false);
mapView.setSatellite(true);
mapView.setStreetView(true);


}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}

@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}

}

最佳答案

好像你忘了声明 Activity :

pl.pawelfrydrych.flyingball.Map

在你的 AndroidManifest.xml 中


在其他 activity 标记下方的 Manifest.xml 中添加类似内容:

    <activity
android:name="pl.pawelfrydrych.flyingball.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- add this here: -->
<activity
android:name="pl.pawelfrydrych.flyingball.Map"
android:label="@string/map_title" >
</activity>

关于android - 当我尝试从 ItemOptions 打开 MapActivity 时出现 fatal error ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22026896/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com