app has stopped unexceptedly with GeoPoint

Put problem concerning MapActivities, MapViews, Overlays and GPS in this forum.

app has stopped unexceptedly with GeoPoint

Postby damninggodson » Thu Mar 25, 2010 3:57 am

Hi everyone:
take a look at the following code:
Code: Select all
package com.android.test;

import com.google.android.maps.GeoPoint;

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

public class test extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        setGeoPoint();
    }
   
   private GeoPoint[] station_geo;

    private void setGeoPoint() {
      try {
         station_geo[0] = new GeoPoint((int) (39.902420 * 1000000),
               (int) (116.425728 * 1000000));
         station_geo[1] = new GeoPoint((int) (39.895458 * 1000000),
               (int) (116.321274 * 1000000));
         }
                catch (Exception e) {
         Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show();
                                   }
   }
}


when i run this app on the android emulator, an alertdialog occurred 'the application test has stopped unexceptedly. please try again.' as a rookie in android dev, i don't quite catch it. what's the problem here? thanks for ur help!
damninggodson
Developer
Developer
 
Posts: 36
Joined: Thu Mar 25, 2010 3:36 am

Top

Re: app has stopped unexceptedly with GeoPoint

Postby hwrdprkns » Thu Mar 25, 2010 8:28 pm

damninggodson wrote:Hi everyone:
take a look at the following code:
Code: Select all
package com.android.test;

import com.google.android.maps.GeoPoint;

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

public class test extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        setGeoPoint();
    }
   
   private GeoPoint[] station_geo;

    private void setGeoPoint() {
      try {
         station_geo[0] = new GeoPoint((int) (39.902420 * 1000000),
               (int) (116.425728 * 1000000));
         station_geo[1] = new GeoPoint((int) (39.895458 * 1000000),
               (int) (116.321274 * 1000000));
         }
                catch (Exception e) {
         Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show();
                                   }
   }
}


when i run this app on the android emulator, an alertdialog occurred 'the application test has stopped unexceptedly. please try again.' as a rookie in android dev, i don't quite catch it. what's the problem here? thanks for ur help!



Try using the DDMS tool in the ~\android*\tools directory, taht should give you some more information on the error. You should see a bunch of red text and then the error at some line in test.java
The more you learn, the less you know.
hwrdprkns
Junior Developer
Junior Developer
 
Posts: 15
Joined: Wed Nov 25, 2009 8:14 am

Postby vik » Tue Mar 30, 2010 1:55 pm

what your logcat shows ?? if you can put it here that might help solving
User avatar
vik
Senior Developer
Senior Developer
 
Posts: 141
Joined: Wed Sep 09, 2009 7:32 am

Postby damninggodson » Thu Apr 01, 2010 7:57 am

thx for the 2 replies!

someone helped me find the problems this morning, it's because i didn't add
Code: Select all
<uses-library android:name="com.google.android.maps"/>
in my code and i made mistakes when i was declaring an array of GeoPoint, it should be like this:
Code: Select all
GeoPoint[] station_geo = new GeoPoint[n];// n is the num of elements in the array


so mission clear~ hope this post can be useful to others who meet the same troubles in the future.cheers.
damninggodson
Developer
Developer
 
Posts: 36
Joined: Thu Mar 25, 2010 3:36 am

Top

Return to Map Problems

Who is online

Users browsing this forum: No registered users and 5 guests