问题描述
我正在尝试将Android Pay集成到我的应用程序中,并且正在遵循google提供的教程.但是我被困在执行IsReadyToPayRequest
的地方;
I am attempting to integrate Android Pay into my application and I am following the tutorial provided b google. However I am stuck at the point where the IsReadyToPayRequest
is executed;
IsReadyToPayRequest request =
IsReadyToPayRequest.fromJson(getIsReadyToPayRequest().toString());
Task<Boolean> task = mPaymentsClient.isReadyToPay(request);
task.addOnCompleteListener(
new OnCompleteListener<Boolean>() {
@Override
public void onComplete(@NonNull Task<Boolean> task) {
try {
boolean result = task.getResult(ApiException.class);
if (result) {
// show Google Pay as a payment option
}
} catch (ApiException e) {
}
}
});
我遇到错误,无法解析方法'fromJson java.lang.string'
I am getting the error, cannot resolve method 'fromJson java.lang.string'
我正在使用com.google.android.gms:play-services:12.0.1
I am using com.google.android.gms:play-services:12.0.1
任何帮助将不胜感激.
推荐答案
fromJson
方法相对较新,因为您可以找到此处.
The fromJson
method is relatively new, as you can find here.
因此,您需要较新的库版本,或者如果要保留旧版本,请使用旧的Builder.
According to this, you need a newer library version or use the old Builder if you want to stick to your old version.
这篇关于IsReadyToPayRequest.fromJson,无法解析方法"fromJson java.lang.string"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!