在我的应用程序中,我使用扩展或收缩AppBarLayout特定事件setExpanded(boolean, true).
我得到了一个很好的结果,使用了一个活泼动人的流体动画com.android.support:design:23.1.0,然后我更新到23.1.1了,动画变得非常缓慢而且根本没有活泼.
在源代码中android.support.design.widget.AppBarLayout,我将问题放在animateOffsetTo(下public static class Behavior extends HeaderBehavior<AppBarLayout>)中,在版本23.1.0中是这样的:
private void animateOffsetTo(final CoordinatorLayout coordinatorLayout,
final AppBarLayout child, int offset) {
if (mAnimator == null) {
mAnimator = ViewUtils.createAnimator();
mAnimator.setInterpolator(AnimationUtils.DECELERATE_INTERPOLATOR);
mAnimator.setUpdateListener(new ValueAnimatorCompat.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimatorCompat animator) {
setHeaderTopBottomOffset(coordinatorLayout, child,
animator.getAnimatedIntValue());
}
});
} else {
mAnimator.cancel();
}
mAnimator.setIntValues(getTopBottomOffsetForScrollingSibling(), offset);
mAnimator.start();
}
Run Code Online (Sandbox Code Playgroud)
在版本23.1.1中是这样的:
private void animateOffsetTo(final CoordinatorLayout coordinatorLayout,
final AppBarLayout child, final int offset) {
final …Run Code Online (Sandbox Code Playgroud) 在我的XML,我给自己定的focusable,focusableInTouchMode,clickable,和longClickable变量假的,但我仍然可以通过点击和移动搜索栏.我是否需要实际更改侦听器事件才能执行此操作?这似乎是不必要的.
我正在尝试使用Retrofit连接到android上的https服务器.这是我的OkHttpClient
@Provides
public OkHttpClient provideContactClient(){
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
ConnectionSpec spec = new ConnectionSpec.Builder(ConnectionSpec.MODERN_TLS)
.tlsVersions(TlsVersion.TLS_1_2)
.cipherSuites(CipherSuite.TLS_RSA_WITH_DES_CBC_SHA,
CipherSuite.TLS_RSA_WITH_AES_128_GCM_SHA256,
CipherSuite.TLS_DHE_RSA_WITH_AES_128_GCM_SHA256)
.build();
interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
SSLSocketFactory sslSocketFactory = null;
try {
SSLContext sslContext = SSLContext.getInstance("TLS");
sslContext.init(null, null, null);
sslSocketFactory = sslContext.getSocketFactory();
}catch (GeneralSecurityException e){
e.printStackTrace();
}
return new OkHttpClient.Builder()
.addInterceptor(interceptor)
.connectionSpecs(Collections.singletonList(spec))
.sslSocketFactory(sslSocketFactory)
.authenticator(new Authenticator() {
@Override
public Request authenticate(Route route, Response response) throws IOException {
if(responseCount(response) >= 5){
return null;
}
String credential = Credentials.basic("user", "pass");
return response.request().newBuilder().header("Authorization", credential).build();
}
})
.build();
} …Run Code Online (Sandbox Code Playgroud) 不getChildPosition()推荐使用的方法:不推荐使用recyclerview中的方法.这是什么的替代?
第一种方法在这里:
<?xml version="1.0" encoding="utf-8"?> <network-security-config>
<base-config> <trust-anchors> <certificates src="system"/>
<certificates src="user"/> </trust-anchors> </base-config>
<domain-config> <domain includeSubdomains="true">xyz.com</domain>
<trust-anchors> <certificates src="@raw/my_ca"/> </trust-anchors>
</domain-config> </network-security-config>
Run Code Online (Sandbox Code Playgroud)
内部清单文件:
android:network Security Config = "@xml/network_security_config"
我已经包含network_security_config在内部res/xml/network_security_config,ca证书在里面res/raw/my_ca.pem
第二种方法是:
import org.apache.http.client.HttpClient;
import org.apache.http.conn.ClientConnectionManager;
import org.apache.http.conn.scheme.Scheme;
import org.apache.http.conn.scheme.SchemeRegistry;
import org.apache.http.conn.ssl.SSLSocketFactory;
import org.apache.http.impl.client.DefaultHttpClient;
import java.io.IOException; import java.net.Socket;
import java.net.UnknownHostException;
import java.security.KeyManagementException;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.UnrecoverableKeyException;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate; import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager; …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用MAC地址连接到BLE设备.
BluetoothDevice device = bluetoothAdapter.getRemoteDevice(rememberedDeviceAddress)
bluetoothDevice.connectGatt(context, false, bluetoothGattCallback);
Run Code Online (Sandbox Code Playgroud)
我得到一个回调BluetoothGattCallback.onConnectionStateChange与status = 133和newState = 2 甚至当我的BLE装置被关闭.
newState = 2指的BluetoothProfile.STATE_CONNECTED是我连接到设备并且status = 133是GATT_ERROR(而不是status = 0 SUCCESS)
我没有得到注册回调错误的失败.
设备:一加一(Android 4.4)
任何可能导致此问题的指针都会有所帮助.
注意:问题不会发生在所有设备上.在Android 5.0的Nexus 5上,一切似乎都运行良好
请在下面找到堆栈跟踪:
03-06 13:00:11.994: D/BluetoothGatt(26771): registerApp()
03-06 13:00:11.994: D/BluetoothGatt(26771): registerApp() - UUID='uuid comes here'
03-06 13:00:12.004: D/BluetoothGatt(26771): onClientRegistered() - status=0 clientIf=5
03-06 13:00:42.004: D/BluetoothGatt(26771): onClientConnectionState() - status=133 clientIf=5 device='device id comes here'
Run Code Online (Sandbox Code Playgroud) 我正在重建我的 android 项目,它是用 java 编写的,一些类是用 kotlin 编写的。我在谷歌上搜索过,但我的问题没有解决。我在构建项目时遇到以下错误:
/home/bansal/.gradle/caches/transforms-2/files-2.1/0bea321a20a76ca878f594ef198fedcf/jetified-core-ktx-1.10.0-alpha02-api.jar!/META-INF/core-ktx_release.kotlin_module:模块已编译与 Kotlin 版本不兼容。其元数据的二进制版本是1.8.0,预期版本是1.6.0。
下面是我的 build.gradel
ext.kotlin_version = '1.6.10'
repositories {
google()
jcenter()
maven {
url 'http://dl.bintray.com/amulyakhare/maven'
}
}
dependencies {
classpath "com.android.tools.build:gradle:4.0.1"
classpath 'io.realm:realm-gradle-plugin:3.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Run Code Online (Sandbox Code Playgroud)
和模块 build.gradle
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
dependencies{
implementation 'androidx.core:core-ktx:1.7.0'
annotationProcessor 'android.arch.lifecycle:compiler:1.1.1'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'android.arch.lifecycle:viewmodel:1.1.1'
implementation 'android.arch.lifecycle:extensions:1.1.1'
//Coroutines
implementation …Run Code Online (Sandbox Code Playgroud)