2012-01-18 66 views
1

我正在開發一個Android應用程序,在該應用程序中,我必須移動到按鈕上的MapActivity單擊事件。 但是,從Activity切換到MapActivity時,應用程序崩潰。從Android Activity切換到MapActivity

任何人都可以幫助我嗎?

在此先感謝。

這裏是我的代碼,

public class PopupActivity extends Activity implements GPSCallback 
{ 
    ....... 
    public void display_map(String str) 
    { 
     Intent showMap_intent = new Intent(this,DisplayGoogleMaps.class); 
     PopupActivity.this.startActivity(showMap_intent); 
    } 

} 

這是我的地圖Activity類

public class DisplayGoogleMaps extends MapActivity 
{ 
    MapView mapView; 

    /** Called when the activity is first created. */ 

    @Override 
    public void onCreate(Bundle savedInstanceState) 
    { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.map); 
    } 
} 

,這是我的Manifest.xml

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



    <uses-permission android:name="android.permission.INTERNET" /> 
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> 
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> 
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />  

    <application 
     android:icon="@drawable/ic_launcher" 
     android:label="@string/app_name" > 

     <uses-library android:name="com.google.android.maps" /> 

     <activity 
      android:label="@string/app_name" 
      android:name=".PopupActivity" > 
      <intent-filter > 
       <action android:name="android.intent.action.MAIN" /> 

       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter> 
     </activity> 

     <activity 
      android:label="@string/app_name" 
      android:name=".DisplayGoogleMaps" > 
     </activity> 
    </application> 

</manifest> 

沒有什麼錯誤日誌中,同時崩潰!

+1

要麼粘貼活動代碼或日誌,所以你可以幫助你。 – jeet 2012-01-18 09:48:11

+1

需要崩潰錯誤日誌 – idiottiger 2012-01-18 09:54:20

回答

3

您是否在您的Manifest中聲明瞭地圖活動?您是否將Android API程序包設置爲Google API? 這些是強制性的。

0

「從Activity切換到MapActivity時」是什麼意思? 你如何切換?任何源代碼?

當你想在MapView中顯示一些數據時,你必須啓動一個Intent。

public void onClick(View view) { 
    Intent i = new Intent(this, ActivityTwo.class); 
    i.putExtra("Value1", "This value one for ActivityTwo "); 
    i.putExtra("Value2", "This value two ActivityTwo"); 
    // Set the request code to any code you like, you can identify the 
    // callback via this code 
    startActivity(i); 
} 

http://www.vogella.de/articles/AndroidIntent/article.html => 6.教程:顯式意圖和活動

在你的情況下,類之間的數據傳輸> ActivityTwo <必須是MapActivity