You have a ClassCastException at line 61, its all in logcat

>> 08-12 15:39:02.912: ERROR/AndroidRuntime(548): Caused by:
>> java.lang.ClassCastException: com.example.North.North
>> 08-12 15:39:02.912: ERROR/AndroidRuntime(548):     at
>> com.example.North.North.onCreate(North.java:61)

Whatever is on line 61 isn't the type you think it is.

Cheers,
Justin
Android Team @ Google

On Aug 12, 8:12 am, Declan <dmeen...@gmail.com> wrote:
> I've modified the code a bit since the last time, and now it crashes
> at runtime.
> I've got the log-cat and code below.
> Any suggestions, or links to a tutoiral on how to go about debugging
> would be appreciated.
> Thanks,
> Declan
>
> package com.wissen.android;
>
> import java.util.List;
>
> import android.content.Context;
> import android.graphics.Bitmap;
> import android.graphics.BitmapFactory;
> import android.graphics.Canvas;
> import android.graphics.Paint;
> import android.graphics.Point;
> import android.graphics.drawable.Drawable;
> import android.hardware.SensorManager;
> import android.location.Location;
> import android.location.LocationListener;
> import android.location.LocationManager;
> import android.os.Bundle;
> import android.os.Vibrator;
> import android.util.Config;
> import android.util.Log;
> import android.view.KeyEvent;
> import android.view.ViewGroup;
> import android.view.ViewGroup.LayoutParams;
> import android.widget.Button;
> import android.widget.EditText;
> import android.widget.TextView;
> import android.widget.ZoomControls;
>
> import com.google.android.maps.GeoPoint;
> import com.google.android.maps.MapActivity;
> import com.google.android.maps.MapController;
> import com.google.android.maps.MapView;
> import com.google.android.maps.Overlay;
>
> public class Hello extends MapActivity implements LocationListener {
>         /** Called when the activity is first created. */
>
>         EditText                txted                   = null;
>         Button                  btnSimple               = null;
>         MapView                 gMapView                = null;
>         MapController   mc                              = null;
>         Drawable                defaultMarker   = null;
>         GeoPoint                p                               = null;
>         double                  latitude                = 0.0, longitude = 
> 0.0; // for current location
>         double                  desLat, desLong;// for current destination
>         private SensorManager mSensorManager;
>     private float[] mValues;
>     private static final String TAG = "Compass";
>     // for compasse
>
>         @Override
>         public void onCreate(Bundle savedInstanceState) {
>                 super.onCreate(savedInstanceState);
>                 setContentView(R.layout.main);
>
>                 // makes the field with text
>                 txted = (EditText) findViewById(R.id.id1);
>                 String currentLocation = "Lat: " + latitude + " Lng: " + 
> longitude;
>                 txted.setText(currentLocation);
>                 // Creating and initializing Map
>                 gMapView = (MapView) findViewById(R.id.myGMap);
>                 p = new GeoPoint((int) (latitude * 1000000), (int) (longitude 
> *
> 1000000));
>                 gMapView.setSatellite(true);
>                 mc = gMapView.getController();
>                 mc.setCenter(p);
>                 mc.setZoom(14);
>
>                 /** Add a location mark**/
>                 MyLocationOverlay myLocationOverlay = new MyLocationOverlay();
>                 List<Overlay> list = gMapView.getOverlays();
>                 list.add(myLocationOverlay);
>
>                 // Adding zoom controls to Map
>                 ZoomControls zoomControls = (ZoomControls) 
> gMapView.getZoomControls
> ();
>                 zoomControls.setLayoutParams(new ViewGroup.LayoutParams
> (LayoutParams.WRAP_CONTENT,
>                                 LayoutParams.WRAP_CONTENT));
>
>                 gMapView.addView(zoomControls);
>                 gMapView.displayZoomControls(true);
>
>                 // Getting locationManager and reflecting changes over map if
> distance travel by
>                 // user is greater than 500m from current location.
>                 LocationManager lm = (LocationManager) getSystemService
> (Context.LOCATION_SERVICE);
>                 lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000L,
> 500.0f, this);
>
>         }
>         public void onSensorChanged(int sensor, float[] values) {
>         if (Config.LOGD) Log.d(TAG, "sensorChanged (" + values[0] + ",
> " + values[1] + ", " + values[2] + ")");{
>                 mValues = values;
>                 //Doesn't work, should appear if this section is called,
> never called?
>                 String currentLocation = "Got magnetic
> ==================================";
>
>                 txted.setText(currentLocation);
>
>                 int i=90;
>                 if (mValues != null) {
>                                 if(mValues[0]<i+3&mValues[0]>i-3)
>                         {
>                                         Vibrator vibrator = 
> (Vibrator)getSystemService
> (Context.VIBRATOR_SERVICE);
>                                         vibrator.vibrate((long) 300.0);
>                         }
>                         }
>                         //Code needed to make a compasse vibrate, I should be 
> from baring
> methad
>
> Vibrator vibrator = (Vibrator)getSystemService
> (Context.VIBRATOR_SERVICE);
> vibrator.vibrate((long) 300.0);
>
>         }
>     }
>         /* This method is called when use position will get changed */
>         public void onLocationChanged(Location location) {
>                 if (location != null) {
>                         double lat = location.getLatitude();
>                         double lng = location.getLongitude();
>                         String currentLocation = "Lat: " + lat + " Lng: " + 
> lng;
>                         txted.setText(currentLocation);
>                         p = new GeoPoint((int) lat * 1000000, (int) lng * 
> 1000000);
>                         mc.animateTo(p);
>                         Vibrator vibrator = (Vibrator)getSystemService
> (Context.VIBRATOR_SERVICE);
>                         vibrator.vibrate((long) 300.0);
>                 }
>         }
>
>         public void onProviderDisabled(String provider) {
>                 // required for interface, not used
>         }
>
>         public void onProviderEnabled(String provider) {
>                 // required for interface, not used
>         }
>
>         public void onStatusChanged(String provider, int status, Bundle
> extras) {
>                 // required for interface, not used
>         }
>
>         protected boolean isRouteDisplayed() {
>                 // TODO Auto-generated method stub
>                 return false;
>         }
>
>         /* User can zoom in/out using keys provided on keypad*/
>         public boolean onKeyDown(int keyCode, KeyEvent event) {
>                 if (keyCode == KeyEvent.KEYCODE_I) {
>                         
> gMapView.getController().setZoom(gMapView.getZoomLevel() + 1);
>                         return true;
>                 } else if (keyCode == KeyEvent.KEYCODE_O) {
>                         
> gMapView.getController().setZoom(gMapView.getZoomLevel() - 1);
>                         return true;
>                 } else if (keyCode == KeyEvent.KEYCODE_S) {
>                         gMapView.setSatellite(true);
>                         return true;
>                 } else if (keyCode == KeyEvent.KEYCODE_T) {
>                         gMapView.setTraffic(true);
>                         return true;
>                 }
>                 return false;
>         }
>
>         /* Class overload draw method which actually plot a marker,text etc.
> on Map */
>         protected class MyLocationOverlay extends
> com.google.android.maps.Overlay {
>
>                 @Override
>                 public boolean draw(Canvas canvas, MapView mapView, boolean 
> shadow,
> long when) {
>                         Paint paint = new Paint();
>
>                         super.draw(canvas, mapView, shadow);
>                         // Converts lat/lng-Point to OUR coordinates on the 
> screen.
>                         Point myScreenCoords = new Point();
>                         mapView.getProjection().toPixels(p, myScreenCoords);
>
>                         paint.setStrokeWidth(1);
>                         paint.setARGB(255, 255, 255, 255);
>                         paint.setStyle(Paint.Style.STROKE);
>
>                         Bitmap bmp = 
> BitmapFactory.decodeResource(getResources(),
> R.drawable.marker);
>
>                         canvas.drawBitmap(bmp, myScreenCoords.x, 
> myScreenCoords.y, paint);
>                         canvas.drawText("I am here...", myScreenCoords.x, 
> myScreenCoords.y,
> paint);
>                         return true;
>                 }
>         }
>
> }
>
> 08-12 15:39:02.892: ERROR/AndroidRuntime(548): Uncaught handler:
> thread main exiting due to uncaught exception
> 08-12 15:39:02.912: ERROR/AndroidRuntime(548):
> java.lang.RuntimeException: Unable to start activity ComponentInfo
> {com.example.North/com.example.North.North}:
> java.lang.ClassCastException: com.example.North.North
> 08-12 15:39:02.912: ERROR/AndroidRuntime(548):     at
> android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
> 2268)
> 08-12 15:39:02.912: ERROR/AndroidRuntime(548):     at
> android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:
> 2284)
> 08-12 15:39:02.912: ERROR/AndroidRuntime(548):     at
> android.app.ActivityThread.access$1800(ActivityThread.java:112)
> 08-12 15:39:02.912: ERROR/AndroidRuntime(548):     at
> android.app.ActivityThread$H.handleMessage(ActivityThread.java:1692)
> 08-12 15:39:02.912: ERROR/AndroidRuntime(548):     at
> android.os.Handler.dispatchMessage(Handler.java:99)
> 08-12 15:39:02.912: ERROR/AndroidRuntime(548):     at
> android.os.Looper.loop(Looper.java:123)
> 08-12 15:39:02.912: ERROR/AndroidRuntime(548):     at
> android.app.ActivityThread.main(ActivityThread.java:3948)
> 08-12 15:39:02.912: ERROR/AndroidRuntime(548):     at
> java.lang.reflect.Method.invokeNative(Native Method)
> 08-12 15:39:02.912: ERROR/AndroidRuntime(548):     at
> java.lang.reflect.Method.invoke(Method.java:521)
> 08-12 15:39:02.912: ERROR/AndroidRuntime(548):     at
> com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
> (ZygoteInit.java:782)
> 08-12 15:39:02.912: ERROR/AndroidRuntime(548):     at
> com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
> 08-12 15:39:02.912: ERROR/AndroidRuntime(548):     at
> dalvik.system.NativeStart.main(Native Method)
> 08-12 15:39:02.912: ERROR/AndroidRuntime(548): Caused by:
> java.lang.ClassCastException: com.example.North.North
> 08-12 15:39:02.912: ERROR/AndroidRuntime(548):     at
> com.example.North.North.onCreate(North.java:61)
> 08-12 15:39:02.912: ERROR/AndroidRuntime(548):     at
> android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:
> 1123)
> 08-12 15:39:02.912: ERROR/AndroidRuntime(548):     at
> android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
> 2231)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to