HTML 소스를 가져 오려고하지만 앱이 멈추고 있습니다. 문제가 무엇인지 모르겠으며 인터넷 사용 권한을 추가했습니다. 사이트에서이 코드를 가져 왔지만 나와 작동하지 않습니다. 버튼을 누를 때까지 작동 한 다음 멈 춥니 다.WebView에서 웹 사이트 소스 코드 가져 오기
내가 어떤 사람이 좀 도와 수 있기를 바랍니다, 여기에 내가 사용하고 코드입니다 :
메인 스레드에서 네트워크 작업을 수행하는 것 외에도public class MainActivity extends Activity {
private String HTML = "";
EditText tv;
private ProgressDialog m_ProgressDialog;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button btn = (Button)findViewById(R.id.button1);
tv = (EditText)findViewById(R.id.editText1);
btn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
getHTML("http://m.Facebook.com/");
}
});
}
public void getHTML(String paramString)
{
try
{
BufferedInputStream localBufferedInputStream = new BufferedInputStream(new URL(paramString).openConnection().getInputStream());
ByteArrayBuffer localByteArrayBuffer = new ByteArrayBuffer(50);
while (true)
{
int i = localBufferedInputStream.read();
if (i == -1)
{
HTML = new String(localByteArrayBuffer.toByteArray());
handler.sendEmptyMessage(0);
return;
}
i = (byte)i;
localByteArrayBuffer.append(i);
}
}
catch (Exception localException)
{
while (true)
this.HTML = "Error!";
}
}
private Handler handler = new Handler()
{
public void handleMessage(Message paramMessage)
{
EditText localEditText = (EditText)MainActivity.this.findViewById(R.id.editText1);
MainActivity.this.m_ProgressDialog.dismiss();
localEditText.setText(MainActivity.this.HTML);
}
};
}