Thanks Mark,
I am acquiring a wakelock as the error points to giving up a wake
lock. No other specific reason. I am not sure how to use Async task.
Can you give me any pointer?

-Kiran

On Tue, Oct 20, 2009 at 1:16 PM, Mark Murphy <mmur...@commonsware.com> wrote:
>
> Kiran wrote:
>> Experts, Any help here?
>
>>>    static String linkUrl = "http://www.google.com/";;
>>>
>>>        protected void onCreate(Bundle savedInstanceState) {
>>>                super.onCreate(savedInstanceState);
>>>
>>>                PowerManager pm = (PowerManager) getSystemService
>>> (Context.POWER_SERVICE);
>>>                PowerManager.WakeLock wl = pm.newWakeLock
>>> (PowerManager.SCREEN_DIM_WAKE_LOCK, "My Tag");
>>>                wl.acquire();
>
> Why are you asking for a WakeLock in an Activity's onCreate()?
>
>>>        try {
>>>                URL connectURL = new URL(linkUrl);
>>>                HttpURLConnection conn = (HttpURLConnection)
>>> connectURL.openConnection();
>>>                DataInputStream dis = new DataInputStream
>>> (conn.getInputStream
>>> ());
>>>                byte[] data = new byte[1024];
>>>                int len = dis.read(data, 0, 1024);
>>>                dataText = new String(data, 0, len);
>>>        }
>>>        catch(Exception e)
>>>        {
>>>            Log.e(TAG, "Exception");
>>>            return;
>>>        }
>
> Never do HTTP I/O on the UI thread. Use AsyncTask or something to do
> this work on a background thread.
>
> --
> Mark Murphy (a Commons Guy)
> http://commonsware.com | http://twitter.com/commonsguy
>
> Android App Developer Books: http://commonsware.com/books.html
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to