小编qwe*_*rty的帖子

如何从一个方法返回2个值并在一个类中使用这两个值?

我正在尝试从Microsoft获得此代码,但我想将它们所做的两个功能结合起来.一个是分析图像,一个是检测名人.但是,我在如何从一个函数返回2个值时遇到困难.这是处理方法......

private String process() throws VisionServiceException, IOException {
    Gson gson = new Gson();
    String model = "celebrities";

    ByteArrayOutputStream output = new ByteArrayOutputStream();
    bitmapPicture.compress(Bitmap.CompressFormat.JPEG, 100, output);
    ByteArrayInputStream inputStream = new ByteArrayInputStream(output.toByteArray());


    AnalysisResult v = this.client.describe(inputStream, 1);
    AnalysisInDomainResult m = this.client.analyzeImageInDomain(inputStream,model);

    String result = gson.toJson(v);
    String result2 = gson.toJson(m);

    Log.d("result", result);

    return result, result2;
}
Run Code Online (Sandbox Code Playgroud)

并将这两种结果与这种方法结合起来......

    @Override
protected void onPostExecute(String data) {
    super.onPostExecute(data);

    mEditText.setText("");
    if (e != null) {
        mEditText.setText("Error: " + e.getMessage());
        this.e = null;
    } else {
        Gson gson = …
Run Code Online (Sandbox Code Playgroud)

java android return microsoft-cognitive

3
推荐指数
1
解决办法
859
查看次数

标签 统计

android ×1

java ×1

microsoft-cognitive ×1

return ×1