0
我有一个应用程序与主页面和其中一个页面/活动应该包含一个地图,但当我点击按钮打开它,我的应用程序崩溃。我该如何分类?包含谷歌地图的开放页面上的应用程序崩溃
清单 -
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.edinburghnights1"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<!-- External storage for caching. -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!-- My Location -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<!-- Maps API needs OpenGL ES 2.0. -->
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<!-- You must insert your own Google Maps for Android API v2 key in here. -->
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="mykey" />
<activity
android:name="com.example.edinburghnights1.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>
<activity
android:name="com.example.edinburghnights1.Map"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
<activity
android:name="com.example.edinburghnights1.WhatsOn"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
<activity
android:name="com.example.edinburghnights1.ClubList"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
</application>
</manifest>
XML -
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FF0000"
android:orientation="vertical" >
<Button
android:id="@+id/back5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#000000"
android:text="Back"
android:textColor="#FFFFFF" />
<fragment
android:id="@+id/map"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
class="com.google.android.gms.maps.SupportMapFragment"/>
</LinearLayout>
爪哇 -
package com.example.edinburghnights1;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.View;
import android.widget.Button;
public class Map extends Activity{ // extends activity so it can be linked to rest of app
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mapsxml); //layout from mapsxml
Button b1=(Button)findViewById(R.id.back5); // name buttons to be used
b1.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) { //action when clicked
Intent myintent2 = new Intent(Map.this,MainActivity.class);
startActivity(myintent2);
}
});
private void initilizeMap() {
googleMap = ((MapFragment)getFragmentManager().findFragmentById(R.id.map)).getMap();
// check if map is created successfully or not
}
}}
发表您的LO gcat在这里。 – Piyush
崩溃堆栈跟踪可能比您的清单更有用。 – Michael