Fatal Exception : AsyncTask #1
<p>help help..huu</p>

<p>Im having a problem here..seems there was no error in codes..but when I run it...and click button to view map consist routing the map..It appers to be close all of sudden..why is that? Please help me friends.. </p>

<p>Im developing an app to read my current location and creating route to A position.. </p>

<p>here are the codes:</p>

<pre><code>public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.map);

    onNewIntent(getIntent());

    Drawable marker = getResources().getDrawable(R.drawable.marker);
    Drawable marked_places = getResources().getDrawable(R.drawable.feringgi_map);

    mymap = (MapView)findViewById(R.id.mymap);
    controller = mymap.getController();
    // extract MapView from layout
    mymap.getController().setZoom(15);
    mymap.setBuiltInZoomControls(true);
    mymap.setSatellite(false);

    // create an overlay that shows our current location
    myLocationOverlay = new MyLocationOverlay(this, mymap);

    // add this overlay to the MapView and refresh it
    mymap.getOverlays().add(myLocationOverlay); 
    mymap.postInvalidate();

    myLocationOverlay.runOnFirstFix(new Runnable() {

        @Override
        public void run() {
            controller.setZoom(10);
            controller.animateTo(myLocationOverlay.getMyLocation());                
        }
    });

    zoomToMyLocation();

   switch(selecteditem)
   {
   case 0:        switch(selectedsubitem){
            case 0://Place A       
                    locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
                  locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, this);
                  Location location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
                      if (location !=null) {
                      loc=location;
                  }
                  GeoPoint destination = getPoint(3.144341, 101.69541800000002);
                  new BackgroundTask(this, loc, destination).execute();
                break;              
}
}

 class BackgroundTask extends AsyncTask&lt;Void, Void, Void&gt; {

        private Location location;
        private GeoPoint dest;
        private Route route;
        private Activity activity;
        private ProgressDialog dialog;
        private RouteOverlay routeOverlay;

        public BackgroundTask(Activity activity, Location loc, GeoPoint dest) {
            location=loc; 
            this.dest=dest;
            this.activity=activity;
            dialog = new ProgressDialog(activity);
        }

        @Override
        protected void onPreExecute() {
            dialog.setCancelable(false);
            dialog.setTitle("Loading...");
            dialog.setMessage("Calculating Route...");
            dialog.setButton("Cancel", new DialogInterface.OnClickListener() {
                public void onClick(final DialogInterface dialog, final int id) {
                  cancel(true);
                  MyMap.this.finish();
                }});
            dialog.show();
        }

protected Void doInBackground(Void... params) {
                if(isNetworkAvailable())
                {
                    if(haveInternet())
                    {   try{
                            route = directions(new GeoPoint((int)(location.getLatitude()*1.0E6),(int)(location.getLongitude()*1.0E6)), dest); 
                        }
                        catch (NullPointerException e){ }
                    }
                    else
                    {   return null;
                    }
                }
                else
                {   return null; }

                return null;
                }
</code></pre>

<p>And this is the log cat (updated).. : </p>

<pre><code>    12-10 13:30:36.677: E/AndroidRuntime(13405): FATAL EXCEPTION: AsyncTask #1
12-10 13:30:36.677: E/AndroidRuntime(13405): java.lang.RuntimeException: An error occured while executing doInBackground()
12-10 13:30:36.677: E/AndroidRuntime(13405):    at android.os.AsyncTask$3.done(AsyncTask.java:278)
12-10 13:30:36.677: E/AndroidRuntime(13405):    at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
12-10 13:30:36.677: E/AndroidRuntime(13405):    at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
12-10 13:30:36.677: E/AndroidRuntime(13405):    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
12-10 13:30:36.677: E/AndroidRuntime(13405):    at java.util.concurrent.FutureTask.run(FutureTask.java:137)
12-10 13:30:36.677: E/AndroidRuntime(13405):    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208)
12-10 13:30:36.677: E/AndroidRuntime(13405):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
12-10 13:30:36.677: E/AndroidRuntime(13405):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
12-10 13:30:36.677: E/AndroidRuntime(13405):    at java.lang.Thread.run(Thread.java:856)
12-10 13:30:36.677: E/AndroidRuntime(13405): Caused by: java.lang.SecurityException: ConnectivityService: Neither user 10228 nor current process has android.permission.ACCESS_NETWORK_STATE.
12-10 13:30:36.677: E/AndroidRuntime(13405):    at android.os.Parcel.readException(Parcel.java:1327)
12-10 13:30:36.677: E/AndroidRuntime(13405):    at android.os.Parcel.readException(Parcel.java:1281)
12-10 13:30:36.677: E/AndroidRuntime(13405):    at android.net.IConnectivityManager$Stub$Proxy.getActiveNetworkInfo(IConnectivityManager.java:728)
12-10 13:30:36.677: E/AndroidRuntime(13405):    at android.net.ConnectivityManager.getActiveNetworkInfo(ConnectivityManager.java:378)
12-10 13:30:36.677: E/AndroidRuntime(13405):    at com.madcatworld.testtesttest.MyMap$BackgroundTask.isNetworkAvailable(MyMap.java:488)
12-10 13:30:36.677: E/AndroidRuntime(13405):    at com.madcatworld.testtesttest.MyMap$BackgroundTask.doInBackground(MyMap.java:411)
12-10 13:30:36.677: E/AndroidRuntime(13405):    at com.madcatworld.testtesttest.MyMap$BackgroundTask.doInBackground(MyMap.java:1)
12-10 13:30:36.677: E/AndroidRuntime(13405):    at android.os.AsyncTask$2.call(AsyncTask.java:264)
12-10 13:30:36.677: E/AndroidRuntime(13405):    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
12-10 13:30:36.677: E/AndroidRuntime(13405):    ... 5 more
</code></pre>

