Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
HelloGoogleMaps : getting error instead of AlertDialog display
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  10 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
yodaa  
View profile  
 More options Feb 24 2010, 10:23 am
From: yodaa <yodaa...@gmail.com>
Date: Wed, 24 Feb 2010 07:23:03 -0800 (PST)
Local: Wed, Feb 24 2010 10:23 am
Subject: [tutotial] HelloGoogleMaps : getting error instead of AlertDialog display
Hi,

I followed the Google Map View tutorial located at:
http://developer.android.com/resources/tutorials/views/hello-mapview....

I'm running Eclipse Galileo (up to date) under Windows XP SP3.

The tutorial projet  is runs within the emulator but clicking on one
of the drawable "androidmarker" positionned on the map leads to the
following Error message:

Sorry!
The applications HelloGoogleMaps (process com.tests) has stopped
unexpectedly. Please try again.

1 ) File :AndroidManifest.xml :
----------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.tests"
      android:versionCode="1"
      android:versionName="1.0">
    <application android:icon="@drawable/icon" android:label="@string/
app_name">
    <uses-library android:name="com.google.android.maps" />
        <activity android:name=".HelloGoogleMaps"
                  android:label="@string/app_name"
                                  android:theme="@android:style/Theme.NoTitleBar">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category
android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-sdk android:minSdkVersion="7" />
</manifest>
2 ) File : res/layout/main.xml :
----------------------------------------------------
<?xml version="1.0" encoding="utf-8" ?>
<com.google.android.maps.MapView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/mapview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:clickable="true"
    android:apiKey="myapikey..." />

3 ) File : HelloGoogleMaps.java :
----------------------------------------------------
package com.tests;

import java.util.List;

import android.graphics.drawable.Drawable;
import android.os.Bundle;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;
import com.google.android.maps.OverlayItem;

public class HelloGoogleMaps extends MapActivity
{
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        MapView mapView = (MapView) findViewById(R.id.mapview);
        mapView.setBuiltInZoomControls(true);
        List<Overlay> mapOverlays = mapView.getOverlays();
        Drawable drawable =
this.getResources().getDrawable(R.drawable.androidmarker);
        HelloItemizedOverlay itemizedoverlay = new
HelloItemizedOverlay(drawable);
        GeoPoint point = new GeoPoint(19240000,-99120000);
        OverlayItem overlayitem = new OverlayItem(point, "Hola,
Mundo!", "I'm in Mexico City!");
        itemizedoverlay.addOverlay(overlayitem);
        mapOverlays.add(itemizedoverlay);
    }
    @Override
    protected boolean isRouteDisplayed()
    {
        return false;
    }

}

4 ) File : HelloItemizedOverlay.java :
----------------------------------------------------
package com.tests;

import java.util.ArrayList;
import android.app.AlertDialog;
import android.content.Context;
import android.graphics.drawable.Drawable;
import com.google.android.maps.ItemizedOverlay;
import com.google.android.maps.OverlayItem;

public class HelloItemizedOverlay extends ItemizedOverlay
{
        private ArrayList<OverlayItem> mOverlays = new
ArrayList<OverlayItem>();
        private Context mContext;
        // First constructor
        public HelloItemizedOverlay(Drawable defaultMarker)
        {
                super(boundCenterBottom(defaultMarker));
        }
        // Second constructor
        public HelloItemizedOverlay(Drawable defaultMarker, Context context)
        {
                  super(defaultMarker);
                  mContext = context;
        }
        public void addOverlay(OverlayItem overlay)
        {
            mOverlays.add(overlay);
            populate();
        }
        @Override
        protected OverlayItem createItem(int i)
        {
          return mOverlays.get(i);
        }
        @Override
        public int size()
        {
          return mOverlays.size();
        }
        @Override
        protected boolean onTap(int index)
        {
          OverlayItem item = mOverlays.get(index);
          AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);
          dialog.setTitle(item.getTitle());
          dialog.setMessage(item.getSnippet());
          dialog.show();
          return true;
        }

}

