Tecnologia do Blogger.
RSS

Re: [androidbrasil-dev] Problema ao chamar tela a partir de um botão

Valeu cara,

Eu vi o erro e resolvi apagar a pergunta hauhaua 
Não vi que vc tinha respondido.
Esta tudo funcionando certinho, valeu mesmo.

Em terça-feira, 28 de janeiro de 2014 17h35min17s UTC-2, Carlos Pelegrin escreveu:
O erro está na MapActivity.java linha 32.

Att.


--
Carlos Eduardo Simões Pelegrin


2014-01-28 Vinny Valente <irmaoca...@gmail.com>
POxa, aquele erro sumiu e agora feio outro =(

Na hora que aperto o potao ainda não abre a outra tela...

Erro

01-28 17:26:28.610: E/AndroidRuntime(14397): FATAL EXCEPTION: main
01-28 17:26:28.610: E/AndroidRuntime(14397): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.encontresepuder/com.example.encontresepuder.MapActivity}: java.lang.NullPointerException
01-28 17:26:28.610: E/AndroidRuntime(14397): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2100)
01-28 17:26:28.610: E/AndroidRuntime(14397): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
01-28 17:26:28.610: E/AndroidRuntime(14397): at android.app.ActivityThread.access$600(ActivityThread.java:140)
01-28 17:26:28.610: E/AndroidRuntime(14397): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
01-28 17:26:28.610: E/AndroidRuntime(14397): at android.os.Handler.dispatchMessage(Handler.java:99)
01-28 17:26:28.610: E/AndroidRuntime(14397): at android.os.Looper.loop(Looper.java:137)
01-28 17:26:28.610: E/AndroidRuntime(14397): at android.app.ActivityThread.main(ActivityThread.java:4898)
01-28 17:26:28.610: E/AndroidRuntime(14397): at java.lang.reflect.Method.invokeNative(Native Method)
01-28 17:26:28.610: E/AndroidRuntime(14397): at java.lang.reflect.Method.invoke(Method.java:511)
01-28 17:26:28.610: E/AndroidRuntime(14397): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
01-28 17:26:28.610: E/AndroidRuntime(14397): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
01-28 17:26:28.610: E/AndroidRuntime(14397): at dalvik.system.NativeStart.main(Native Method)
01-28 17:26:28.610: E/AndroidRuntime(14397): Caused by: java.lang.NullPointerException
01-28 17:26:28.610: E/AndroidRuntime(14397): at com.example.encontresepuder.MapActivity.onCreate(MapActivity.java:32)
01-28 17:26:28.610: E/AndroidRuntime(14397): at android.app.Activity.performCreate(Activity.java:5206)
01-28 17:26:28.610: E/AndroidRuntime(14397): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1083)
01-28 17:26:28.610: E/AndroidRuntime(14397): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2064)
01-28 17:26:28.610: E/AndroidRuntime(14397): ... 11 more


Em terça-feira, 28 de janeiro de 2014 17h10min18s UTC-2, Rudson Lima escreveu:
\o/


2014-01-28 Vinny Valente <irmaoca...@gmail.com>
Nossa cara, qe vacilo meu. Eu esqueci de colocar as coisas do AndroidManifest.xml para o outro Manifest...
Valeu, funcionou!

Em terça-feira, 28 de janeiro de 2014 16h45min40s UTC-2, Rudson Lima escreveu:
AndroidManifest.xml does not exist.  You must have the following declaration within the <application> element:     <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />


Coloca dentro do teu <application>


        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />
               
        <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
             android:value="meu_key" />             



2014-01-28 Vinny Valente <irmaoca...@gmail.com>
E ai galera blz?

Sou inciante e algumas coisas consigo fazer e outras q são faceis eu empaco =/
Fiz um projeto pra fazer funcionar um mapa nos meus teste e consegui.
Fiz outro projeto pra criar telinha com botoes e chamar outra tela e tb consegui.
Ai decidi fazer o mapa funcionar no projeto com as telinhas para ele aparecer quando clicar no botao Mapa.

Ai q ta a caca, quando clico no botao Mapa da pau e o aplicativo para.

