Olá pessoal, não estou conseguindo abrir o mapa no meu aparelho. segue a minha codificação:
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="br.com.caelum.cadastro"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<permission
android:name="br.com.caelum.cadastro.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="SEU_PACOTE.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<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" >
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="my code" />
<activity android:name=".Formulario" >
</activity>
<activity
android:name=".ListaAlunos"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver
android:name=".SMSReceiver"
android:enabled="true" >
<intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
<activity
android:name=".Provas"
android:label="@string/title_activity_provas" >
</activity>
<activity
android:name=".MostraAlunosProximos"
android:label="@string/mapas" >
</activity>
</application>
</manifest>
MapaFragment.java
public class MapaFragment extends SupportMapFragment {
}
map_layout.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:orientation="vertical" >
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/mapa"
android:name="com.google.android.gms.maps.SupportMapFragment"
/>
</LinearLayout>
MostraAlunosProximos.java
public class MostraAlunosProximos extends FragmentActivity{
@Override
protected void onCreate(Bundle arg0) {
setContentView(R.layout.map_layout);
try{
MapaFragment mapaFragment = new MapaFragment();
FragmentManager manager = getSupportFragmentManager();
FragmentTransaction transaction = manager.beginTransaction();
transaction.replace(R.id.mapa, mapaFragment);
transaction.commit();
}catch(Exception e )
{
Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show();
}
}
}
chamada da activity no método = onOptionsItemSelected da classe ListaAlunos:
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int itemClicado = item.getItemId();
case R.id.mapa:
Intent irParaMapa = new Intent(this,MostraAlunosProximos.class);
startActivity(irParaMapa);
break;
default:
}
return super.onOptionsItemSelected(item);
}
}
Error no console:
09-07 20:12:13.466: E/AndroidRuntime(13983): FATAL EXCEPTION: main 09-07 20:12:13.466: E/AndroidRuntime(13983): Process: br.com.caelum.cadastro, PID: 13983 09-07 20:12:13.466: E/AndroidRuntime(13983): android.util.SuperNotCalledException: Activity {br.com.caelum.cadastro/br.com.caelum.cadastro.MostraAlunosProximos} did not call through to super.onCreate() 09-07 20:12:13.466: E/AndroidRuntime(13983): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2150) 09-07 20:12:13.466: E/AndroidRuntime(13983): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233) 09-07 20:12:13.466: E/AndroidRuntime(13983): at android.app.ActivityThread.access$800(ActivityThread.java:135) 09-07 20:12:13.466: E/AndroidRuntime(13983): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) 09-07 20:12:13.466: E/AndroidRuntime(13983): at android.os.Handler.dispatchMessage(Handler.java:102) 09-07 20:12:13.466: E/AndroidRuntime(13983): at android.os.Looper.loop(Looper.java:136) 09-07 20:12:13.466: E/AndroidRuntime(13983): at android.app.ActivityThread.main(ActivityThread.java:5001) 09-07 20:12:13.466: E/AndroidRuntime(13983): at java.lang.reflect.Method.invokeNative(Native Method) 09-07 20:12:13.466: E/AndroidRuntime(13983): at java.lang.reflect.Method.invoke(Method.java:515) 09-07 20:12:13.466: E/AndroidRuntime(13983): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785) 09-07 20:12:13.466: E/AndroidRuntime(13983): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601) 09-07 20:12:13.466: E/AndroidRuntime(13983): at dalvik.system.NativeStart.main(Native Method)