0

嗨,这段代码基本上是在程序加载时获取地图位置并输入地址(例如纬度、经度和地址显示)到数据库中。但是,我无法让程序工作,因为它在进入代码的异步部分后崩溃。

public class LocationActivity extends MapActivity implements LocationListener{
        /** Called when the activity is first created. */
        MapView map;
        long start;
        long stop;
        MyLocationOverlay compass;
        MapController controller;
        List<Overlay> overlayList;
        int x, y;
        int lat = 0;
        int longi = 0;
        GeoPoint touchedPoint;
        Drawable d;
        LocationManager lm;
        String towers;
        String location_name1;
        String latitude1;
        String longtitude1;
        String location_description1;

        private ProgressDialog pDialog;

        JSONParser jsonParser = new JSONParser();

        private static String url_create_record = "http://localhost/android_connect/create_location.php";

        private static final String TAG_SUCCESS = "success";

        @Override
        public void onCreate(Bundle savedInstanceState){
            super.onCreate(savedInstanceState);
            setContentView(R.layout.location_layout);
            map = (MapView)findViewById(R.id.mvMain);
            map.setBuiltInZoomControls(true);

            Touch t = new Touch();
            overlayList = map.getOverlays();
            overlayList.add(t);
            compass = new MyLocationOverlay(LocationActivity.this, map);
            overlayList.add(compass);
            controller = map.getController();
            GeoPoint point = new GeoPoint(1367060, 103805416);
            controller.animateTo(point);
            controller.setZoom(6);

            d = getResources().getDrawable(R.drawable.songs_gray);

            //Placing pinpoint at location
            lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
            Criteria crit = new Criteria();

            towers = lm.getBestProvider(crit, false);
            Location location = lm.getLastKnownLocation(towers);

            if(location !=null){
                Log.e("Activity", "Location is not null");
                lat = (int) (location.getLatitude()*1E6);
                longi = (int) (location.getLongitude()*1E6);
                GeoPoint ourLocation = new GeoPoint(lat, longi);
                OverlayItem overlayItem = new OverlayItem(ourLocation, "What's up", "2nd String");
                CustomPinpoint custom = new CustomPinpoint(d, LocationActivity.this);
                custom.insertPinPoint(overlayItem);
                overlayList.add(custom);

                latitude1 = new Integer(lat).toString();
                longtitude1 = new Integer(longi).toString();

                Log.e("Activity", "Latitude/ Longitutde " + latitude1 + longtitude1);
                Geocoder geocoder = new Geocoder(getBaseContext(), Locale.getDefault());
                try{
                    Log.e("Activity", "Try to get activity");
                    List<Address> address = geocoder.getFromLocation(location.getLatitude(), location.getLongitude(), 1);
                    Log.e("Activity", "List Address: " + address);
                    if(address.size() > 0){
                        Log.e("Activity", "Address.size: ");
                        String display = "";
                        for (int i = 0; i <= address.get(0).getMaxAddressLineIndex(); i++){                     
                            Log.e("Activity", "Enter loop:");
                            display += address.get(0).getAddressLine(i) + "\n";
                        }
                        Log.e("Activity", "Display: " + display);
                        Toast s = Toast.makeText(getBaseContext(), display, Toast.LENGTH_LONG);
                        s.show();
                        location_name1 = display.toString();
                        Log.e("Activity", "Location_name1: " + location_name1);
                    }
                } catch (IOException e){
                    e.printStackTrace();

                }

                new CreateNewLocation().execute();

            }else{
                Toast.makeText(LocationActivity.this, "Couldn't get provider", Toast.LENGTH_SHORT).show();
            }


        }

        @Override
        protected void onPause() {
            // TODO Auto-generated method stub
            compass.disableCompass();
            super.onPause();
            lm.removeUpdates(this);

        }

        @Override
        protected void onResume() {
            // TODO Auto-generated method stub
            compass.enableCompass();
            super.onResume();
            lm.requestLocationUpdates(towers, 500, 1, this);

        }

        @Override
        protected boolean isRouteDisplayed() {
            // TODO Auto-generated method stub
            return false;
        }