Problema: btnTelaMapa ... os outros botoes funcionam normalmente.

Codigos:

Main

public class MainActivity extends Activity {

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

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
public void btnExibirNestaTela(View view) {
// Recupera o elemento da tela e o seu texto.
EditText primeiroCampo = (EditText) findViewById(R.id.editText1);
String mensagem = primeiroCampo.getText().toString();
 
// Exibe a mensagem.
Toast.makeText(this, mensagem, Toast.LENGTH_LONG).show();
}
public void btnExibirNovaTela(View view) {
// Recupera o elemento da tela e o seu texto.
EditText segundoCampo = (EditText) findViewById(R.id.editText2);
String mensagem = segundoCampo.getText().toString();
 
// Cria o intent com a mensagem a ser passada para a onva tela.
Intent intent = new Intent(this, SecondActivity.class);
intent.putExtra("mensagem", mensagem);
 
// Inicia a nova tela.
startActivity(intent);
}
public void btnTelaMapa (View view) {
Intent i = new Intent(this, MapActivity.class);
        startActivity(i);
}

}

Classe MAPA

package com.example.novolayout;

import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.GoogleMapOptions;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.CircleOptions;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;

public class MapActivity extends Activity {
private GoogleMap mMap;
private LatLng frameworkSystemLocation = new LatLng(-23.614201, -46.773360);
private LatLng testeMerker = new LatLng(-23.614101, -46.773360);
static final LatLng LAT = new LatLng(-22.614201, -24.614201);
static final LatLng LONG = new LatLng(-45.773360, -47.773360);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.map);
mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
GoogleMapOptions options = new GoogleMapOptions();
options.mapType(GoogleMap.MAP_TYPE_TERRAIN)
   .compassEnabled(false)
   .rotateGesturesEnabled(false)
   .tiltGesturesEnabled(false);
//Adiciona um ponto no mapa no local pré determinado 
        mMap.addMarker(new MarkerOptions()
       .position(frameworkSystemLocation).title("Prodesp")
       .alpha(0.7f)
       .icon(BitmapDescriptorFactory.fromResource(R.drawable.aqui)))
       .setSnippet("Vinny Trampando");
        
        //Circulo
        CircleOptions circleOptions = new CircleOptions()
        .strokeWidth(2)
        .strokeColor(Color.LTGRAY)
        .fillColor(Color.TRANSPARENT)
        .center(frameworkSystemLocation)
        .radius(100); // In meters

        // Get back the mutable Circle
        mMap.addCircle(circleOptions);
        
        mMap.addMarker(new MarkerOptions()
        .position(testeMerker).title("Teste 2")
        .alpha(0.7f)
        .icon(BitmapDescriptorFactory.fromResource(R.drawable.aqui)))
        .setSnippet("Vinny");
        
        //Move a câmera para Framework System com zoom 15.
        mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(testeMerker , 15));
        mMap.animateCamera(CameraUpdateFactory.zoomTo(17), 2000, null);
        
        
      //Marca sua posição no mapa
        mMap.getUiSettings().setMyLocationButtonEnabled(true);
        mMap.getUiSettings().setCompassEnabled(true); 
        mMap.setMyLocationEnabled(true); 

}
}

ERRO

