[android-developers] Re: Activity launch timeout even with wakelock
Hierarchy viewer shows the text view. Also the data contains the html page. Here is the screenshot of hierarchy viewer: http://i1011.photobucket.com/albums/af233/kiranjulapalli/textview.png?t=1256301091 On Oct 22, 5:21 pm, Mark Murphy mmur...@commonsware.com wrote: Kiran wrote: I did that.. every statement is properly executed and see that bodyText.setText(dataText); is called and the value of dataText is the full html of the google.com OK, try using hierarchyviewer to confirm that your TextView is actually on screen, visible, etc. -- Mark Murphy (a Commons Guy)http://commonsware.com|http://twitter.com/commonsguy _The Busy Coder's Guide to *Advanced* Android Development_ Version 1.1 Available! --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[android-developers] Re: Activity launch timeout even with wakelock
Kiran wrote: Hierarchy viewer shows the text view. Also the data contains the html page. Here is the screenshot of hierarchy viewer: http://i1011.photobucket.com/albums/af233/kiranjulapalli/textview.png?t=1256301091 Great! That means your background processing is working just fine. Now all you need to do is figure out why the text is not showing up, such as: -- The TextView is off-screen -- The TextView is hidden behind something else -- The TextView has black text on a black background -- The TextView has zero height or width -- etc. hierarchyviewer should be able to help with much of that. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://twitter.com/commonsguy _Android Programming Tutorials_ Version 1.0 Available! --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[android-developers] Re: Activity launch timeout even with wakelock
Thanks Mark, Hierachy viewer did help me. The issue is in the xml file. I am not sure why I had the listview in first place and removing it solved the problem. But the process exposed to a good toolset that will help me in future debugging. ?xml version=1.0 encoding=utf-8? LinearLayout xmlns:android=http://schemas.android.com/apk/res/ android android:layout_width=wrap_content android:layout_height=wrap_content ListView android:id=@+id/android:fetchlist android:layout_width=wrap_content android:layout_height=wrap_content/ TextView android:id=@+id/android:fetchtext android:layout_width=wrap_content android:layout_height=wrap_content/ /LinearLayout On Oct 23, 7:47 am, Mark Murphy mmur...@commonsware.com wrote: Kiran wrote: Hierarchy viewer shows the text view. Also the data contains the html page. Here is the screenshot of hierarchy viewer: http://i1011.photobucket.com/albums/af233/kiranjulapalli/textview.png... Great! That means your background processing is working just fine. Now all you need to do is figure out why the text is not showing up, such as: -- The TextView is off-screen -- The TextView is hidden behind something else -- The TextView has black text on a black background -- The TextView has zero height or width -- etc. hierarchyviewer should be able to help with much of that. -- Mark Murphy (a Commons Guy)http://commonsware.com|http://twitter.com/commonsguy _Android Programming Tutorials_ Version 1.0 Available! --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[android-developers] Re: Activity launch timeout even with wakelock
If you give your TextView a weight it will probably show up under the list. android:layout_weight=1 On Oct 23, 10:53 am, Kiran kiran.julapa...@gmail.com wrote: Thanks Mark, Hierachy viewer did help me. The issue is in the xml file. I am not sure why I had the listview in first place and removing it solved the problem. But the process exposed to a good toolset that will help me in future debugging. ?xml version=1.0 encoding=utf-8? LinearLayout xmlns:android=http://schemas.android.com/apk/res/ android android:layout_width=wrap_content android:layout_height=wrap_content ListView android:id=@+id/android:fetchlist android:layout_width=wrap_content android:layout_height=wrap_content/ TextView android:id=@+id/android:fetchtext android:layout_width=wrap_content android:layout_height=wrap_content/ /LinearLayout On Oct 23, 7:47 am, Mark Murphy mmur...@commonsware.com wrote: Kiran wrote: Hierarchy viewer shows the text view. Also the data contains the html page. Here is the screenshot of hierarchy viewer: http://i1011.photobucket.com/albums/af233/kiranjulapalli/textview.png... Great! That means your background processing is working just fine. Now all you need to do is figure out why the text is not showing up, such as: -- The TextView is off-screen -- The TextView is hidden behind something else -- The TextView has black text on a black background -- The TextView has zero height or width -- etc. hierarchyviewer should be able to help with much of that. -- Mark Murphy (a Commons Guy)http://commonsware.com|http://twitter.com/commonsguy _Android Programming Tutorials_ Version 1.0 Available! --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[android-developers] Re: Activity launch timeout even with wakelock
I updated the code as following. However, now I see that the display is not updated with the text. Am I missing something? static String linkUrl = http://www.google.com;; String dataText; @Override protected void onCreate(Bundle savedInstanceState) { Log.d(TAG, OnCreate begins); super.onCreate(savedInstanceState); setContentView(R.layout.notes_fetch); new HttpConnect1().execute(); } private class HttpConnect1 extends AsyncTaskVoid, Void, Void { @Override protected Void doInBackground(Void... nulls) { 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); dis.close(); conn.disconnect(); } catch(Exception e) { Log.e(TAG, Exception getting HTTPResponse); return null; } return null; } @Override protected void onPostExecute(Void nothing) { TextView bodyText = (TextView) findViewById (R.id.android_fetchtext); bodyText.setText(dataText); } } On Oct 20, 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 -~--~~~~--~~--~--~---
[android-developers] Re: Activity launch timeout even with wakelock
Kiran wrote: I updated the code as following. However, now I see that the display is not updated with the text. Am I missing something? static String linkUrl = http://www.google.com;; String dataText; @Override protected void onCreate(Bundle savedInstanceState) { Log.d(TAG, OnCreate begins); super.onCreate(savedInstanceState); setContentView(R.layout.notes_fetch); new HttpConnect1().execute(); } private class HttpConnect1 extends AsyncTaskVoid, Void, Void { @Override protected Void doInBackground(Void... nulls) { 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); dis.close(); conn.disconnect(); } catch(Exception e) { Log.e(TAG, Exception getting HTTPResponse); return null; } return null; } @Override protected void onPostExecute(Void nothing) { TextView bodyText = (TextView) findViewById (R.id.android_fetchtext); bodyText.setText(dataText); } } It is impossible to tell. Use a debugger, or put some Log calls in onPostExecute(), and confirm that it is being called. Or, check your LogCat to see if you are getting an exception that is being logged by your existing code. -- 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 -~--~~~~--~~--~--~---
[android-developers] Re: Activity launch timeout even with wakelock
I did that.. every statement is properly executed and see that bodyText.setText(dataText); is called and the value of dataText is the full html of the google.com On Oct 22, 4:47 pm, Mark Murphy mmur...@commonsware.com wrote: Kiran wrote: I updated the code as following. However, now I see that the display is not updated with the text. Am I missing something? static String linkUrl = http://www.google.com;; String dataText; �...@override protected void onCreate(Bundle savedInstanceState) { Log.d(TAG, OnCreate begins); super.onCreate(savedInstanceState); setContentView(R.layout.notes_fetch); new HttpConnect1().execute(); } private class HttpConnect1 extends AsyncTaskVoid, Void, Void { �...@override protected Void doInBackground(Void... nulls) { 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); dis.close(); conn.disconnect(); } catch(Exception e) { Log.e(TAG, Exception getting HTTPResponse); return null; } return null; } �...@override protected void onPostExecute(Void nothing) { TextView bodyText = (TextView) findViewById (R.id.android_fetchtext); bodyText.setText(dataText); } } It is impossible to tell. Use a debugger, or put some Log calls in onPostExecute(), and confirm that it is being called. Or, check your LogCat to see if you are getting an exception that is being logged by your existing code. -- 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 -~--~~~~--~~--~--~---
[android-developers] Re: Activity launch timeout even with wakelock
Kiran wrote: I did that.. every statement is properly executed and see that bodyText.setText(dataText); is called and the value of dataText is the full html of the google.com OK, try using hierarchyviewer to confirm that your TextView is actually on screen, visible, etc. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://twitter.com/commonsguy _The Busy Coder's Guide to *Advanced* Android Development_ Version 1.1 Available! --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[android-developers] Re: Activity launch timeout even with wakelock
Experts, Any help here? Thanks On Oct 20, 8:23 am, Kiran kiran.julapa...@gmail.com wrote: Hi, I have the following code in Oncreate of my activity: *** * 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(); 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; } TextView bodyText = (EditText) findViewById (R.id.android_fetchtext); bodyText.setText(dataText); setContentView(R.layout.notes_fetch); wl.release(); } *** * I declared the following permissions in manifest: *** * uses-permission android:name=android.permission.INTERNET / uses-permission android:name=android.permission.WAKE_LOCK/ *** * Here is my xml layout file: *** * ?xml version=1.0 encoding=utf-8? LinearLayout xmlns:android=http://schemas.android.com/apk/res/ android android:layout_width=wrap_content android:layout_height=wrap_content ListView android:id=@+id/android:fetchlist android:layout_width=wrap_content android:layout_height=wrap_content/ TextView android:id=@+id/android:fetchtext android:layout_width=wrap_content android:layout_height=wrap_content/ /LinearLayout *** * Problem is, application goes to force close with following error: *** * 10-19 22:11:49.404: DEBUG/FetchData(715): Entered OnCreate 10-19 22:11:49.413: DEBUG/FetchData(715): Set URL 10-19 22:11:49.435: DEBUG/FetchData(715): HttpURLConnection 10-19 22:11:49.464: DEBUG/FetchData(715): DIS 10-19 22:11:56.013: DEBUG/FetchData(715): Read 10-19 22:11:59.191: WARN/ActivityManager(574): Launch timeout has expired, giving up wake lock! -- 10-19 22:11:59.307: WARN/ActivityManager(574): Activity idle timeout for HistoryRecord{438d4478 com.android.demo.notepad3/.FetchData} --- 10-19 22:12:01.455: DEBUG/AndroidRuntime(715): Shutting down VM 10-19 22:12:01.455: WARN/dalvikvm(715): threadid=3: thread exiting with uncaught exception (group=0x4001aa28) 10-19 22:12:01.465: ERROR/AndroidRuntime(715): Uncaught handler: thread main exiting due to uncaught exception 10-19 22:12:01.834: ERROR/AndroidRuntime(715): java.lang.RuntimeException: Unable to start activity ComponentInfo {com.android.demo.notepad3/com.android.demo.notepad3.FetchData}: java.lang.NullPointerException 10-19 22:12:01.834: ERROR/AndroidRuntime(715): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java: 2401) 10-19 22:12:01.834: ERROR/AndroidRuntime(715): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java: 2417) 10-19 22:12:01.834: ERROR/AndroidRuntime(715): at android.app.ActivityThread.access$2100(ActivityThread.java:116) 10-19 22:12:01.834: ERROR/AndroidRuntime(715): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794) 10-19 22:12:01.834: ERROR/AndroidRuntime(715): at android.os.Handler.dispatchMessage(Handler.java:99) 10-19 22:12:01.834: ERROR/AndroidRuntime(715): at android.os.Looper.loop(Looper.java:123) 10-19 22:12:01.834: ERROR/AndroidRuntime(715): at android.app.ActivityThread.main(ActivityThread.java:4203) 10-19 22:12:01.834: ERROR/AndroidRuntime(715): at java.lang.reflect.Method.invokeNative(Native Method) 10-19 22:12:01.834: ERROR/AndroidRuntime(715): at java.lang.reflect.Method.invoke(Method.java:521) 10-19 22:12:01.834: ERROR/AndroidRuntime(715): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:791) 10-19 22:12:01.834: ERROR/AndroidRuntime(715): at
[android-developers] Re: Activity launch timeout even with wakelock
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 -~--~~~~--~~--~--~---
[android-developers] Re: Activity launch timeout even with wakelock
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 -~--~~~~--~~--~--~---
[android-developers] Re: Activity launch timeout even with wakelock
Maybe it's trying to access an external website during the processing of onCreate. Try pulling this on a worker thread. -- RichardC On Oct 20, 7:28 pm, Kiran Julapalli kiran.julapa...@gmail.com wrote: 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 -~--~~~~--~~--~--~---
[android-developers] Re: Activity launch timeout even with wakelock
On Tue, Oct 20, 2009 at 11:28 AM, Kiran Julapalli kiran.julapa...@gmail.com wrote: I am acquiring a wakelock as the error points to giving up a wake lock. That message is about the activity manager releasing its internal wake lock because it has given up on hearing back from the application in a timely manner. -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---