我有一個使用Google地圖的應用程序 - 直到它正常工作。但是現在,當我想點擊一個按鈕以便在地圖上添加功能時,我遇到了問題。 我設法可視化屏幕上的按鈕,它也適用於點擊 - 它顯示正確的烤麪包。但我的目標是開始(有他自己的佈局)的新活動 - 尋找和閱讀教程和東西在這裏的色調是什麼,我有:從主更改爲其他活動時出錯 - Android
//the Add Button in the upper right corner
Button addBookmark = (Button) findViewById(R.id.Button);
addBookmark.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View mapView) {
Intent addBookmarkIntent = new Intent(GoogleMapsApp.this, LocationBookmaker.class);
startActivity(addBookmarkIntent);
}
});
而且我已經編輯清單文件:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
...
<activity android:name=".LocationBookmarker"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
...
</manifest>
無論我嘗試什麼,我總是得到「應用程序GoogleMapsApp(進程google.maps.app)意外停止,請重試。」只有「強制關閉」選項。
自從兩天以來,我一直在嘗試 - 在互聯網上的很多例子中,都說它應該像這樣工作。我看不出哪裏可能是我的錯誤。 也許在意圖的開始,或清單或地方...?
您能告訴我們什麼異常是在應用程序崩潰時在LogCat中報告的嗎? –
07-21 13:52:14.049:ERROR/AndroidRuntime(1267):未捕獲的處理程序:由於未捕獲的異常導致主線程退出 07-21 13:52:14.158:ERROR/AndroidRuntime(1267):android.content .ActivityNotFoundException:無法找到顯式活動類{google.maps.app/google.maps.app.LocationBookmaker};你有沒有在你的AndroidManifest.xml中聲明這個活動?' 這是它 - 但我已經在清單中聲明它 - 也許它需要更多? –
你在模擬器或任何設備上測試嗎? – Prasham