应用程序崩溃的意图开始与谷歌地图
问题描述:
在地图活动的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>
启动意图
maps.setOnClickListener(new Button.OnClickListener(){
@Override
public void onClick(View v) {
Intent openMap = new Intent("com.schweigert.drinkingbuddy.BarMaps");
startActivity(openMap);
}
});
当我运行这段代码
Java代码在我的模拟器上,我在电脑上设置了它,它引发了“除非您更新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);
}
}
});
}
}
答
所以我有一个尝试捕捉这是用不存在了一个TextView互动,然后我有我的清单设置不正确。感谢Shivan的帮助。
使用Android SDK管理器更新您的Android SDK。对于设备上的问题,LogCat会告诉您什么? – Raptor
这是我在Galaxy S3上运行它时发生的LogCat错误http://i.imgur.com/MmOUpxR.png。抱歉,我迟迟没有赶上课程和考试 –
你的'StartingPoint.java'第59行有什么?有些东西是'空'的。 – Raptor