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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to