I suspect something gone wrong within the "onTap" method of
"HelloItemizedOverlay"...

Could anyone give me a clue on that?
Thanks


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "[tutotial] HelloGoogleMaps : getting error instead of AlertDialog display" by TreKing
TreKing  
View profile  
 More options Feb 24 2010, 4:15 pm
From: TreKing <treking...@gmail.com>
Date: Wed, 24 Feb 2010 15:15:14 -0600
Local: Wed, Feb 24 2010 4:15 pm
Subject: Re: [android-beginners] [tutotial] HelloGoogleMaps : getting error instead of AlertDialog display

On Wed, Feb 24, 2010 at 9:23 AM, yodaa <yodaa...@gmail.com> wrote:
> I suspect something gone wrong within the "onTap" method of
> "HelloItemizedOverlay"...

> Could anyone give me a clue on that?

What's the stack trace at the point of the exception? That's your best bet.

--------------------------------------------------------------------------- ----------------------
TreKing - Chicago transit tracking app for Android-powered devices
http://sites.google.com/site/rezmobileapps/treking


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "HelloGoogleMaps : getting error instead of AlertDialog display" by yodaa
yodaa  
View profile  
 More options Feb 27 2010, 8:10 am
From: yodaa <yodaa...@gmail.com>
Date: Sat, 27 Feb 2010 05:10:34 -0800 (PST)
Local: Sat, Feb 27 2010 8:10 am
Subject: Re: [tutotial] HelloGoogleMaps : getting error instead of AlertDialog display
thanks for your reply

I started the adb command line in the Windows XP shell:

C:\xxx\tools\adb logcat

and ran my "HelloGoogleMaps" project.The maps showed up within the
emulator with the androidmarker icon as ususal, I clicked on it and
encountered the error message mentionned earlier.

The log gave me the following "traces":

D/dalvikvm(  191): GC freed 875 objects / 121384 bytes in 214ms
D/AndroidRuntime(  191): Shutting down VM
W/dalvikvm(  191): threadid=3: thread exiting with uncaught exception
(group=0x4001b188)
E/AndroidRuntime(  191): Uncaught handler: thread main exiting due to
uncaught exception
D/dalvikvm(  191): GC freed 945 objects / 464808 bytes in 181ms
E/AndroidRuntime(  191): java.lang.NullPointerException
E/AndroidRuntime(  191):        at
com.android.internal.app.AlertController
$AlertParams.<init>(AlertController.java:753)
E/AndroidRuntime(  191):        at android.app.AlertDialog
$Builder.<init>(AlertDialog.java:273)
E/AndroidRuntime(  191):        at
com.tests.HelloItemizedOverlay.onTap(HelloItemizedOverlay.java:45)
E/AndroidRuntime(  191):        at
com.google.android.maps.ItemizedOverlay.onTap(ItemizedOverlay.java:
453)
E/AndroidRuntime(  191):        at
com.google.android.maps.OverlayBundle.onTap(OverlayBundle.java:83)
E/AndroidRuntime(  191):        at com.google.android.maps.MapView
$1.onSingleTapUp(MapView.java:346)
E/AndroidRuntime(  191):        at
android.view.GestureDetector.onTouchEvent(GestureDetector.java:506)
E/AndroidRuntime(  191):        at
com.google.android.maps.MapView.onTouchEvent(MapView.java:628)
E/AndroidRuntime(  191):        at
android.view.View.dispatchTouchEvent(View.java:3709)
E/AndroidRuntime(  191):        at
android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:852)
E/AndroidRuntime(  191):        at
android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
E/AndroidRuntime(  191):        at
android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
E/AndroidRuntime(  191):        at
com.android.internal.policy.impl.PhoneWindow$
DecorView.superDispatchTouchEvent(PhoneWindow.java:1659)
E/AndroidRuntime(  191):        at
com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneW indow.java:
1107)
E/AndroidRuntime(  191):        at
android.app.Activity.dispatchTouchEvent(Activity.java:2061)
E/AndroidRuntime(  191):        at
com.android.internal.policy.impl.PhoneWindow$
DecorView.dispatchTouchEvent(PhoneWindow.java:1643)
E/AndroidRuntime(  191):        at
android.view.ViewRoot.handleMessage(ViewRoot.java:1691)
E/AndroidRuntime(  191):        at
android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(  191):        at android.os.Looper.loop(Looper.java:
123)
E/AndroidRuntime(  191):        at
android.app.ActivityThread.main(ActivityThread.java:4363)
E/AndroidRuntime(  191):        at
java.lang.reflect.Method.invokeNative(NativeMethod)
E/AndroidRuntime(  191):        at
java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime(  191):        at com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:860)
E/AndroidRuntime(  191):        at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
E/AndroidRuntime(  191):        at
dalvik.system.NativeStart.main(Native Method)
I/Process (   57): Sending signal. PID: 191 SIG: 3
I/dalvikvm(  191): threadid=7: reacting to signal 3
I/dalvikvm(  191): Wrote stack trace to '/data/anr/traces.txt'

