从Android Activity切换到MapActivity
问题描述:
我正在开发一个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>
没有什么错误日志中,同时崩溃!
答
您是否在您的Manifest中声明了地图活动?您是否将Android API程序包设置为Google API? 这些是强制性的。
答
“从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
要么粘贴活动代码或日志,所以你可以帮助你。 – jeet 2012-01-18 09:48:11
需要崩溃错误日志 – idiottiger 2012-01-18 09:54:20