Search Results

Search found 1 results on 1 pages for 'nadirah ibtisam'.

Page 1/1 | 1 

  • Fatal Exception : AsyncTask #1

    - by Nadirah Ibtisam
    help help..huu 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.. Im developing an app to read my current location and creating route to A position.. here are the codes: 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<Void, Void, Void> { 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; } And this is the log cat (updated).. : 12-10 12:21:15.527: E/AndroidRuntime(10146): FATAL EXCEPTION: AsyncTask #1 12-10 12:21:15.527: E/AndroidRuntime(10146): java.lang.RuntimeException: An error occured while executing doInBackground() 12-10 12:21:15.527: E/AndroidRuntime(10146): at android.os.AsyncTask$3.done(AsyncTask.java:278) 12-10 12:21:15.527: E/AndroidRuntime(10146): at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273) 12-10 12:21:15.527: E/AndroidRuntime(10146): at java.util.concurrent.FutureTask.setException(FutureTask.java:124) 12-10 12:21:15.527: E/AndroidRuntime(10146): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307) 12-10 12:21:15.527: E/AndroidRuntime(10146): at java.util.concurrent.FutureTask.run(FutureTask.java:137) 12-10 12:21:15.527: E/AndroidRuntime(10146): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208) 12-10 12:21:15.527: E/AndroidRuntime(10146): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076) 12-10 12:21:15.527: E/AndroidRuntime(10146): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569) 12-10 12:21:15.527: E/AndroidRuntime(10146): at java.lang.Thread.run(Thread.java:856) 12-10 12:21:15.527: E/AndroidRuntime(10146): Caused by: java.lang.SecurityException: ConnectivityService: Neither user 10228 nor current process has android.permission.ACCESS_NETWORK_STATE. 12-10 12:21:15.527: E/AndroidRuntime(10146): at android.os.Parcel.readException(Parcel.java:1327) 12-10 12:21:15.527: E/AndroidRuntime(10146): at android.os.Parcel.readException(Parcel.java:1281) 12-10 12:21:15.527: E/AndroidRuntime(10146): at android.net.IConnectivityManager$Stub$Proxy.getActiveNetworkInfo(IConnectivityManager.java:728) 12-10 12:21:15.527: E/AndroidRuntime(10146): at android.net.ConnectivityManager.getActiveNetworkInfo(ConnectivityManager.java:378) 12-10 12:21:15.527: E/AndroidRuntime(10146): at com.madcatworld.testtesttest.MyMap$BackgroundTask.isNetworkAvailable(MyMap.java:488) 12-10 12:21:15.527: E/AndroidRuntime(10146): at com.madcatworld.testtesttest.MyMap$BackgroundTask.doInBackground(MyMap.java:411) 12-10 12:21:15.527: E/AndroidRuntime(10146): at com.madcatworld.testtesttest.MyMap$BackgroundTask.doInBackground(MyMap.java:1) 12-10 12:21:15.527: E/AndroidRuntime(10146): at android.os.AsyncTask$2.call(AsyncTask.java:264) 12-10 12:21:15.527: E/AndroidRuntime(10146): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305) 12-10 12:21:15.527: E/AndroidRuntime(10146): ... 5 more This is my manifest file: <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.madcatworld.testtesttest" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="15" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> <uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.CALL_PHONE"/> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <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" /> <activity android:theme="@style/StyledIndicators" android:name=".MainTest" android:label="@string/title_activity_main" android:screenOrientation="portrait"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <uses-library android:name="com.google.android.maps"/> <activity android:name="A" android:screenOrientation="portrait"></activity> <activity android:name="B" android:screenOrientation="portrait"></activity> <activity android:name="C" android:screenOrientation="portrait"></activity> </application> </manifest> For your information, I already put ACCESS_NETWORK_STATE in my manifest.. Can u discover what cause the error? No error in code..but it failed to review my route map..:( Thanks Friends

    Read the article

1