It seems like something happens with AlertDialog.Builder...
Help would be appreciated

On 24 fév, 22:15, TreKing <treking...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
gino@DeviceDriven  
View profile  
 More options Feb 27 2010, 11:15 pm
From: "gino@DeviceDriven" <ginokur...@gmail.com>
Date: Sat, 27 Feb 2010 20:15:08 -0800 (PST)
Local: Sat, Feb 27 2010 11:15 pm
Subject: Re: HelloGoogleMaps : getting error instead of AlertDialog display
yodaa

i trust you have given the map api key in your layout .xml correctly??
as per your logcat o/p your error is in line no 54 in
theHelloItemizedOverlay class
check it...ya point out the line...

Reagrds
gino

On Feb 27, 6:10 pm, yodaa <yodaa...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Vadid Valiulla  
View profile  
 More options Feb 25 2010, 11:48 pm
From: Vadid Valiulla <its.va...@gmail.com>
Date: Thu, 25 Feb 2010 20:48:52 -0800 (PST)
Local: Thurs, Feb 25 2010 11:48 pm
Subject: Re: HelloGoogleMaps : getting error instead of AlertDialog display
hi Yodaa,

i guess your problem is with calling the HelloItemizedOverlay(Drawable
defaultMarker, Context context) constructor... u r calling the wrong
constructoe as u have made 2 constructors in the class..

Secondly i would like to point out that its better you keep only one
constructor and change it as i have mentioned below...
m sure this will solve your problem...

public HelloItemizedOverlay(Drawable defaultMarker, Context context)
        {
                  super(boundCenterBottom(defaultMarker));
                  mContext = context;
        }

Take care....


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Vadid Valiulla  
View profile  
 More options Feb 25 2010, 11:52 pm
From: Vadid Valiulla <its.va...@gmail.com>
Date: Thu, 25 Feb 2010 20:52:28 -0800 (PST)
Local: Thurs, Feb 25 2010 11:52 pm
Subject: Re: HelloGoogleMaps : getting error instead of AlertDialog display
Actually your problem is that the Dialog is not getting the correct
context... Coz the constructor u initialized doesnt have the context
passed to it... Check that and i suppose your problem should get
solved...

sorry 4 sending another message i forgot to mention the reason i gave
the re-defined constructor...

Take care...


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
yodaa  
View profile  
 More options Mar 4 2010, 2:44 pm
From: yodaa <yodaa...@gmail.com>
Date: Thu, 4 Mar 2010 11:44:47 -0800 (PST)
Local: Thurs, Mar 4 2010 2:44 pm
Subject: Re: HelloGoogleMaps : getting error instead of AlertDialog display
@Vavid

Yep, you're absolutely right about the constructor. The relevent
Context wasn't passed as a  parameter to new HelloItemized objet.
Something is not clear to me in this tutorial: what is the Context I
should pass to the HelloItemized objet? Tutorial URL:
http://developer.android.com/resources/tutorials/views/hello-mapview....