        class Touch extends Overlay{
            public boolean onTouchEvent(MotionEvent e, MapView m){
                if(e.getAction() == MotionEvent.ACTION_DOWN){
                    start = e.getEventTime();
                    x = (int) e.getX();
                    x = (int) e.getY();
                    touchedPoint = map.getProjection().fromPixels(x, y);
                }
                if(e.getAction() == MotionEvent.ACTION_UP){
                    stop = e.getEventTime();                
                }
                if(stop -start > 1500){
                    //perform action if user hold down on the map
                    AlertDialog alert = new AlertDialog.Builder(LocationActivity.this).create();
                    alert.setTitle("Pick an Option");
                    alert.setMessage("Please select one of the options from below");
                    alert.setButton("Place a pinpoint", new DialogInterface.OnClickListener() {

                        public void onClick(DialogInterface dialog, int which) {
                            // TODO Auto-generated method stub

                            OverlayItem overlayItem = new OverlayItem(touchedPoint, "What's up", "2nd String");
                            CustomPinpoint custom = new CustomPinpoint(d, LocationActivity.this);
                            custom.insertPinPoint(overlayItem);
                            overlayList.add(custom);

                        }
                    });
                    alert.setButton2("Get Address", new DialogInterface.OnClickListener(){

                        public void onClick(DialogInterface dialog, int which) {
                            // TODO Auto-generated method stub
                            Geocoder geocoder = new Geocoder(getBaseContext(), Locale.getDefault());
                            try{
                                List<Address> address = geocoder.getFromLocation(touchedPoint.getLatitudeE6() / 1E6, touchedPoint.getLongitudeE6() / 1E6, 1);
                                if(address.size() > 0){
                                    String display = "";
                                    for (int i = 0; i <= address.get(0).getMaxAddressLineIndex(); i++){                     
                                        display += address.get(0).getAddressLine(i) + "\n";
                                    }
                                    Toast t = Toast.makeText(getBaseContext(), display, Toast.LENGTH_LONG);
                                    t.show();
                                }
                            } catch (IOException e){
                                e.printStackTrace();

                            }
                        }
                    });
                    alert.setButton3("Toggle View", new DialogInterface.OnClickListener(){

                        public void onClick(DialogInterface dialog, int which) {
                            // TODO Auto-generated method stub

                            if (map.isSatellite()){
                                map.setSatellite(false);
                                map.setStreetView(true);
                            }else {
                                map.setStreetView(false);
                                map.setSatellite(true);
                            }
                        }
                    });
                    alert.show();
                    return true;
                }
                return false;
            }
        }

        public void onLocationChanged(Location l) {
            // TODO Auto-generated method stub
            lat = (int) (l.getLatitude()*1E6);
            longi = (int) (l.getLongitude()*1E6);

            GeoPoint ourLocation = new GeoPoint(lat, longi);
            OverlayItem overlayItem = new OverlayItem(ourLocation, "What's up", "2nd String");
            CustomPinpoint custom = new CustomPinpoint(d, LocationActivity.this);
            custom.insertPinPoint(overlayItem);
            overlayList.add(custom);

        }

        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

        }

        //creating new location to database
        class CreateNewLocation extends AsyncTask<String, String, String>{
            protected void onPreExecute(){
                Log.e("Activity", "Enters Async: ");
                super.onPreExecute();
                pDialog = new ProgressDialog(LocationActivity.this);
                pDialog.setMessage ("Recording current location ...");
                pDialog.setIndeterminate(false);
                pDialog.setCancelable(true);
                pDialog.show();
            }

            //Creating record

            protected String doInBackground(String... args){
                Log.e("Activity", "Enters doinbackground: ");
                String location_name = location_name1 ;
                String latitude = latitude1 ;
                String longtitude = longtitude1;
                //String location_description = location_name1;

                List<NameValuePair> params = new ArrayList<NameValuePair>();
                params.add(new BasicNameValuePair("location_name", location_name));
                params.add(new BasicNameValuePair("latitude", latitude));
                params.add(new BasicNameValuePair("longtitude", longtitude));
                //params.add(new BasicNameValuePair("location_description", location_description));

            //getting JSON Object
            //Note that create product url accepts POST method
                JSONObject json = jsonParser.makeHttpRequest(url_create_record, "POST", params);

            //check log cat for response
                Log.d("Create Response", json.toString());

            //check for success tag
                try{
                    int success = json.getInt(TAG_SUCCESS);

                    if (success == 1){
                        //successfully created record
                        finish();
                    } else {
                        //failed to create record
                    }
                }catch (JSONException e){
                    e.printStackTrace();
                }
                return null;
            }
            //After completing background task Dismiss the progress dialog
            protected void onPostExecute(String file_url){
                //dismiss the dialog once done
                pDialog.dismiss();
            }
        }
    }

