Skip to content

Instantly share code, notes, and snippets.

@Starksoft
Starksoft / BundleExt.kt
Created May 1, 2026 19:56
Реализация замены bundleOf в Android
package ru.starksoft.core.utils.ext
private const val TAG = "BundleExt"
/**
* Type-safe replacement for the deprecated [androidx.core.os.bundleOf].
*
* Unlike the AndroidX version which accepts `Pair<String, Any?>` and may crash at runtime
* on unsupported types (e.g. `SparseArray`), these overloads constrain the value type at
* compile time. Use one overload per call — all pairs in a single invocation must share
@Starksoft
Starksoft / clientCert.android.java
Created October 15, 2020 16:57 — forked from milhomem/clientCert.android.java
How to connect using Client Certificate in Android with OkHttp
KeyStore keyStore = KeyStore.getInstance("PKCS12");
FileInputStream clientCertificateContent = new FileInputStream("/path/to/publicAndPrivateKey.p12");
keyStore.load(clientCertificateContent, "private key password".toCharArray());
KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
keyManagerFactory.init(keyStore, "private key password".toCharArray());
FileInputStream myTrustedCAFileContent = new FileInputStream("/path/to/embedded/CA-Chain.pem");
CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509");
X509Certificate myCAPublicKey = (X509Certificate) certificateFactory.generateCertificate(myTrustedCAFileContent);