I tried the following (but this did nothing and my android marker has
disappeared...):

1 ) File HelloGoogleMaps.java:
-------------------------------------------------
package com.tests;

import java.util.List;

import android.graphics.drawable.Drawable;
import android.os.Bundle;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;
import com.google.android.maps.OverlayItem;

public class HelloGoogleMaps extends MapActivity
{
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        MapView mapView = (MapView) findViewById(R.id.mapview);
        mapView.setBuiltInZoomControls(true);

        List<Overlay> mapOverlays = mapView.getOverlays();
        Drawable drawable =
this.getResources().getDrawable(R.drawable.androidmarker);
        HelloItemizedOverlay itemizedoverlay = new
HelloItemizedOverlay(drawable,this);
        GeoPoint point = new GeoPoint(19240000,-99120000);
        OverlayItem overlayitem = new OverlayItem(point, "Hola,
Mundo!", "I'm in Mexico City!");

        itemizedoverlay.addOverlay(overlayitem);
        mapOverlays.add(itemizedoverlay);
    }
    @Override
    protected boolean isRouteDisplayed()
    {
        return false;
    }

}

2 ) File : HelloItemizedOverlay.java :
----------------------------------------------------
package com.tests;

import java.util.ArrayList;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.Context;
import android.graphics.drawable.Drawable;
import com.google.android.maps.ItemizedOverlay;
import com.google.android.maps.OverlayItem;

public class HelloItemizedOverlay extends ItemizedOverlay
{
        private ArrayList<OverlayItem> mOverlays = new
ArrayList<OverlayItem>();
        private Context mContext;

        public HelloItemizedOverlay(Drawable defaultMarker, Context context)
        {
                  super(defaultMarker);
                  mContext = context;
        }

        public void addOverlay(OverlayItem overlay)
        {
            mOverlays.add(overlay);
            populate();
        }
        @Override
        protected OverlayItem createItem(int i)
        {
          return mOverlays.get(i);
        }
        @Override
        public int size()
        {
          return mOverlays.size();
        }
        @Override
        protected boolean onTap(int index)
        {
          OverlayItem item = mOverlays.get(index);
          AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);
          dialog.setTitle(item.getTitle());
          dialog.setMessage(item.getSnippet());
          dialog.show();
          return true;
        }

}

Help would be appreciated...

On 26 fév, 05:52, Vadid Valiulla <its.va...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Javadid  
View profile  
 More options Mar 6 2010, 12:13 am
From: Javadid <its.va...@gmail.com>
Date: Fri, 5 Mar 2010 21:13:42 -0800 (PST)
Local: Sat, Mar 6 2010 12:13 am
Subject: Re: HelloGoogleMaps : getting error instead of AlertDialog display
Your coding is fine AFAIK... but can u be more specific... i mean wat
is the logged error u r getting...
sometimes i have seen that just clicking on the map or invalidating
the map results in the display of the pin...
try shifting the map a little... if it doesnt work, pass me the error
generated in the logs...

regards,

P.S. - My names "Vadid" dude...

On Mar 5, 12:44 am, yodaa <yodaa...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
jvr  
View profile  
 More options Mar 4 2010, 9:09 am
From: jvr <jorgvanros...@gmail.com>
Date: Thu, 4 Mar 2010 06:09:34 -0800 (PST)
Local: Thurs, Mar 4 2010 9:09 am
Subject: Re: HelloGoogleMaps : getting error instead of AlertDialog display
I had the same problem.

i solved it by changing the following:

in HelloGoogleMaps,java:

HelloItemizedOverlay itemizedoverlay = new
HelloItemizedOverlay(drawable);

replace by:

HelloItemizedOverlay itemizedoverlay = new
HelloItemizedOverlay(drawable, this);

and in HelloItemizedOverlay.java change the new constructor with the
boundCenterBottom method to see the marker:

        public HelloItemizedOverlay(Drawable defaultMarker, Context
context)
        {
                  super(boundCenterBottom(defaultMarker));
                  mContext = context;
        }