LogCat 错误

07-28 21:06:47.587: D/dalvikvm(29465): GC_CONCURRENT freed 230K, 45% free 3119K/5639K, external 0K/0K, paused 3ms+2ms
07-28 21:06:47.827: D/dalvikvm(29465): GC_CONCURRENT freed 308K, 44% free 3351K/5959K, external 0K/0K, paused 3ms+16ms
07-28 21:06:48.047: D/dalvikvm(29465): GC_CONCURRENT freed 628K, 48% free 3283K/6215K, external 0K/0K, paused 3ms+4ms
07-28 21:06:48.187: D/dalvikvm(29465): GC_CONCURRENT freed 503K, 48% free 3292K/6215K, external 0K/0K, paused 1ms+3ms
07-28 21:06:48.368: D/dalvikvm(29465): GC_CONCURRENT freed 331K, 45% free 3470K/6215K, external 0K/0K, paused 2ms+13ms
07-28 21:06:49.549: E/Activity(29465): Location is not null
07-28 21:06:49.549: E/Activity(29465): Latitude/ Longitutde 1433509103838336
07-28 21:06:49.549: E/Activity(29465): Try to get activity
07-28 21:06:49.739: E/Activity(29465): List Address: [Address[addressLines=[0:"589 Sembawang Close",1:"Singapore 760589"],feature=589,admin=null,sub-admin=null,locality=null,thoroughfare=Sembawang Close ,postalCode=760589,countryCode=SG,countryName=Singapore,hasLatitude=true,latitude=1.433459,hasLongitude=true,longitude=103.838868,phone=null,url=null,extras=null]]
07-28 21:06:49.739: E/Activity(29465): Address.size: 
07-28 21:06:49.739: E/Activity(29465): Enter loop:
07-28 21:06:49.739: E/Activity(29465): Enter loop:
07-28 21:06:49.739: E/Activity(29465): Display: 589 Sembawang
07-28 21:06:49.739: E/Activity(29465): Singapore 760589
07-28 21:06:49.769: E/Activity(29465): Location_name1: 589 Sembawang Close
07-28 21:06:49.769: E/Activity(29465): Singapore 760589
07-28 21:06:49.779: E/Activity(29465): Enters Async: 
07-28 21:06:49.979: D/WindowManagerImpl(29465): addView, new view, mViews[0]: com.android.internal.policy.impl.PhoneWindow$DecorView@405953a0
07-28 21:06:50.019: D/ATRecorder(29465): com.htc.autotest.dlib.RecordEngine in loader dalvik.system.DexClassLoader@40623670
07-28 21:06:50.019: E/Activity(29465): Enters doinbackground: 
07-28 21:06:50.149: D/dalvikvm(29465): GC_CONCURRENT freed 761K, 50% free 3180K/6279K, external 0K/0K, paused 3ms+13ms
07-28 21:06:50.169: D/ATRecorder(29465): com.htc.autotest.dlib.RecordEngine in loader dalvik.system.DexClassLoader@405425f8
07-28 21:06:50.239: D/SensorGUI(29465): SensorChannel(const Parcel& data): mSendFd = -1, mReceiveFd = 63
07-28 21:06:50.390: D/dalvikvm(29465): GC_FOR_MALLOC freed 49K, 50% free 3192K/6279K, external 0K/0K, paused 39ms
07-28 21:06:50.410: I/dalvikvm-heap(29465): Grow heap (frag case) to 5.445MB for 87396-byte allocation
07-28 21:06:50.470: D/dalvikvm(29465): GC_FOR_MALLOC freed 0K, 49% free 3277K/6407K, external 0K/0K, paused 27ms
07-28 21:06:50.470: D/WindowManagerImpl(29465): addView, new view, mViews[1]: com.android.internal.policy.impl.PhoneWindow$DecorView@405266e8
07-28 21:06:50.540: D/dalvikvm(29465): GC_FOR_MALLOC freed 1K, 49% free 3280K/6407K, external 0K/0K, paused 59ms
07-28 21:06:50.570: I/dalvikvm-heap(29465): Grow heap (frag case) to 5.531MB for 87396-byte allocation
07-28 21:06:50.620: D/dalvikvm(29465): GC_FOR_MALLOC freed 0K, 49% free 3365K/6535K, external 0K/0K, paused 36ms
07-28 21:06:50.670: D/PhoneWindow(29465): couldn't save which view has focus because the focused view com.android.internal.policy.impl.PhoneWindow$DecorView@40512458 has no id.
07-28 21:06:50.680: D/SensorManager(29465): unregisterSensor: mSensors = 128, legacyType = 128
07-28 21:06:50.680: D/SensorManager(29465): unregisterSensor: After modify mSensors = 0
07-28 21:06:50.700: D/WindowManagerImpl(29465): addView, new view, mViews[2]: android.widget.LinearLayout@405a72a8
07-28 21:06:50.800: W/NetworkConnectivityListener(29465): onReceived() called with UNKNOWN and Intent { act=android.net.conn.CONNECTIVITY_CHANGE flg=0x10000000 (has extras) }
07-28 21:06:51.531: E/JSON Parser(29465): Error parsing data org.json.JSONException: Value <br of type java.lang.String cannot be converted to JSONObject
07-28 21:06:51.541: W/dalvikvm(29465): threadid=9: thread exiting with uncaught exception (group=0x4001d5a0)
07-28 21:06:51.621: E/AndroidRuntime(29465): FATAL EXCEPTION: AsyncTask #1
07-28 21:06:51.621: E/AndroidRuntime(29465): java.lang.RuntimeException: An error occured while executing doInBackground()
07-28 21:06:51.621: E/AndroidRuntime(29465):    at android.os.AsyncTask$3.done(AsyncTask.java:200)
07-28 21:06:51.621: E/AndroidRuntime(29465):    at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:274)
07-28 21:06:51.621: E/AndroidRuntime(29465):    at java.util.concurrent.FutureTask.setException(FutureTask.java:125)
07-28 21:06:51.621: E/AndroidRuntime(29465):    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:308)
07-28 21:06:51.621: E/AndroidRuntime(29465):    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
07-28 21:06:51.621: E/AndroidRuntime(29465):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
07-28 21:06:51.621: E/AndroidRuntime(29465):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
07-28 21:06:51.621: E/AndroidRuntime(29465):    at java.lang.Thread.run(Thread.java:1027)
07-28 21:06:51.621: E/AndroidRuntime(29465): Caused by: java.lang.NullPointerException
07-28 21:06:51.621: E/AndroidRuntime(29465):    at com.isec.leonard.LocationActivity$CreateNewLocation.doInBackground(LocationActivity.java:295)
07-28 21:06:51.621: E/AndroidRuntime(29465):    at com.isec.leonard.LocationActivity$CreateNewLocation.doInBackground(LocationActivity.java:1)
07-28 21:06:51.621: E/AndroidRuntime(29465):    at android.os.AsyncTask$2.call(AsyncTask.java:185)
07-28 21:06:51.621: E/AndroidRuntime(29465):    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
07-28 21:06:51.621: E/AndroidRuntime(29465):    ... 4 more
07-28 21:06:51.751: D/PhoneWindow(29465): couldn't save which view has focus because the focused view com.android.internal.policy.impl.PhoneWindow$DecorView@40512458 has no id.
07-28 21:06:51.751: D/SensorManager(29465): unregisterSensor: mSensors = 128, legacyType = 128
07-28 21:06:51.751: D/SensorManager(29465): unregisterSensor: After modify mSensors = 0
07-28 21:06:51.771: W/NetworkConnectivityListener(29465): onReceived() called with UNKNOWN and Intent { act=android.net.conn.CONNECTIVITY_CHANGE flg=0x10000000 (has extras) }
07-28 21:06:51.831: D/Process(29465): killProcess, pid=29465
07-28 21:06:51.881: D/Process(29465): dalvik.system.VMStack.getThreadStackTrace(Native Method)
07-28 21:06:51.891: D/Process(29465): java.lang.Thread.getStackTrace(Thread.java:745)
07-28 21:06:51.891: D/Process(29465): android.os.Process.killProcess(Process.java:797)
07-28 21:06:51.921: D/Process(29465): com.android.internal.os.RuntimeInit$UncaughtHandler.uncaughtException(RuntimeInit.java:108)
07-28 21:06:51.921: D/Process(29465): java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:854)
07-28 21:06:51.921: D/Process(29465): java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:851)
07-28 21:06:51.921: I/Process(29465): Sending signal. PID: 29465 SIG: 9
07-28 21:07:09.218: D/dalvikvm(29709): GC_CONCURRENT freed 230K, 45% free 3117K/5639K, external 0K/0K, paused 3ms+2ms
07-28 21:07:09.348: D/dalvikvm(29709): GC_CONCURRENT freed 299K, 45% free 3286K/5895K, external 0K/0K, paused 2ms+3ms
07-28 21:07:09.558: D/dalvikvm(29709): GC_CONCURRENT freed 592K, 48% free 3256K/6151K, external 0K/0K, paused 4ms+2ms
07-28 21:07:09.718: D/dalvikvm(29709): GC_CONCURRENT freed 412K, 46% free 3355K/6151K, external 0K/0K, paused 16ms+4ms
07-28 21:07:09.828: D/dalvikvm(29709): GC_CONCURRENT freed 362K, 43% free 3551K/6215K, external 0K/0K, paused 2ms+3ms
07-28 21:07:09.999: E/Activity(29709): Location is not null
07-28 21:07:09.999: E/Activity(29709): Latitude/ Longitutde 1433509103838336
07-28 21:07:09.999: E/Activity(29709): Try to get activity
07-28 21:07:10.159: E/Activity(29709): List Address: [Address[addressLines=[0:"237 Yishun Ring Rd",1:"Singapore 760237"],feature=237,admin=null,sub-admin=null,locality=null,thoroughfare=Yishun Ring Rd,postalCode=760237,countryCode=SG,countryName=Singapore,hasLatitude=true,latitude=1.433459,hasLongitude=true,longitude=103.838868,phone=null,url=null,extras=null]]
07-28 21:07:10.159: E/Activity(29709): Address.size: 
07-28 21:07:10.159: E/Activity(29709): Enter loop:
07-28 21:07:10.159: E/Activity(29709): Enter loop:
07-28 21:07:10.159: E/Activity(29709): Display: 237 Yishun Ring Rd
07-28 21:07:10.159: E/Activity(29709): Singapore 760237
07-28 21:07:10.179: E/Activity(29709): Location_name1: 237 Yishun Ring Rd
07-28 21:07:10.179: E/Activity(29709): Singapore 760237
07-28 21:07:10.189: E/Activity(29709): Enters Async: 
07-28 21:07:10.289: D/dalvikvm(29709): GC_CONCURRENT freed 586K, 47% free 3409K/6343K, external 0K/0K, paused 12ms+7ms
07-28 21:07:10.469: D/WindowManagerImpl(29709): addView, new view, mViews[0]: com.android.internal.policy.impl.PhoneWindow$DecorView@406341a8
07-28 21:07:10.619: D/ATRecorder(29709): com.htc.autotest.dlib.RecordEngine in loader dalvik.system.DexClassLoader@40588420
07-28 21:07:10.619: E/Activity(29709): Enters doinbackground: 
07-28 21:07:10.659: D/ATRecorder(29709): com.htc.autotest.dlib.RecordEngine in loader dalvik.system.DexClassLoader@40520840
07-28 21:07:10.799: D/dalvikvm(29709): GC_FOR_MALLOC freed 238K, 49% free 3275K/6343K, external 0K/0K, paused 62ms
07-28 21:07:10.809: I/dalvikvm-heap(29709): Grow heap (frag case) to 5.526MB for 87396-byte allocation
07-28 21:07:10.849: D/dalvikvm(29709): GC_FOR_MALLOC freed 0K, 49% free 3360K/6471K, external 0K/0K, paused 25ms
07-28 21:07:10.859: D/SensorGUI(29709): SensorChannel(const Parcel& data): mSendFd = -1, mReceiveFd = 64
07-28 21:07:10.940: E/JSON Parser(29709): Error parsing data org.json.JSONException: Value <br of type java.lang.String cannot be converted to JSONObject
07-28 21:07:10.950: W/dalvikvm(29709): threadid=9: thread exiting with uncaught exception (group=0x4001d5a0)
07-28 21:07:11.120: E/AndroidRuntime(29709): FATAL EXCEPTION: AsyncTask #1
07-28 21:07:11.120: E/AndroidRuntime(29709): java.lang.RuntimeException: An error occured while executing doInBackground()
07-28 21:07:11.120: E/AndroidRuntime(29709):    at android.os.AsyncTask$3.done(AsyncTask.java:200)
07-28 21:07:11.120: E/AndroidRuntime(29709):    at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:274)
07-28 21:07:11.120: E/AndroidRuntime(29709):    at java.util.concurrent.FutureTask.setException(FutureTask.java:125)
07-28 21:07:11.120: E/AndroidRuntime(29709):    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:308)
07-28 21:07:11.120: E/AndroidRuntime(29709):    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
07-28 21:07:11.120: E/AndroidRuntime(29709):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
07-28 21:07:11.120: E/AndroidRuntime(29709):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
07-28 21:07:11.120: E/AndroidRuntime(29709):    at java.lang.Thread.run(Thread.java:1027)
07-28 21:07:11.120: E/AndroidRuntime(29709): Caused by: java.lang.NullPointerException
07-28 21:07:11.120: E/AndroidRuntime(29709):    at com.isec.leonard.LocationActivity$CreateNewLocation.doInBackground(LocationActivity.java:295)
07-28 21:07:11.120: E/AndroidRuntime(29709):    at com.isec.leonard.LocationActivity$CreateNewLocation.doInBackground(LocationActivity.java:1)
07-28 21:07:11.120: E/AndroidRuntime(29709):    at android.os.AsyncTask$2.call(AsyncTask.java:185)
07-28 21:07:11.120: E/AndroidRuntime(29709):    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
07-28 21:07:11.120: E/AndroidRuntime(29709):    ... 4 more
07-28 21:07:11.220: D/WindowManagerImpl(29709): addView, new view, mViews[1]: com.android.internal.policy.impl.PhoneWindow$DecorView@40526fa0
07-28 21:07:11.440: D/WindowManagerImpl(29709): addView, new view, mViews[2]: android.widget.LinearLayout@40630800
07-28 21:07:11.670: D/SensorManager(29709): unregisterSensor: mSensors = 128, legacyType = 128
07-28 21:07:11.670: D/SensorManager(29709): unregisterSensor: After modify mSensors = 0
07-28 21:07:11.900: I/MapActivity(29709): Handling network change notification:CONNECTED
07-28 21:07:11.900: E/MapActivity(29709): Couldn't get connection factory client
07-28 21:07:12.531: D/WindowManagerImpl(29709): finishRemoveViewLocked, mViews[1]: com.android.internal.policy.impl.PhoneWindow$DecorView@40526fa0
07-28 21:07:12.631: E/WindowManager(29709): Activity com.isec.leonard.PhoneTrackingActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@406341a8 that was originally added here
07-28 21:07:12.631: E/WindowManager(29709): android.view.WindowLeaked: Activity com.isec.leonard.PhoneTrackingActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@406341a8 that was originally added here
07-28 21:07:12.631: E/WindowManager(29709):     at android.view.ViewRoot.<init>(ViewRoot.java:278)
07-28 21:07:12.631: E/WindowManager(29709):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:149)
07-28 21:07:12.631: E/WindowManager(29709):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
07-28 21:07:12.631: E/WindowManager(29709):     at android.view.Window$LocalWindowManager.addView(Window.java:433)
07-28 21:07:12.631: E/WindowManager(29709):     at android.app.Dialog.show(Dialog.java:265)
07-28 21:07:12.631: E/WindowManager(29709):     at com.isec.leonard.LocationActivity$CreateNewLocation.onPreExecute(LocationActivity.java:272)
07-28 21:07:12.631: E/WindowManager(29709):     at android.os.AsyncTask.execute(AsyncTask.java:391)
07-28 21:07:12.631: E/WindowManager(29709):     at com.isec.leonard.LocationActivity.onCreate(LocationActivity.java:132)
07-28 21:07:12.631: E/WindowManager(29709):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1072)
07-28 21:07:12.631: E/WindowManager(29709):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1836)
07-28 21:07:12.631: E/WindowManager(29709):     at android.app.ActivityThread.startActivityNow(ActivityThread.java:1692)
07-28 21:07:12.631: E/WindowManager(29709):     at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:127)
07-28 21:07:12.631: E/WindowManager(29709):     at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:339)
07-28 21:07:12.631: E/WindowManager(29709):     at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:656)
07-28 21:07:12.631: E/WindowManager(29709):     at android.widget.TabHost.setCurrentTab(TabHost.java:326)
07-28 21:07:12.631: E/WindowManager(29709):     at android.widget.TabHost.addTab(TabHost.java:216)
07-28 21:07:12.631: E/WindowManager(29709):     at com.isec.leonard.PhoneTrackingActivity.onCreate(PhoneTrackingActivity.java:33)
07-28 21:07:12.631: E/WindowManager(29709):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1072)
07-28 21:07:12.631: E/WindowManager(29709):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1836)
07-28 21:07:12.631: E/WindowManager(29709):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1893)
07-28 21:07:12.631: E/WindowManager(29709):     at android.app.ActivityThread.access$1500(ActivityThread.java:135)
07-28 21:07:12.631: E/WindowManager(29709):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1054)
07-28 21:07:12.631: E/WindowManager(29709):     at android.os.Handler.dispatchMessage(Handler.java:99)
07-28 21:07:12.631: E/WindowManager(29709):     at android.os.Looper.loop(Looper.java:150)
07-28 21:07:12.631: E/WindowManager(29709):     at android.app.ActivityThread.main(ActivityThread.java:4385)
07-28 21:07:12.631: E/WindowManager(29709):     at java.lang.reflect.Method.invokeNative(Native Method)
07-28 21:07:12.631: E/WindowManager(29709):     at java.lang.reflect.Method.invoke(Method.java:507)
07-28 21:07:12.631: E/WindowManager(29709):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:849)
07-28 21:07:12.631: E/WindowManager(29709):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607)
07-28 21:07:12.631: E/WindowManager(29709):     at dalvik.system.NativeStart.main(Native Method)
07-28 21:07:12.641: D/WindowManagerImpl(29709): finishRemoveViewLocked, mViews[0]: com.android.internal.policy.impl.PhoneWindow$DecorView@406341a8
07-28 21:07:12.761: D/dalvikvm(29709): GC_CONCURRENT freed 231K, 46% free 3556K/6471K, external 0K/0K, paused 23ms+7ms
07-28 21:07:13.722: D/WindowManagerImpl(29709): finishRemoveViewLocked, mViews[0]: android.widget.LinearLayout@40630800
07-28 21:07:13.952: D/Process(29709): killProcess, pid=29709
07-28 21:07:13.952: D/Process(29709): dalvik.system.VMStack.getThreadStackTrace(Native Method)
07-28 21:07:14.033: D/Process(29709): java.lang.Thread.getStackTrace(Thread.java:745)
07-28 21:07:14.043: D/Process(29709): android.os.Process.killProcess(Process.java:797)
07-28 21:07:14.043: D/Process(29709): com.android.internal.os.RuntimeInit$UncaughtHandler.uncaughtException(RuntimeInit.java:108)
07-28 21:07:14.053: D/Process(29709): java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:854)
07-28 21:07:14.063: D/Process(29709): java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:851)
07-28 21:07:14.063: I/Process(29709): Sending signal. PID: 29709 SIG: 9
4

2 回答 2

0

您在 LocationActivity.java:295 处有 NullPointerException

于 2012-07-28T13:40:04.750 回答
0

解析失败,因为您没有收到 JSON 对象(您收到的响应开始于<BR

 Error parsing data org.json.JSONException: Value <br of type java.lang.String cannot be converted to JSONObject
于 2012-07-28T14:25:59.417 回答