我创建了此代码来下载Web内容,并使用了asynctask。当网址以“ http”开头时,它不会在日志目录中返回任何错误。
*“ 09-12 22:19:25.679 6894-6921 / company.krystian.guessthecelebrity W / OpenGLRenderer:无法使用EGL_SWAP_BEHAVIOR_PRESERVED选择配置,请重试而无需...
09-12 22:19:25.754 6894-6921 / company.krystian.guessthecelebrity E / eglCodecCommon:glUtilsParamSize:unknow param 0x000082da glUtilsParamSize:未知参数0x000082da“ *
但是,如果URL地址以“ https”开头,则会返回我一部分内容和另一个错误。
*“ 09-12 22:13:36.330 3057-3784 / company.krystian.guessthecelebrity W / OpenGLRenderer:无法使用EGL_SWAP_BEHAVIOR_PRESERVED选择配置,请重试而无需...
09-12 22:13:36.390 3057-3784 / company.krystian.guessthecelebrity E / eglCodecCommon:glUtilsParamSize:unknow param 0x000082da glUtilsParamSize:未知参数0x000082da“ *
public class MainActivity extends AppCompatActivity {
public class DownloadTask extends AsyncTask<String, Void, String> {
@Override
protected String doInBackground(String... urls) {
String result = "";
URL url;
HttpURLConnection urlConnection = null;
try {
url = new URL(urls[0]);
urlConnection = (HttpURLConnection) url.openConnection();
InputStream in = urlConnection.getInputStream();
InputStreamReader reader = new InputStreamReader(in);
int data = reader.read();
while (data != -1) {
char current = (char) data;
result += current;
data = reader.read();
}
return result;
} catch (Exception e) {
e.printStackTrace();
return "Fail";
}
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
DownloadTask task = new DownloadTask();
String result = null;
try {
result = task.execute("http://www.ecowebhosting.co.uk/").get();
Log.i("Contents of URL", result);
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}
}
答案 0 :(得分:1)
这是我的工作代码片段:
min(result[result$predict==1,]$p1)
# [1] 0.3644026
max(result[result$predict==0,]$p1)
# [1] 0.3602365
# Thresholds found by maximizing the metrics on the training dataset
fit@model$training_metrics@metrics$max_criteria_and_metric_scores
#Maximum Metrics: Maximum metrics at their respective thresholds
# metric threshold value idx
#1 max f1 0.314699 0.641975 200
#2 max f2 0.215203 0.795148 262
#3 max f0point5 0.451965 0.669856 74
#4 max accuracy 0.451965 0.707581 74
#5 max precision 0.998285 1.000000 0
#6 max recall 0.215203 1.000000 262
#7 max specificity 0.998285 1.000000 0
#8 max absolute_mcc 0.451965 0.395147 74
#9 max min_per_class_accuracy 0.360174 0.652542 127
#10 max mean_per_class_accuracy 0.391279 0.683269 97
# Thresholds found by maximizing the metrics on the validation dataset
fit@model$validation_metrics@metrics$max_criteria_and_metric_scores
#Maximum Metrics: Maximum metrics at their respective thresholds
# metric threshold value idx
#1 max f1 0.363477 0.607143 33
#2 max f2 0.292342 0.785714 51
#3 max f0point5 0.643382 0.725806 9
#4 max accuracy 0.643382 0.774194 9
#5 max precision 0.985308 1.000000 0
#6 max recall 0.292342 1.000000 51
#7 max specificity 0.985308 1.000000 0
#8 max absolute_mcc 0.643382 0.499659 9
#9 max min_per_class_accuracy 0.379602 0.650000 28
#10 max mean_per_class_accuracy 0.618286 0.702273 11
result[order(result$predict),]
# predict p0 p1
#5 0 0.703274569 0.2967254
#6 0 0.639763460 0.3602365
#13 0 0.689557497 0.3104425
#14 0 0.656764541 0.3432355
#15 0 0.696248328 0.3037517
#16 0 0.707069611 0.2929304
#18 0 0.692137408 0.3078626
#19 0 0.701482762 0.2985172
#20 0 0.705973644 0.2940264
#21 0 0.701156961 0.2988430
#22 0 0.671778898 0.3282211
#24 0 0.646735016 0.3532650
#26 0 0.646582708 0.3534173
#27 0 0.690402957 0.3095970
#32 0 0.649945017 0.3500550
#37 0 0.804937468 0.1950625
#40 0 0.717706731 0.2822933
#41 0 0.642094040 0.3579060
#1 1 0.364577068 0.6354229
#2 1 0.503432724 0.4965673
#3 1 0.406771233 0.5932288
#4 1 0.551801718 0.4481983
#7 1 0.339600779 0.6603992
#8 1 0.002978593 0.9970214
#9 1 0.378034417 0.6219656
#10 1 0.596298925 0.4037011
#11 1 0.635597359 0.3644026
#12 1 0.552662241 0.4473378
#17 1 0.615302107 0.3846979
#23 1 0.628906297 0.3710937
#25 1 0.600791894 0.3992081
#28 1 0.216571552 0.7834284
#29 1 0.559174924 0.4408251
#30 1 0.489514642 0.5104854
#31 1 0.623958696 0.3760413
#33 1 0.504691497 0.4953085
#34 1 0.582509462 0.4174905
#35 1 0.504136056 0.4958639
#36 1 0.463076505 0.5369235
#38 1 0.510908093 0.4890919
#39 1 0.469376828 0.5306232
这是调用代码:
private class GetRegisterDateAsyncTask extends AsyncTask<Void, Void, String> {
@Override
protected String doInBackground(Void... voids) {
String result = "";
try {
URL url = new URL("YOUR URL HERE");
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
String inputLine;
final StringBuffer buffer = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
buffer.append(inputLine);
}
in.close();
result = buffer.toString();
} catch (MalformedURLException e) {
Crashlytics.logException(e);
return "";
} catch (IOException e) {
Crashlytics.logException(e);
return "";
} catch (Exception e) {
Crashlytics.logException(e);
return "";
}
return result;
}
@Override
protected void onPostExecute(String result) {
try {
// check and use the result here
...
} catch (Exception e) {
Crashlytics.logException(e);
}
}
}
祝你好运