Hi, I am reading one simple web page, but when I launched my
application after 2-3 min it show me output as : The operation timed
out.
Here ia my code
public void onCreate(Bundle icicle)
{
super.onCreate(icicle);
/* We will show the data we read in a TextView. */
TextView tv = new TextView(this);
/* Will be filled and displayed later. */
String myString = null;
try
{
/* Define the URL we want to load data from. */
URL myURL = new URL("http://www.google.com");
/* Open a connection to that URL. */
URLConnection ucon = myURL.openConnection();
/* Define InputStreams to read
* from the URLConnection. */
InputStream is = ucon.getInputStream();
BufferedInputStream bis = new BufferedInputStream(is);
/* Read bytes to the Buffer until
* there is nothing more to read(-1). */
ByteArrayBuffer baf = new ByteArrayBuffer(50);
int current = 0;
while((current = bis.read()) != -1)
{
baf.append((byte)current);
}
/* Convert the Bytes read to a String. */
myString = new String(baf.toByteArray());
}
catch (Exception e)
{
/* On any Error we want to display it. */
myString = e.getMessage();
}
System.out.println (myString);
/* Show the String on the GUI. */
tv.setText(myString);
this.setContentView(tv);
}
Logcat gives following info:
11-02 09:40:11.879: INFO/ActivityManager(63): Starting activity:
Intent { act=android.intent.action.MAIN
cat=[android.intent.category.LAUNCHER] flg=0x10200000
cmp=com.monarch.web/.GetDataFromTheWeb }
11-02 09:40:21.943: WARN/ActivityManager(63): Launch timeout has
expired, giving up wake lock!
11-02 09:40:22.071: WARN/ActivityManager(63): Activity idle timeout
for HistoryRecord{43d91bf0 com.monarch.web/.GetDataFromTheWeb}
11-02 09:43:30.310: INFO/ActivityManager(63): Displayed activity
com.monarch.web/.GetDataFromTheWeb: 198326 ms (total 198326 ms)
--
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