01-28 16:38:05.225: D/AndroidRuntime(13817): Shutting down VM
01-28 16:38:05.225: W/dalvikvm(13817): threadid=1: thread exiting with uncaught exception (group=0x41bb72a0)
01-28 16:38:05.240: E/AndroidRuntime(13817): FATAL EXCEPTION: main
01-28 16:38:05.240: E/AndroidRuntime(13817): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.novolayout/com.example.novolayout.MapActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
01-28 16:38:05.240: E/AndroidRuntime(13817): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2100)
01-28 16:38:05.240: E/AndroidRuntime(13817): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
01-28 16:38:05.240: E/AndroidRuntime(13817): at android.app.ActivityThread.access$600(ActivityThread.java:140)
01-28 16:38:05.240: E/AndroidRuntime(13817): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
01-28 16:38:05.240: E/AndroidRuntime(13817): at android.os.Handler.dispatchMessage(Handler.java:99)
01-28 16:38:05.240: E/AndroidRuntime(13817): at android.os.Looper.loop(Looper.java:137)
01-28 16:38:05.240: E/AndroidRuntime(13817): at android.app.ActivityThread.main(ActivityThread.java:4898)
01-28 16:38:05.240: E/AndroidRuntime(13817): at java.lang.reflect.Method.invokeNative(Native Method)
01-28 16:38:05.240: E/AndroidRuntime(13817): at java.lang.reflect.Method.invoke(Method.java:511)
01-28 16:38:05.240: E/AndroidRuntime(13817): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
01-28 16:38:05.240: E/AndroidRuntime(13817): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
01-28 16:38:05.240: E/AndroidRuntime(13817): at dalvik.system.NativeStart.main(Native Method)
01-28 16:38:05.240: E/AndroidRuntime(13817): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
01-28 16:38:05.240: E/AndroidRuntime(13817): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
01-28 16:38:05.240: E/AndroidRuntime(13817): at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
01-28 16:38:05.240: E/AndroidRuntime(13817): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
01-28 16:38:05.240: E/AndroidRuntime(13817): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
01-28 16:38:05.240: E/AndroidRuntime(13817): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:308)
01-28 16:38:05.240: E/AndroidRuntime(13817): at android.app.Activity.setContentView(Activity.java:1924)
01-28 16:38:05.240: E/AndroidRuntime(13817): at com.example.novolayout.MapActivity.onCreate(MapActivity.java:25)
01-28 16:38:05.240: E/AndroidRuntime(13817): at android.app.Activity.performCreate(Activity.java:5206)
01-28 16:38:05.240: E/AndroidRuntime(13817): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1083)
01-28 16:38:05.240: E/AndroidRuntime(13817): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2064)
01-28 16:38:05.240: E/AndroidRuntime(13817): ... 11 more
01-28 16:38:05.240: E/AndroidRuntime(13817): Caused by: java.lang.IllegalStateException: A required meta-data tag in your app's AndroidManifest.xml does not exist.  You must have the following declaration within the <application> element:     <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
01-28 16:38:05.240: E/AndroidRuntime(13817): at com.google.android.gms.common.GooglePlayServicesUtil.n(Unknown Source)
01-28 16:38:05.240: E/AndroidRuntime(13817): at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source)
01-28 16:38:05.240: E/AndroidRuntime(13817): at com.google.android.gms.maps.internal.q.v(Unknown Source)
01-28 16:38:05.240: E/AndroidRuntime(13817): at com.google.android.gms.maps.internal.q.u(Unknown Source)
01-28 16:38:05.240: E/AndroidRuntime(13817): at com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
01-28 16:38:05.240: E/AndroidRuntime(13817): at com.google.android.gms.maps.MapFragment$b.eb(Unknown Source)
01-28 16:38:05.240: E/AndroidRuntime(13817): at com.google.android.gms.maps.MapFragment$b.a(Unknown Source)
01-28 16:38:05.240: E/AndroidRuntime(13817): at com.google.android.gms.dynamic.a.a(Unknown Source)
01-28 16:38:05.240: E/AndroidRuntime(13817): at com.google.android.gms.dynamic.a.onInflate(Unknown Source)
01-28 16:38:05.240: E/AndroidRuntime(13817): at com.google.android.gms.maps.MapFragment.onInflate(Unknown Source)
01-28 16:38:05.240: E/AndroidRuntime(13817): at android.app.Activity.onCreateView(Activity.java:4856)
01-28 16:38:05.240: E/AndroidRuntime(13817): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
01-28 16:38:05.240: E/AndroidRuntime(13817): ... 20 more


Valeu quem puder ajudar

--
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.



--
Rudson Lima ( live-O )
Desenvolvedor Android - Web Service C# - SQL Server - Delphi
+55 85 87050560 - Fortaleza-ce

--
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
Rudson Lima ( live-O )
Desenvolvedor Android - Web Service C# - SQL Server - Delphi
+55 85 87050560 - Fortaleza-ce

--
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • RSS

0 comentários:

Postar um comentário