In android i am tring to fetch the data from website and displaying it through the code but i am getting these errors in logcat.
11-22 12:04:28.448: WARN/System.err(810): Can't dispatch DDM chunk 4d505251: no handler defined
11-22 12:05:44.558: WARN/WindowManager(577): Key dispatching timed out sending to com.hi/com.hi.hi
11-22 12:05:44.569: WARN/WindowManager(577): Dispatch state: {{KeyEvent{action=1 code=82 repeat=0 meta=0 scancode=229 mFlags=8} to Window{436a8aa8 com.hi/com.hi.hi paused=false} @ 1290407250374 lw=Window{436a8aa8 com.hi/com.hi.hi paused=false} lb=android.os.BinderProxy@435e2798 fin=false gfw=true ed=true tts=0 wf=true fp=false mcf=Window{437095c8 com.hi/com.hi.hi paused=false}}}
11-22 12:05:44.569: WARN/WindowManager(577): Current state: {{null to Window{437095c8 com.hi/com.hi.hi paused=false} @ 1290407744573 lw=Window{437095c8 com.hi/com.hi.hi paused=false} lb=android.os.BinderProxy@43709460 fin=false gfw=true ed=true tts=0 wf=false fp=false mcf=Window{437095c8 com.hi/com.hi.hi paused=false}}}
11-22 12:05:44.599: INFO/ActivityManager(577): ANR (application not responding) in process: com.hi
11-22 12:05:44.599: INFO/ActivityManager(577): Annotation: keyDispatchingTimedOut
11-22 12:05:44.599: INFO/ActivityManager(577): CPU usage:
11-22 12:05:44.599: INFO/ActivityManager(577): Load: 0.02 / 0.05 / 0.04
11-22 12:05:44.599: INFO/ActivityManager(577): CPU usage from 44599ms to 23ms ago:
11-22 12:05:44.599: INFO/ActivityManager(577): system_server: 2% = 1% user + 0% kernel
11-22 12:05:44.599: INFO/ActivityManager(577): qemud: 0% = 0% user + 0% kernel
11-22 12:05:44.599: INFO/ActivityManager(577): com.android.phone: 0% = 0% user + 0% kernel
11-22 12:05:44.599: INFO/ActivityManag开发者_运维技巧er(577): com.hi: 0% = 0% user + 0% kernel
11-22 12:05:44.599: INFO/ActivityManager(577): events/0: 0% = 0% user + 0% kernel
11-22 12:05:44.599: INFO/ActivityManager(577): rild: 0% = 0% user + 0% kernel
11-22 12:05:44.599: INFO/ActivityManager(577): adbd: 0% = 0% user + 0% kernel
11-22 12:05:44.599: INFO/ActivityManager(577): TOTAL: 1% = 0% user + 1% kernel + 0% softirq
11-22 12:05:44.609: INFO/ActivityManager(577): Removing old ANR trace file from /data/anr/traces.txt
11-22 12:05:44.629: INFO/Process(577): Sending signal. PID: 810 SIG: 3
11-22 12:05:44.629: INFO/dalvikvm(810): threadid=7: reacting to signal 3
11-22 12:05:44.648: INFO/Process(577): Sending signal. PID: 619 SIG: 3
11-22 12:05:44.648: INFO/dalvikvm(619): threadid=7: reacting to signal 3
11-22 12:05:44.648: INFO/Process(577): Sending signal. PID: 724 SIG: 3
11-22 12:05:44.648: INFO/dalvikvm(724): threadid=7: reacting to signal 3
11-22 12:05:44.648: INFO/Process(577): Sending signal. PID: 666 SIG: 3
11-22 12:05:44.648: INFO/dalvikvm(666): threadid=7: reacting to signal 3
11-22 12:05:44.648: INFO/Process(577): Sending signal. PID: 642 SIG: 3
11-22 12:05:44.659: INFO/dalvikvm(642): threadid=7: reacting to signal 3
11-22 12:05:44.659: INFO/Process(577): Sending signal. PID: 656 SIG: 3
11-22 12:05:44.659: INFO/dalvikvm(656): threadid=7: reacting to signal 3
11-22 12:05:44.659: INFO/Process(577): Sending signal. PID: 577 SIG: 3
11-22 12:05:44.659: INFO/dalvikvm(577): threadid=7: reacting to signal 3
11-22 12:05:44.730: INFO/dalvikvm(666): Wrote stack trace to '/data/anr/traces.txt'
11-22 12:05:44.730: INFO/dalvikvm(724): Wrote stack trace to '/data/anr/traces.txt'
11-22 12:05:44.739: INFO/dalvikvm(619): Wrote stack trace to '/data/anr/traces.txt'
11-22 12:05:44.739: INFO/dalvikvm(577): Wrote stack trace to '/data/anr/traces.txt'
11-22 12:05:44.748: INFO/Process(577): Sending signal. PID: 617 SIG: 3
11-22 12:05:44.748: INFO/dalvikvm(617): threadid=7: reacting to signal 3
11-22 12:05:44.789: INFO/dalvikvm(642): Wrote stack trace to '/data/anr/traces.txt'
11-22 12:05:44.789: INFO/dalvikvm(810): Wrote stack trace to '/data/anr/traces.txt'
11-22 12:05:44.829: INFO/dalvikvm(617): Wrote stack trace to '/data/anr/traces.txt'
This is an ApplicationnNotResponding error, the problem is likely in your code.
Have a look here: http://developer.android.com/guide/practices/design/responsiveness.html
This is My Program
public class hi extends Activity implements OnClickListener,Runnable { /** Called when the activity is first created. */
TextView txt;
Button but1;
String str;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
txt = (TextView) findViewById(R.id.text);
but1 = (Button) findViewById(R.id.btn_get_data);
but1.setOnClickListener(this);
}
private InputStream OpenHttpConnection(String urlString) throws IOException {
InputStream in = null;
int response = -1;
URL url = new URL(urlString);
URLConnection conn = url.openConnection();
if (!(conn instanceof HttpURLConnection))
throw new IOException("Not an HTTP connection");
try {
HttpURLConnection httpConn = (HttpURLConnection) conn;
//httpConn.setAllowUserInteraction(false);
httpConn.setInstanceFollowRedirects(true);
httpConn.setRequestMethod("GET");
httpConn.connect();
response = httpConn.getResponseCode();
if (response == HttpURLConnection.HTTP_OK) {
in = httpConn.getInputStream();
}
} catch (Exception ex) {
ex.printStackTrace();
}
return in;
}
private String DownloadText(String URL) {
int BUFFER_SIZE = 2000;
InputStream in = null;
try {
in = OpenHttpConnection(URL);
Log.i("Open connection","HTTP CONNECTION OPENED");
} catch (IOException e1) {
e1.printStackTrace();
return "";
}
InputStreamReader isr = new InputStreamReader(in);
int charRead;
String str = "";
char[] inputBuffer = new char[BUFFER_SIZE];
try
{
while ((charRead = isr.read(inputBuffer)) > 0)
{
// ---convert the chars to a String---
String readString = String
.copyValueOf(inputBuffer, 0, charRead);
str += readString;
inputBuffer = new char[BUFFER_SIZE];
}
in.close();
}
catch (IOException e)
{
e.printStackTrace();
return "";
}
return str;
}
public void onClick(View v)
{
//str = DownloadText("http://www.yahoo.com");
//txt.setText(str);
Thread t=new Thread(new hi());
t.start();
}
@Override
public void run()
{
str = DownloadText("http://www.yahoo.com");
txt.setText(str);
}
}
精彩评论