第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

在調(diào)用方法中改造空錯誤

在調(diào)用方法中改造空錯誤

慕的地6264312 2021-07-06 17:57:17
我想通過改造從 MySQL 數(shù)據(jù)庫中獲取最后一個 id 但是當(dāng)運(yùn)行項(xiàng)目有錯誤時,使用郵遞員測試的調(diào)用方法值并獲取值A(chǔ)PIClient.java :public class APIClient {private static final String BASE_URL = "http://**********/Api/";private static Retrofit retrofit = null;public static Retrofit getClient() {    if (retrofit == null) {        retrofit = new Retrofit.Builder().baseUrl(BASE_URL).addConverterFactory(GsonConverterFactory.create())                .build();    }    return retrofit;}}APIIinterface.java :public interface APIIinterface {@POST("Agahi/getlastid.php")Call<AgahiLastId> getAgahiLastId(); }AgahiLastId.java :public class AgahiLastId {    @SerializedName("agahi_id")    private int agahi_id;    public int getAgahi_id() {        return agahi_id;    }    public void setAgahi_id(int agahi_id) {        this.agahi_id = agahi_id;    }}主活動.java :       public class MainActivity extends AppCompatActivity {private APIIinterface apiIinterface;@Overrideprotected void onCreate(Bundle savedInstanceState) {    super.onCreate(savedInstanceState);    setContentView(R.layout.activity_main);Call<AgahiLastId> agahiLastIdCall = apiIinterface.getAgahiLastId();agahiLastIdCall.enqueue(new Callback<AgahiLastId>() {    @Override    public void onResponse(Call<AgahiLastId> call, Response<AgahiLastId> response) {        if (response.isSuccessful()) {            Log.d("lts","ok");        }    }    @Override    public void onFailure(Call<AgahiLastId> call, Throwable t) {    }});}我有這一行的錯誤:Call<AgahiLastId> agahiLastIdCall = apiIinterface.getAgahiLastId();錯誤日志: Attempt to invoke the interface method 'retrofit2. Call app.zagroszoom.mseif.com.zagroszoom.webService.APIIinterface.getAgahiLastId()' on a null object reference
查看完整描述

2 回答

?
犯罪嫌疑人X

TA貢獻(xiàn)2080條經(jīng)驗(yàn) 獲得超4個贊

你需要在你的Mainactivity里面添加以下內(nèi)容onCreate之前Call<AgahiLastId> agahiLastIdCall = apiIinterface.getAgahiLastId();

apiIinterface= APIClient.getClient().create(APIIinterface.class);

在此處了解更多信息Retrofit


查看完整回答
反對 回復(fù) 2021-07-14
  • 2 回答
  • 0 關(guān)注
  • 242 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號