<p>this is the other half I havent post them here previously: </p>

<pre><code>12-10 13:30:37.308: E/WindowManager(13405): Activity com.madcatworld.testtesttest.MyMap has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@4254bb28 that was originally added here
12-10 13:30:37.308: E/WindowManager(13405): android.view.WindowLeaked: Activity com.madcatworld.testtesttest.MyMap has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@4254bb28 that was originally added here
12-10 13:30:37.308: E/WindowManager(13405):     at android.view.ViewRootImpl.&lt;init&gt;(ViewRootImpl.java:344)
12-10 13:30:37.308: E/WindowManager(13405):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:267)
12-10 13:30:37.308: E/WindowManager(13405):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:215)
12-10 13:30:37.308: E/WindowManager(13405):     at android.view.WindowManagerImpl$CompatModeWrapper.addView(WindowManagerImpl.java:140)
12-10 13:30:37.308: E/WindowManager(13405):     at android.view.Window$LocalWindowManager.addView(Window.java:537)
12-10 13:30:37.308: E/WindowManager(13405):     at android.app.Dialog.show(Dialog.java:278)
12-10 13:30:37.308: E/WindowManager(13405):     at com.madcatworld.testtesttest.MyMap$BackgroundTask.onPreExecute(MyMap.java:406)
12-10 13:30:37.308: E/WindowManager(13405):     at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:561)
12-10 13:30:37.308: E/WindowManager(13405):     at android.os.AsyncTask.execute(AsyncTask.java:511)
12-10 13:30:37.308: E/WindowManager(13405):     at com.madcatworld.testtesttest.MyMap.onCreate(MyMap.java:108)
12-10 13:30:37.308: E/WindowManager(13405):     at android.app.Activity.performCreate(Activity.java:4465)
12-10 13:30:37.308: E/WindowManager(13405):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
12-10 13:30:37.308: E/WindowManager(13405):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
12-10 13:30:37.308: E/WindowManager(13405):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
12-10 13:30:37.308: E/WindowManager(13405):     at android.app.ActivityThread.access$600(ActivityThread.java:123)
12-10 13:30:37.308: E/WindowManager(13405):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
12-10 13:30:37.308: E/WindowManager(13405):     at android.os.Handler.dispatchMessage(Handler.java:99)
12-10 13:30:37.308: E/WindowManager(13405):     at android.os.Looper.loop(Looper.java:137)
12-10 13:30:37.308: E/WindowManager(13405):     at android.app.ActivityThread.main(ActivityThread.java:4424)
12-10 13:30:37.308: E/WindowManager(13405):     at java.lang.reflect.Method.invokeNative(Native Method)
12-10 13:30:37.308: E/WindowManager(13405):     at java.lang.reflect.Method.invoke(Method.java:511)
12-10 13:30:37.308: E/WindowManager(13405):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:787)
12-10 13:30:37.308: E/WindowManager(13405):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:554)
12-10 13:30:37.308: E/WindowManager(13405):     at dalvik.system.NativeStart.main(Native Method)
</code></pre>

<p>This is my manifest file: </p>

<pre><code> &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.madcatworld.testtesttest"
        android:versionCode="1"
        android:versionName="1.0" &gt;

        &lt;uses-sdk
            android:minSdkVersion="8"
            android:targetSdkVersion="15" /&gt;
        &lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/&gt;
        &lt;uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/&gt;
        &lt;uses-permission android:name="android.permission.INTERNET"/&gt;
        &lt;uses-permission android:name="android.permission.CALL_PHONE"/&gt;
        &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/&gt;

        &lt;application
            android:icon="@drawable/ic_launcher"
            android:label="@string/app_name"
            android:theme="@style/AppTheme" &gt;

            &lt;com.google.android.maps.MapView
            android:id="@+id/mymap"
            android:clickable="true"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:apiKey="XXXX"
            /&gt;       

            &lt;activity
                android:theme="@style/StyledIndicators"
                android:name=".MainTest"
                android:label="@string/title_activity_main" 
                android:screenOrientation="portrait"&gt;
                &lt;intent-filter&gt;
                    &lt;action android:name="android.intent.action.MAIN" /&gt;
                    &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
                &lt;/intent-filter&gt;
            &lt;/activity&gt;
            &lt;uses-library android:name="com.google.android.maps"/&gt;
            &lt;activity android:name="A"
                android:screenOrientation="portrait"&gt;&lt;/activity&gt;
            &lt;activity android:name="B"
                android:screenOrientation="portrait"&gt;&lt;/activity&gt;
            &lt;activity android:name="C"
                android:screenOrientation="portrait"&gt;&lt;/activity&gt;
        &lt;/application&gt;

    &lt;/manifest&gt;
</code></pre>

<p>For your information, I already put ACCESS_NETWORK_STATE in my manifest..</p>

<p>Can u discover what cause the error? No error in code..but it failed to review my route map..:( Thanks Friends</p>
