Football Fans: Download the 2012 Schedule App from Google Play!


Go Back   Android Forums > Android Discussion > Android Applications

Android Applications All the information you could ever want about Android Applications. Learn about apps and get help with them... all here! New apps can be found and announced in the Applications Announcements forum linked below.



Reply
 
LinkBack Thread Tools
Old January 18th, 2010, 03:10 PM   #1 (permalink)
New Member
 
Join Date: Jan 2010
Posts: 4
 
Device(s):
Thanks: 0
Thanked 0 Times in 0 Posts
Default Android application Crashes

hello everyone,

I am very new to android programming. i was following a guide in here, to create an application that shows the current location, i did as was told in the guide, but whenever i try to run it, it crashes, and asks for "force Close",
does somebody know what i am doing wrong? here is the code:
Code:
package pro.googleLocation;

import android.app.Activity;
import android.content.Context;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.widget.TextView;

public class Finder extends Activity {
    /** Called when the activity is first created. */
    private LocationManager myLocationManager;
    private LocationListener myLocationListener;
    private TextView myLatitude, myLongitude;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        myLatitude = (TextView)findViewById(R.id.Latitude);
        myLongitude = (TextView)findViewById(R.id.Longitude);

        myLocationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
        myLocationListener = new MyLocationListener();
        myLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,0,0,myLocationListener);
        myLatitude.setText(String.valueOf(
                  myLocationManager.getLastKnownLocation(
                    LocationManager.GPS_PROVIDER).getLatitude()));

                myLongitude.setText(String.valueOf(
                 myLocationManager.getLastKnownLocation(
                   LocationManager.GPS_PROVIDER).getLongitude()));
    }
    private class MyLocationListener implements LocationListener{

        public void onLocationChanged(Location argLocation) {
        // TODO Auto-generated method stub
        myLatitude.setText(String.valueOf(
          argLocation.getLatitude()));
        myLongitude.setText(String.valueOf(
          argLocation.getLongitude()));
        }

        public void onProviderDisabled(String provider) {
        // TODO Auto-generated method stub
        }

        public void onProviderEnabled(String provider) {
        // TODO Auto-generated method stub
        }

        public void onStatusChanged(String provider,
         int status, Bundle extras) {
        // TODO Auto-generated method stub
        }
        };
        
}
log cat shows something like this:
Code:
01-18 22:12:46.017: WARN/dalvikvm(1091): threadid=3: thread exiting with uncaught exception (group=0x4001aa28)
01-18 22:12:46.017: ERROR/AndroidRuntime(1091): Uncaught handler: thread main exiting due to uncaught exception
01-18 22:12:46.037: ERROR/AndroidRuntime(1091): java.lang.RuntimeException: Unable to start activity ComponentInfo{pro.googleLocation/pro.googleLocation.Finder}: java.lang.NullPointerException
01-18 22:12:46.037: ERROR/AndroidRuntime(1091):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2401)
01-18 22:12:46.037: ERROR/AndroidRuntime(1091):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2417)
01-18 22:12:46.037: ERROR/AndroidRuntime(1091):     at android.app.ActivityThread.access$2100(ActivityThread.java:116)
01-18 22:12:46.037: ERROR/AndroidRuntime(1091):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
01-18 22:12:46.037: ERROR/AndroidRuntime(1091):     at android.os.Handler.dispatchMessage(Handler.java:99)
01-18 22:12:46.037: ERROR/AndroidRuntime(1091):     at android.os.Looper.loop(Looper.java:123)
01-18 22:12:46.037: ERROR/AndroidRuntime(1091):     at android.app.ActivityThread.main(ActivityThread.java:4203)
01-18 22:12:46.037: ERROR/AndroidRuntime(1091):     at java.lang.reflect.Method.invokeNative(Native Method)
01-18 22:12:46.037: ERROR/AndroidRuntime(1091):     at java.lang.reflect.Method.invoke(Method.java:521)
01-18 22:12:46.037: ERROR/AndroidRuntime(1091):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
01-18 22:12:46.037: ERROR/AndroidRuntime(1091):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
01-18 22:12:46.037: ERROR/AndroidRuntime(1091):     at dalvik.system.NativeStart.main(Native Method)
01-18 22:12:46.037: ERROR/AndroidRuntime(1091): Caused by: java.lang.NullPointerException
01-18 22:12:46.037: ERROR/AndroidRuntime(1091):     at pro.googleLocation.Finder.onCreate(Finder.java:28)
01-18 22:12:46.037: ERROR/AndroidRuntime(1091):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
01-18 22:12:46.037: ERROR/AndroidRuntime(1091):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2364)
01-18 22:12:46.037: ERROR/AndroidRuntime(1091):     ... 11 more

Deewanagan is offline  
Last edited by Deewanagan; January 18th, 2010 at 03:19 PM.
Reply With Quote
Sponsors
Old January 18th, 2010, 06:28 PM   #2 (permalink)
New Member
 
Join Date: Jan 2010
Posts: 4
 
Device(s):
Thanks: 0
Thanked 0 Times in 0 Posts
Default

found the problem. it crashed because the lat/longitude value wasn't being passed to the emulator.
Deewanagan is offline  
Reply With Quote
Reply

Bookmarks

Tags
android emulator


Go Back   Android Forums > Android Discussion > Android Applications User CP
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
selecting contact crashes android.core.... nandroido Vibrant - Support and Troubleshooting 0 September 18th, 2010 12:45 PM
GW620 Crashes & Crashes & Crashes..... James24 Eve - Support and Troubleshooting 2 July 12th, 2010 07:11 AM
Bitmap Scaling crashes application fat-wednesday Developer 101 0 March 26th, 2010 02:36 PM
Phone crashes when Camera application launched sampablokuper G1 - Support 6 November 27th, 2009 09:06 PM



All times are GMT -5. The time now is 01:21 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Custom vBulletin Skins by: Relivo