6 c# exception visual-studio xamarin.android xamarin
我正在开发一个Xamarin.Android应用程序.每当我尝试下载JSON提要时,我都会收到错误"您的应用程序已进入中断状态,但没有代码显示,因为所有线程都在执行外部代码".
我的json feed下载代码
string url = "http://xamdev.epizy.com/getData1.php";
public async void downloadJsonFeedAsync(String url) {
var httpClient = new HttpClient();
Task<string> contentsTask = httpClient.GetStringAsync(url);
// await! control returns to the caller and the task continues to run on another thread
string content = await contentsTask;
Console.Out.WriteLine("Response Body: \r\n {0}", content);
//Convert string to JSON object
result = Newtonsoft.Json.JsonConvert.DeserializeObject<RootObject> (content);
//Update listview
RunOnUiThread (() => {
listView.Adapter = new CusotmListAdapter(this, result.posts);
progress.Visibility = ViewStates.Gone;
});
}
Run Code Online (Sandbox Code Playgroud)我在这条线上有错误
string content = await contentsTask;
这是我的json
{"posts":[{"id":"1","url":"","title":"在Android应用程序中将语音转换为文本","日期":"2017-06-16 06:15: 18","content":"将语音转换为Tex在Android应用程序中将语音转换为文本在Android应用程序的Android应用程序中将语音转换为文本","缩略图":"http:\ /\/ stacktips.com\/ wp-content\/ uploads\/ 2017\/ 01\/Speech-to-Text-in-Android-375x300.jpeg"}]}
请问有人告诉我我的代码有什么问题吗?提前致谢..
这是我的php webservice代码 -
<?php
if($_SERVER['REQUEST_METHOD']=='GET'){
require_once('conn.php');
$sql = "SELECT * FROM space";
if ($result = mysqli_query($conn, $sql))
{
$resultArray = array();
$tempArray = array();
while($row = $result->fetch_object())
{
$tempArray = $row;
array_push($resultArray, $tempArray);
}
echo json_encode(array("result"=>$resultArray));
}
mysqli_close($conn);
}
?>
Run Code Online (Sandbox Code Playgroud)
imm*_*odi 12
对于这个问题,我很惊讶但没有找到最佳答案.对我而言,上述解决方案无效.要解决此问题,我将从调试菜单中禁用以下选项.
Debug > Options > General > Uncheck "Enable Just My Code"
Run Code Online (Sandbox Code Playgroud)
有关更多详细信息,请查看microsoft msdn help.
归档时间: |
|
查看次数: |
19381 次 |
最近记录: |