Android.os.networkonmainthreadexception In Facebook Wall Post
I'm using Android facebook SDK for post on facebook wall.I have used following code for wall post but every time through exception android.os.NetworkOnMainThreadException public vo
Solution 1:
You cannot perform network IO on the UI thread on Honeycombe or later. Technically it is possible on earlier versions of Android, but is a really bad idea as it will cause your app to stop responding, and can result in the OS killing your app for being badly behaved. You'll need to run a background process or use AsyncTask to perform your network transaction on a background thread.
Edit : Another Idea but it is not good . It is Bad Practice to use it but some people use it.
StrictMode.ThreadPolicypolicy=newStrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
Add above code in your activity class.
I personally Prefer the first option use thread or AsyncTask .
Post a Comment for "Android.os.networkonmainthreadexception In Facebook Wall Post"