2016-04-26 36 views
0

我有登錄功能在我的app.My應用程序連接到打開的API,其succesfull請求,我沒事,代碼== 200.我需要得到此用戶的通道列表。但是當我創建認證會話時,什麼我可以做什麼?當我檢查「if(response.isSuccessful())」 我可以開始新的活動並獲取用戶視頻嗎?我插入部分代碼喜歡這個?驗證創建,接下來我需要做什麼?

Call<SignInResults> call = videoApi.insertUser(username_value,password_value); 
    call.enqueue(new Callback<SignInResults>() { 

     @Override 
     public void onResponse(Call<SignInResults> call, Response<SignInResults> response) { 
      if(response.isSuccessful()) { 
       SignInResults results = response.body(); 
       Log.d("Response ==>> ", new GsonBuilder().setPrettyPrinting().create().toJson(results)); 
      } 
      else { 
       // handle error 
      } 
     } 

     @Override 
     public void onFailure(Call<SignInResults> call, Throwable t) { 

     } 
    }); 

回答

0

進展你的下一個合乎邏輯的步驟可能是保存結果(SignInResults),我猜會是某種API密鑰或[SharedPreferences][1]令牌,以便在未來使用的所有其他API接觸的方法,作爲你的認證機制。

SharedPreferences sharedPref = getActivity().getPreferences(Context.MODE_PRIVATE); 
SharedPreferences.Editor editor = sharedPref.edit(); 
editor.putInt("api_key", results.api_key); 
editor.commit(); 
+0

我無法獲取數據( SignInResults results = response.body(); is null –

相關問題