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 AsyncTask<Void, 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 [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 -~----------~----~----~----~------~----~------~--~---

