com.android.volley.NoConnectionError: javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
Run Code Online (Sandbox Code Playgroud)
我在 19 到 24 的 api 上的 logcat 中收到此错误,并且我的应用程序中没有从服务器加载数据我搜索了该错误并找到了解决方案
@SuppressLint("TrulyRandom")
public static void handleSSLHandshake() {
try {
TrustManager[] trustAllCerts = new TrustManager[]{new X509TrustManager() {
public X509Certificate[] getAcceptedIssuers() {
return new X509Certificate[0];
}
@Override
public void checkClientTrusted(X509Certificate[] certs, String authType) {
}
@Override
public void checkServerTrusted(X509Certificate[] certs, String authType) {
}
}};
SSLContext sc = SSLContext.getInstance("SSL");
sc.init(null, trustAllCerts, new SecureRandom());
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() {
@Override
public boolean verify(String arg0, SSLSession …Run Code Online (Sandbox Code Playgroud) android android-volley android-security trustmanager x509trustmanager
我正在尝试使用https://developers.google.com/identity/sign-in/android/在我的 android 应用程序中使用 google 登录,但是当尝试使用我的项目包和 SHA1 密钥配置项目时,我出现这个错误
Couldn't create OAuth client
warning
Requested entity already exists
Run Code Online (Sandbox Code Playgroud)
我搜索了我之前是否使用此包和 SHA 创建了一个项目,并发现我的同事在之前的项目中使用它,他尝试添加它并收到相同的警告,然后他删除了它,我再次尝试使用我的项目,但问题仍然存在存在。
我正在尝试在 android 中使用第 3 方库,其中 PaymentActivity 开始付款
这是代码:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tv = findViewById(R.id.tv);
btn = findViewById(R.id.button);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(MainActivity.this, PaymentActivity.class);//Checkout activity
DPSettings dpSettings = new DPSettings();
intent.putExtra(PaymentConstants.TRANSACTION_URL, "");
intent.putExtra(PaymentConstants.PLATFORM_TYPE, dpSettings.getPlatformType());
intent.putExtra(PaymentConstants.TRANSACTION_BLOCK, "");
intent.putExtra(PaymentConstants.PAYMENT_FIELD_BLOCK, "");
intent.putExtra(PaymentConstants.BILLING_BLOCK, "");
intent.putExtra(PaymentConstants.SHIPPING_BLOCK, "");
intent.putExtra(PaymentConstants.OTHER_DETAILS_BLOCK, "");
startActivityForResult(intent,1);
}
});
}
Run Code Online (Sandbox Code Playgroud)
但是当我运行应用程序并单击按钮开始活动时,没有任何操作,但在 logcat 中我发现了以下消息:
2019-07-31 10:02:58.308 1600-6058/? I/ActivityManager: START u0 {cmp=porter.aia.com.paymenttesting/dp.toml.directpay.PaymentActivity (has extras)} from uid 10082
2019-07-31 10:03:00.639 1412-1412/? D/SurfaceFlinger: …Run Code Online (Sandbox Code Playgroud) 我正在尝试制作一个包含多个项目的嵌套回收器视图,在完成适配器和设计并进行测试后,我在模拟器中得到了这个
\n\n\n\n我不明白为什么项目会这样出现,这些项目的高度和宽度与我为其布局设计而设计的高度和宽度不同。
\n\n这是 recyclerview 设置的代码
\n\n mRecyclerView.setHasFixedSize(true);\n adapter = new CheckoutMainRecyAdapter(CheckOutActivity.this, allSampleData);\n mRecyclerView.setLayoutManager(new LinearLayoutManager(CheckOutActivity.this));\n mRecyclerView.setAdapter(adapter);\nRun Code Online (Sandbox Code Playgroud)\n\n这是适配器代码
\n\npublic class CheckoutMainRecyAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {\n private ArrayList<CheckoutMainModel> dataList;\n private Context mContext;\n\npublic CheckoutMainRecyAdapter(Context context, ArrayList<CheckoutMainModel> dataList) {\n this.dataList = dataList;\n this.mContext = context;\n\n}\n\n@Override\npublic RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {\n View view;\n switch (i) {\n case Constants.type_checkout_address:\n view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.checkout_address_item, null);\n CheckoutMainRecyAdapter.AddressItemHolder mho = new CheckoutMainRecyAdapter.AddressItemHolder(view);\n return mho;\n case Constants.type_checkout_policy:\n view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.checkout_policy_item, null);\n CheckoutMainRecyAdapter.TermsItemHolder pro = new CheckoutMainRecyAdapter.TermsItemHolder(view);\n …Run Code Online (Sandbox Code Playgroud)