On 24 feb, 16:23, yodaa <yodaa...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
yodaa  
View profile  
 More options Mar 8 2010, 6:06 pm
From: yodaa <yodaa...@gmail.com>
Date: Mon, 8 Mar 2010 15:06:13 -0800 (PST)
Local: Mon, Mar 8 2010 6:06 pm
Subject: Re: HelloGoogleMaps : getting error instead of AlertDialog display
@jvr: thanks for the tip, now the android marker icon appears
correctly using in HelloItemizedOverlay constructor:

/*
* file: "HelloItemizedOverlay.java"
*/
// Class constructor
public HelloItemizedOverlay(Drawable defaultMarker, Context context)
{
      super(boundCenterBottom(defaultMarker));
      mContext = context;

}

I wonder how the Drawable is positionned if no method is applied
(boundCenter or boundCenterBottom)... Because the drawable icon was'nt
visible..at all without passing it to the  boundCenterBottom method.

For the main application, I've either tryied to pass
"this.getApplicationContext" and "this" as Context, but only the
following version works (this is still unclear for me...):

/*
* file: "HelloGoogleMaps.java"
*/
// ...
HelloItemizedOverlay itemizedoverlay = new
HelloItemizedOverlay(drawable,this);
// ...

@Vadid: thx for the feedback and sorry for misspelling your name...

Complete (tested) code below:

1 ) HelloGoogleMaps.java
-------------------------------------------------
package com.tests;

import java.util.List;

import android.graphics.drawable.Drawable;
import android.os.Bundle;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;
import com.google.android.maps.OverlayItem;

public class HelloGoogleMaps extends MapActivity
{
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        MapView mapView = (MapView) findViewById(R.id.mapview);
        mapView.setBuiltInZoomControls(true);

        List<Overlay> mapOverlays = mapView.getOverlays();
        Drawable drawable =
this.getResources().getDrawable(R.drawable.androidmarker);
        HelloItemizedOverlay itemizedoverlay = new
HelloItemizedOverlay(drawable,this);
        GeoPoint point = new GeoPoint(19240000,-99120000);
        OverlayItem overlayitem = new OverlayItem(point, "Hola,
Mundo!", "I'm in Mexico City!");

        GeoPoint point2 = new GeoPoint(35410000, 139460000);
        OverlayItem overlayitem2 = new OverlayItem(point2, "Sekai,
konichiwa!", "I'm in Japan!");

        itemizedoverlay.addOverlay(overlayitem);
        itemizedoverlay.addOverlay(overlayitem2);

        mapOverlays.add(itemizedoverlay);
    }
    @Override
    protected boolean isRouteDisplayed()
    {
        return false;
    }

}

2 ) HelloItemizedOverlay.java
-------------------------------------------------
package com.tests;

import java.util.ArrayList;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.Context;
import android.graphics.drawable.Drawable;
import com.google.android.maps.ItemizedOverlay;
import com.google.android.maps.OverlayItem;

public class HelloItemizedOverlay extends ItemizedOverlay
{
        private ArrayList<OverlayItem> mOverlays = new
ArrayList<OverlayItem>();
        private Context mContext;

        public HelloItemizedOverlay(Drawable defaultMarker, Context context)
        {
                super(boundCenterBottom(defaultMarker));
                mContext = context;
        }

        public void addOverlay(OverlayItem overlay)
        {
            mOverlays.add(overlay);
            populate();
        }
        @Override
        protected OverlayItem createItem(int i)
        {
          return mOverlays.get(i);
        }
        @Override
        public int size()
        {
          return mOverlays.size();
        }
        @Override
        protected boolean onTap(int index)
        {
          OverlayItem item = mOverlays.get(index);
          AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);
          dialog.setTitle(item.getTitle());
          dialog.setMessage(item.getSnippet());
          dialog.show();
          return true;
        }

}

Thanks again guys

On 4 mar, 15:09, jvr <jorgvanros...@gmail.com> wrote:

...

read more »


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »