【问题标题】:App Crashing on intent start with google maps应用程序崩溃意图从谷歌地图开始
【发布时间】:2014-02-13 02:38:03
【问题描述】:

地图活动的Java代码

package com.schweigert.drinkingbuddy;

import android.app.Activity;
import android.os.Bundle;


public class BarMaps extends Activity {



protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.barmaps);


}
}

XML 代码

<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/map"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:name="com.google.android.gms.maps.MapFragment" >


</fragment>

启动意图的Java代码

    maps.setOnClickListener(new Button.OnClickListener(){

        @Override
        public void onClick(View v) {


                Intent openMap = new Intent("com.schweigert.drinkingbuddy.BarMaps");
                startActivity(openMap);


        }

    });

当我在我的计算机上设置的模拟器上运行此代码时,它会显示“除非您更新 Google Play 服务,否则此应用程序将无法运行。但是当我在物理设备上运行它时,它会超时并显示该应用程序已停止工作。为什么我的模拟器和物理设备之间的错误差异如此之大?

编辑:

package com.schweigert.drinkingbuddy;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.EditText;


public class StartingPoint extends Activity {

double numDrinks;
int counter;
EditText standardDrinks;
Button bacIntent, maps, drinks;
TextView display;
Bundle testBundle;
@Override
protected void onCreate(Bundle testBundle) {
    super.onCreate(testBundle);
    setContentView(R.layout.activity_starting_point);
    counter = 0;
    bacIntent = (Button) findViewById(R.id.bacIntent);
    maps = (Button) findViewById(R.id.Maps);
    drinks = (Button) findViewById(R.id.drinks);


    bacIntent.setOnClickListener(new Button.OnClickListener(){
        @Override
        public void onClick(View v){


            try{
                Intent openBac = new Intent("com.schweigert.drinkingbuddy.BloodAlcoholContent");
                startActivity(openBac);
            }
            catch(Exception e)
            {
                display.setText("my d" + e);
            }
            }



    });

    maps.setOnClickListener(new Button.OnClickListener(){

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            try{
                Intent openMap = new Intent("com.schweigert.drinkingbuddy.MainActivity");
                startActivity(openMap);
            }
            catch(Exception e){
                display.setText("my d"+ e);
            }
        }

    });

    drinks.setOnClickListener(new Button.OnClickListener(){

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            try{
                Intent openDrinkMenu = new Intent("com.schweigert.drinkingbuddy.DrinkType");
                startActivity(openDrinkMenu);
            }
            catch(Exception e){
                display.setText("my d:" + e);
            }
        }

    });


}
}

【问题讨论】:

  • 使用 Android SDK 管理器更新您的 Android SDK。对于设备上的问题,LogCat 说明了什么?
  • 这是我在 Galaxy s3 i.imgur.com/MmOUpxR.png 上运行时出现的 LogCat 错误。对不起,我赶上了课程和考试的延误
  • StartingPoint.java 第 59 行有什么内容?有东西是null
  • 请检查您的 google play 服务是否包含在您的“YOUR_APP.apk”中,否则将无法在您的实体手机上正常运行。

标签: java android google-maps android-intent


【解决方案1】:

所以我有一个 try catch 与一个不再存在的 textview 交互,然后我的清单设置不正确。感谢 Shivan 的帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多