K
Kellrkind
Neues Mitglied
- 0
Hallo Leute,
ich schon wieder
Diesmal hab ich ein Anliegen mit der Integration von Google Maps in die App.
Ich entwickle mittels Eclipse und lasse Sie auf dem Handy laufen.
Das Problem ist, es funktioniert manchmal, dann aber wieder nicht...
manchmal auch das hier:
Ich komm grad echt nicht mehr weiter...
Hier ein paar Code Ausschnitte:
Hier rufe ich die Map Klasse Auf:
Und das hier ist meine maps Klasse
Hier noch die XML-Klasse:
Und abschließend noch mein Manifest:
Wäre top wenn Ihr mir weiterhelfen könntet.
Ich verzweifle grad weil es manchmal klappt ohne probs und manchmal wirfts mich aus google maps raus -_-
Danke!
Grüße
Kellrkind
ich schon wieder

Diesmal hab ich ein Anliegen mit der Integration von Google Maps in die App.
Ich entwickle mittels Eclipse und lasse Sie auf dem Handy laufen.
Das Problem ist, es funktioniert manchmal, dann aber wieder nicht...
Code:
08-02 13:37:07.631: E/AndroidRuntime(9764): FATAL EXCEPTION: CacheCommitter:its
08-02 13:37:07.631: E/AndroidRuntime(9764): java.lang.OutOfMemoryError
08-02 13:37:07.631: E/AndroidRuntime(9764): at maps.m.h.a(Unknown Source)
08-02 13:37:07.631: E/AndroidRuntime(9764): at maps.m.y.b(Unknown Source)
08-02 13:37:07.631: E/AndroidRuntime(9764): at maps.k.i.b(Unknown Source)
08-02 13:37:07.631: E/AndroidRuntime(9764): at maps.ap.b.run(Unknown Source)
08-02 13:39:25.136: I/dalvikvm-heap(9942): Clamp target GC heap from 48.079MB to 48.000MB
08-02 13:39:25.141: D/dalvikvm(9942): GC_FOR_ALLOC freed 280K, 7% free 45901K/49159K, paused 33ms, total 33ms
08-02 13:39:27.031: I/dalvikvm-heap(9942): Clamp target GC heap from 48.141MB to 48.000MB
08-02 13:39:27.031: D/dalvikvm(9942): GC_FOR_ALLOC freed 97K, 7% free 45965K/49159K, paused 34ms, total 34ms
08-02 13:39:27.541: I/dalvikvm-heap(9942): Clamp target GC heap from 48.204MB to 48.000MB
08-02 13:39:27.546: D/dalvikvm(9942): GC_FOR_ALLOC freed 3K, 7% free 46029K/49159K, paused 96ms, total 96ms
08-02 13:39:27.546: I/dalvikvm-heap(9942): Forcing collection of SoftReferences for 66023-byte allocation
08-02 13:39:27.591: I/dalvikvm-heap(9942): Clamp target GC heap from 48.194MB to 48.000MB
08-02 13:39:27.591: D/dalvikvm(9942): GC_BEFORE_OOM freed 10K, 7% free 46018K/49159K, paused 45ms, total 45ms
08-02 13:39:27.591: E/dalvikvm-heap(9942): Out of memory on a 66023-byte allocation.
08-02 13:39:27.591: I/dalvikvm(9942): "DataRequestDispatcher" prio=5 tid=30 RUNNABLE
08-02 13:39:27.591: I/dalvikvm(9942): | group="main" sCount=0 dsCount=0 obj=0x43f769e0 self=0x568b7868
08-02 13:39:27.591: I/dalvikvm(9942): | sysTid=10019 nice=0 sched=0/0 cgrp=apps handle=1451985328
08-02 13:39:27.591: I/dalvikvm(9942): | schedstat=( 237856908 75679092 287 ) utm=21 stm=2 core=0
08-02 13:39:27.591: I/dalvikvm(9942): at maps.k.ah.a((null):~-1)
08-02 13:39:27.591: I/dalvikvm(9942): at maps.k.b.a((null):-1)
08-02 13:39:27.591: I/dalvikvm(9942): at maps.k.b.a((null):-1)
08-02 13:39:27.591: I/dalvikvm(9942): at maps.bp.j.a((null):-1)
08-02 13:39:27.591: I/dalvikvm(9942): at maps.bp.j.run((null):-1)
08-02 13:39:27.591: I/dalvikvm(9942): at java.lang.Thread.run(Thread.java:856)
08-02 13:39:27.871: I/dalvikvm-heap(9942): Clamp target GC heap from 48.166MB to 48.000MB
08-02 13:39:27.871: D/dalvikvm(9942): GC_FOR_ALLOC freed 114K, 7% free 45990K/49159K, paused 27ms, total 27ms
08-02 13:39:27.876: W/System.err(9942): OutOfMemory
08-02 13:39:27.921: I/dalvikvm-heap(9942): Clamp target GC heap from 48.219MB to 48.000MB
08-02 13:39:27.921: D/dalvikvm(9942): GC_FOR_ALLOC freed 96K, 7% free 46045K/49159K, paused 37ms, total 37ms
08-02 13:39:27.921: I/dalvikvm-heap(9942): Forcing collection of SoftReferences for 161096-byte allocation
08-02 13:39:27.951: I/dalvikvm-heap(9942): Clamp target GC heap from 48.219MB to 48.000MB
08-02 13:39:27.951: D/dalvikvm(9942): GC_BEFORE_OOM freed <1K, 7% free 46045K/49159K, paused 32ms, total 32ms
08-02 13:39:27.951: E/dalvikvm-heap(9942): Out of memory on a 161096-byte allocation.
08-02 13:39:27.951: I/dalvikvm(9942): "vts_de.martinkeller.bude_app" prio=5 tid=12 RUNNABLE
08-02 13:39:27.951: I/dalvikvm(9942): | group="main" sCount=0 dsCount=0 obj=0x43e75c10 self=0x4cf55070
08-02 13:39:27.951: I/dalvikvm(9942): | sysTid=9968 nice=10 sched=0/0 cgrp=apps/bg_non_interactive handle=1273381224
08-02 13:39:27.956: I/dalvikvm(9942): | schedstat=( 331626402 520498679 805 ) utm=27 stm=5 core=0
08-02 13:39:27.956: I/dalvikvm(9942): at maps.ap.d.a((null):~-1)
08-02 13:39:27.956: I/dalvikvm(9942): at maps.i.ct.a((null):-1)
08-02 13:39:27.956: I/dalvikvm(9942): at maps.k.ah.a((null):-1)
08-02 13:39:27.956: I/dalvikvm(9942): at maps.k.d.a((null):-1)
08-02 13:39:27.956: I/dalvikvm(9942): at maps.k.g.handleMessage((null):-1)
08-02 13:39:27.956: I/dalvikvm(9942): at android.os.Handler.dispatchMessage(Handler.java:99)
08-02 13:39:27.956: I/dalvikvm(9942): at android.os.Looper.loop(Looper.java:137)
08-02 13:39:27.956: I/dalvikvm(9942): at maps.k.d.b((null):-1)
08-02 13:39:27.956: I/dalvikvm(9942): at maps.k.ag.b((null):-1)
08-02 13:39:27.956: I/dalvikvm(9942): at maps.ap.b.run((null):-1)
manchmal auch das hier:
Code:
08-02 14:12:26.986: E/AndroidRuntime(12214): FATAL EXCEPTION: vts_de.martinkeller.bude_app
08-02 14:12:26.986: E/AndroidRuntime(12214): java.lang.OutOfMemoryError
08-02 14:12:26.986: E/AndroidRuntime(12214): at maps.ap.d.a(Unknown Source)
08-02 14:12:26.986: E/AndroidRuntime(12214): at maps.i.ct.a(Unknown Source)
08-02 14:12:26.986: E/AndroidRuntime(12214): at maps.u.u.a(Unknown Source)
08-02 14:12:26.986: E/AndroidRuntime(12214): at maps.m.y.c(Unknown Source)
08-02 14:12:26.986: E/AndroidRuntime(12214): at maps.k.d.a(Unknown Source)
08-02 14:12:26.986: E/AndroidRuntime(12214): at maps.k.d.b(Unknown Source)
08-02 14:12:26.986: E/AndroidRuntime(12214): at maps.k.d.a(Unknown Source)
08-02 14:12:26.986: E/AndroidRuntime(12214): at maps.k.g.handleMessage(Unknown Source)
08-02 14:12:26.986: E/AndroidRuntime(12214): at android.os.Handler.dispatchMessage(Handler.java:99)
08-02 14:12:26.986: E/AndroidRuntime(12214): at android.os.Looper.loop(Looper.java:137)
08-02 14:12:26.986: E/AndroidRuntime(12214): at maps.k.d.b(Unknown Source)
08-02 14:12:26.986: E/AndroidRuntime(12214): at maps.k.ag.b(Unknown Source)
08-02 14:12:26.986: E/AndroidRuntime(12214): at maps.ap.b.run(Unknown Source)
08-02 14:12:34.726: W/SurfaceView(12214): CHECK surface infomation creating=false formatChanged=false sizeChanged=false visible=false visibleChanged=true surfaceChanged=true realSizeChanged=false redrawNeeded=false left=false top=false
Ich komm grad echt nicht mehr weiter...
Hier ein paar Code Ausschnitte:
Code:
final Intent intent1 = new Intent(this, Maps.class);
Hier rufe ich die Map Klasse Auf:
Code:
karte.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Bundle korb = new Bundle();
Bundle korb2 = new Bundle();
korb.putInt("datenpaket1", uebersicht.get(0).getId());
korb2.putString("datenpaket2", "1Bude");
intent1.putExtras(korb);
intent1.putExtras(korb2);
startActivity(intent1);
}
});
Und das hier ist meine maps Klasse
Code:
package de.martinkeller.bude_app;
import java.util.ArrayList;
import java.util.List;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.maps.CameraUpdate;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.LocationSource;
import com.google.android.gms.maps.LocationSource.OnLocationChangedListener;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.LatLngBounds;
import com.google.android.gms.maps.model.MarkerOptions;
import com.google.android.maps.MapView;
import android.location.Criteria;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.FragmentManager;
import android.content.Intent;
import android.content.res.Configuration;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
import android.widget.Toast;
public class Maps extends Activity implements LocationSource, LocationListener {
final int RQS_GooglePlayServices = 1;
MapFragment myMapFragment;
GoogleMap myMap;
LocationManager myLocationManager = null;
OnLocationChangedListener myLocationListener = null;
Criteria myCriteria;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.map);
FragmentManager myFragmentManager = getFragmentManager();
MapFragment myMapFragment = (MapFragment) myFragmentManager
.findFragmentById(R.id.map);
myMap = myMapFragment.getMap();
myMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);
myMap.setMyLocationEnabled(true);
//hole alle Buden aus der DB
Appebene appebene = new Appebene();
final List<Bude> uebersicht = appebene.holeUebersicht();
//Füge alle Buden, die Längen und Breitenangaben haben als POI auf der Map ein
for (int i = 0; i < uebersicht.size(); i++) {
String budeName = uebersicht.get(i).getName();
String positionName = budeName;
positionName.replaceAll(" ", "_");
if (uebersicht.get(i).getY_koordinaten().equals("null")) {
} else {
Double y_kor = Double.parseDouble(uebersicht.get(i)
.getY_koordinaten());
Double x_kor = Double.parseDouble(uebersicht.get(i)
.getX_koordinaten());
final LatLng Bude = new LatLng(y_kor, x_kor);
myMap.addMarker(new MarkerOptions().position(Bude).title(
budeName));
}
}
myCriteria = new Criteria();
myCriteria.setAccuracy(Criteria.ACCURACY_FINE);
myLocationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
}
@Override
public void onLocationChanged(Location location) {
if (myLocationListener != null) {
myLocationListener.onLocationChanged(location);
Bundle zielkorb = getIntent().getExtras();
String warum = zielkorb.getString("datenpaket2");
//starte Funktion anhand der übergebenen Werte
//Bei "1Bude" starte zeigeBude(id)
if (warum.equals("1Bude")) {
int id = zielkorb.getInt("datenpaket1");
zeigeBude(id);
}
//Bei "Navi" starte starteNavi(id, latlng)
else if (warum.equals("Navi")) {
int id = zielkorb.getInt("datenpaket1");
LatLng latlng = new LatLng(location.getLatitude(),
location.getLongitude());
starteNavi(id, latlng);
}
//Ansonsten öffne Karte mit aktueller Position
else {
LatLng latlng = new LatLng(location.getLatitude(),
location.getLongitude());
myMap.animateCamera(CameraUpdateFactory.newLatLngZoom(latlng,
17));
}
}
}
public void starteNavi(int id, LatLng latlng) {
//Funktion startet die Navi Funktion des Handys anhand des aktuellen Standorts zu den Längen
//und Breitengraden der Bude (Informationen anhand der ID)
Appebene appebene = new Appebene();
final List<Bude> uebersicht = appebene.holeBudeInfo(id);
if (uebersicht.get(0).getY_koordinaten().equals("null")) {
final Intent intent1 = new Intent(this, Bude_Info.class);
Bundle korb = new Bundle();
korb.putInt("datenpaket1", uebersicht.get(0).getId());
intent1.putExtras(korb);
startActivity(intent1);
} else {
Double y_kor = Double.parseDouble(uebersicht.get(0)
.getY_koordinaten());
Double x_kor = Double.parseDouble(uebersicht.get(0)
.getX_koordinaten());
Intent navIntent = new Intent(Intent.ACTION_VIEW,
Uri.parse("http://maps.google.com/maps?saddr="
+ latlng.latitude + "," + latlng.longitude
+ "&daddr=" + y_kor + "," + x_kor + ""));
startActivity(navIntent);
}
}
public void zeigeBude(int id) {
//Funktion startet Karte und setzt Position auf die Längen- und Breitengrade der ausgewählten Bude
Appebene appebene = new Appebene();
final List<Bude> uebersicht = appebene.holeBudeInfo(id);
String budeName = uebersicht.get(0).getName();
String positionName = budeName;
positionName.replaceAll(" ", "_");
if (uebersicht.get(0).getY_koordinaten().equals("null")) {
final Intent intent1 = new Intent(this, Bude_Info.class);
Bundle korb = new Bundle();
korb.putInt("datenpaket1", uebersicht.get(0).getId());
intent1.putExtras(korb);
startActivity(intent1);
} else {
Double y_kor = Double.parseDouble(uebersicht.get(0)
.getY_koordinaten());
Double x_kor = Double.parseDouble(uebersicht.get(0)
.getX_koordinaten());
final LatLng Bude = new LatLng(y_kor, x_kor);
myMap.animateCamera(CameraUpdateFactory.newLatLngZoom(Bude, 17));
// myMap.addMarker(new
// MarkerOptions().position(Bude).title(budeName));
final View mapView = getFragmentManager()
.findFragmentById(R.id.map).getView();
if (mapView.getViewTreeObserver().isAlive()) {
mapView.getViewTreeObserver().addOnGlobalLayoutListener(
new OnGlobalLayoutListener() {
@SuppressWarnings("deprecation")
@SuppressLint("NewApi")
// We check which build version we are using.
@Override
public void onGlobalLayout() {
// LatLngBounds bounds = new
// LatLngBounds.Builder()
// .include(Bude).build();
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
mapView.getViewTreeObserver()
.removeGlobalOnLayoutListener(this);
} else {
mapView.getViewTreeObserver()
.removeOnGlobalLayoutListener(this);
}
// myMap.moveCamera(CameraUpdateFactory
// .newLatLngBounds(bounds, 100));
}
});
}
}
}
public void zeigeVieleBuden(String[] id) {
Appebene appebene = new Appebene();
final List<Bude> uebersicht = new ArrayList<Bude>();
for (int i = 0; i < id.length; i++) {
int id2 = Integer.parseInt(id[i]);
List<Bude> test = appebene.holeBudeInfo(id2);
Bude bude = new Bude(test.get(0).getId(), test.get(0).getName(),
test.get(0).getPLZ(), test.get(0).getOrt(), test.get(0)
.getGegruendet(), test.get(0).getMitglieder(), test
.get(0).getY_koordinaten(), test.get(0)
.getX_koordinaten(), null);
uebersicht.set(i, bude);
}
String budeName = uebersicht.get(0).getName();
String positionName = budeName;
positionName.replaceAll(" ", "_");
Double y_kor = Double.parseDouble(uebersicht.get(0).getY_koordinaten());
Double x_kor = Double.parseDouble(uebersicht.get(0).getX_koordinaten());
final LatLng Bude = new LatLng(y_kor, x_kor);
myMap.addMarker(new MarkerOptions().position(Bude).title(budeName));
final View mapView = getFragmentManager().findFragmentById(R.id.map)
.getView();
if (mapView.getViewTreeObserver().isAlive()) {
mapView.getViewTreeObserver().addOnGlobalLayoutListener(
new OnGlobalLayoutListener() {
@SuppressWarnings("deprecation")
@SuppressLint("NewApi")
// We check which build version we are using.
@Override
public void onGlobalLayout() {
LatLngBounds bounds = new LatLngBounds.Builder()
.include(Bude).build();
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
mapView.getViewTreeObserver()
.removeGlobalOnLayoutListener(this);
} else {
mapView.getViewTreeObserver()
.removeOnGlobalLayoutListener(this);
}
myMap.moveCamera(CameraUpdateFactory
.newLatLngBounds(bounds, 50));
}
});
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.startscreen, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_legalnotices:
String LicenseInfo = GooglePlayServicesUtil
.getOpenSourceSoftwareLicenseInfo(getApplicationContext());
AlertDialog.Builder LicenseDialog = new AlertDialog.Builder(this);
LicenseDialog.setTitle("Legal Notices");
LicenseDialog.setMessage(LicenseInfo);
LicenseDialog.show();
return true;
}
return super.onOptionsItemSelected(item);
}
@Override
protected void onResume() {
super.onResume();
int resultCode = GooglePlayServicesUtil
.isGooglePlayServicesAvailable(getApplicationContext());
if (resultCode == ConnectionResult.SUCCESS) {
// Register for location updates using a Criteria, and a callback on
// the specified looper thread.
myLocationManager.requestLocationUpdates(0L, // minTime
0.0f, // minDistance
myCriteria, // criteria
this, // listener
null); // looper
// Replaces the location source of the my-location layer.
myMap.setLocationSource(this);
} else {
GooglePlayServicesUtil.getErrorDialog(resultCode, this,
RQS_GooglePlayServices);
}
}
@Override
protected void onPause() {
myMap.setLocationSource(null);
myLocationManager.removeUpdates(this);
super.onPause();
}
@Override
public void activate(OnLocationChangedListener listener) {
myLocationListener = listener;
}
@Override
public void deactivate() {
myLocationListener = null;
}
@Override
public void onProviderDisabled(String arg0) {
// TODO Auto-generated method stub
}
@Override
public void onProviderEnabled(String arg0) {
// TODO Auto-generated method stub
}
@Override
public void onStatusChanged(String arg0, int arg1, Bundle arg2) {
// TODO Auto-generated method stub
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
}
}
Hier noch die XML-Klasse:
Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity" >
<TextView
android:id="@+id/locinfo"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.MapFragment"/>
</LinearLayout>
Und abschließend noch mein Manifest:
Code:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="de.martinkeller.bude_app"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="16" />
<permission
android:name="de.martinkeller.bude_app.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="de.martinkeller.bude_app.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<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-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<application
android:name="Appebene"
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="de.martinkeller.bude_app.Startscreen"
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="de.martinkeller.bude_app.Menue" >
</activity>
<activity android:name="de.martinkeller.bude_app.Bude_Liste" >
</activity>
<activity android:name="de.martinkeller.bude_app.Bude_Info" >
</activity>
<activity android:name="de.martinkeller.bude_app.Appebene" >
</activity>
<activity
android:name="de.martinkeller.bude_app.Maps"
android:configChanges="orientation|keyboardHidden|screenSize" >
</activity>
<activity android:name="de.martinkeller.bude_app.Suche" >
</activity>
<uses-library android:name="com.google.android.maps" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyDEGKp7kJjbYTrQxe2svHn_45uAuHwMiK0" />
</application>
</manifest>
Wäre top wenn Ihr mir weiterhelfen könntet.
Ich verzweifle grad weil es manchmal klappt ohne probs und manchmal wirfts mich aus google maps raus -_-
Danke!
Grüße
Kellrkind
Zuletzt bearbeitet: