我有以下代码我把它放在点击我想把 urlAll(源代码)放在 AlertDialog
String urlAll="localhost/admin";
new DownloadTask().execute(urlAll);
new AlertDialog.Builder(PrintDemo.this).setTitle("Message").setMessage(urlAll).setPositiveButton(android.R.string.ok, null).setCancelable(false).create().show();
在运动中我收到以下消息
上面代码的结果(但我想要源代码)我正在使用 DownloadTask
本地主机/管理员
这里是下载任务函数
private class DownloadTask extends AsyncTask<String, Void, String>{
@Override
protected String doInBackground(String... urls) {
HttpResponse response = null;
HttpGet httpGet = null;
HttpClient mHttpClient = null;
String s = "";
try {
if(mHttpClient == null){
mHttpClient = new DefaultHttpClient();
}
httpGet = new HttpGet(urls[0]);
response = mHttpClient.execute(httpGet);
s = EntityUtils.toString(response.getEntity(), "UTF-8");
} catch (IOException e) {
e.printStackTrace();
}
return s;
}
感谢您的帮助。
最佳答案
作为您问题的答案,我将在此处发布。
我为你创建了一个要点。
https://gist.github.com/eneim/59df18b4f92065e7d409
请在要点中发表评论(如果没有 github 帐户,请创建一个)。我们不应该在这里继续讨论:)
请提供更多关于您的“ClickEvent”的信息。但基本上,流程应该是这样的。
关于java - android - DownloadTask - 如何将源代码放入对话框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28059316/