簡體   English   中英

Android HttpResponse不是通用的

[英]Android HttpResponse not generic

我收到錯誤消息: The type HttpResponse is not generic; it cannot be parameterized with arguments <JsonNode> The type HttpResponse is not generic; it cannot be parameterized with arguments <JsonNode>

在正常的Java中,它可以工作,但在Android中,不是嗎?

     try 
        {  
           HttpResponse<JsonNode> jsonResponse = Unirest.post("http://example.com/example.php")
             .field("sender", sender)
             .field("body", body)

             .asJson();
              System.out.println(jsonResponse.getBody().toString());
        }
        catch(Exception e)
        {
            System.out.println(e);
        }

進口:

import org.apache.http.HttpResponse;

import com.mashape.unirest.http.JsonNode;
import com.mashape.unirest.http.Unirest;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.Window;
import android.widget.EditText;

您需要import com.mashape.unirest.http.HttpResponse;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM