localChatManager.addIncomingListener { from, message, chat ->
Log.v(TAG,"listener")
//You can't modify views from non-UI thread.
this@chatActivity.runOnUiThread { object :Runnable{
override fun run() {
Log.i(TAG,"runOnUiThread")
}
} }
}
Run Code Online (Sandbox Code Playgroud)
我无法弄清楚为什么runOnUiThread不工作但在该方法之外一切正常.
Android Studio 2.2.3
Android Studio无法检测到logcat中的行号.有什么方法可以解决这个问题吗?它显示 未知来源代替行号.
添加LOGCAT只是指出问题的动摇.不要指出为什么NULL POINT EXCEPTION出现...
请忽略错误(我知道它为什么会发生).我已添加注销以显示问题所在.
Android studio显示的是Unknown Source而不是错误行号.
logcat的:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: user.com.hlthee, PID: 1107
java.lang.NullPointerException
at user.com.hlthee.Reminders$13.onClick(**Unknown Source**)
at android.support.v7.app.AlertController$ButtonHandler.handleMessage(Unknown Source)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
Run Code Online (Sandbox Code Playgroud) 我试图从函数返回布尔值.
fun validateDetails(jabberId:String, passwordText: String) {
if(jabberId.isEmpty()){
jabber_id.requestFocus()
jabber_id.error="Jabber id can't be null."
return false
}else if(jabberId.isBlank()){
jabber_id.requestFocus()
jabber_id.error="Jabber id can't be blank."
return false
}else if (passwordText.isNotEmpty()){
password.requestFocus();
password.error="Password can't be null."
return false
}
else{
return true
}
}
Run Code Online (Sandbox Code Playgroud)
错误:布尔文字不符合预期的类型单位.
我知道unit是kotlin中的默认返回类型.我将如何将其更改为布尔值.
我知道这是一个非常基本的问题。我尝试找到多种解决方案,但我无法理解它们。
我想要的是
将图像上传到服务器,作为回报,我得到了 URL,但问题是在使用此 URL 设置图像时,设置了旧图像。发生这种情况是因为滑翔正在获取旧缓存而不是更新缓存。
怎么解决这个问题。
Glide.clear(profilePic);
Glide.with(getApplicationContext())
.load(url)
.diskCacheStrategy(DiskCacheStrategy.ALL)
.skipMemoryCache(true)
.transform(new CircleTransform(MainProfile.this))
.into(profilePic);
Run Code Online (Sandbox Code Playgroud)
目前,图片已更改,但是当我单击后退按钮并返回此活动时,它会加载旧图像。像这样从缓存加载图像。
//setting up the profile pic
Glide.with(getApplicationContext())
.load(userProfilePicUrl)
.asBitmap()
.centerCrop()
.into(new BitmapImageViewTarget(profilePic) {
@Override
protected void setResource(Bitmap resource) {
RoundedBitmapDrawable circularBitmapDrawable =
RoundedBitmapDrawableFactory.create(MainProfile.this.getResources(), resource);
circularBitmapDrawable.setCircular(true);
profilePic.setImageDrawable(circularBitmapDrawable);
}
});
Run Code Online (Sandbox Code Playgroud)
问题是,当我回到此活动时,它显示旧图片而不是新图片。
约束集connect的官方文档说:https://developer.android.com/reference/android/support/constraint/ConstraintSet.html#connect (int,int,int,int,int)
void connect (int startID,
int startSide,
int endID,
int endSide,
int margin)
Run Code Online (Sandbox Code Playgroud)
限制的边际(保证金必须是积极的)
根据我的理解,如果我想从左到右连接两个视图,那么这个边距是左边距.
//从左到右
constraintset.connect(textView.id,ConstraintSet.LEFT,previousTextViewId,ConstraintSet.RIGHT,10)
Run Code Online (Sandbox Code Playgroud)
然后10是左边距.我对吗?我已经实现了这个概念,但即使没有右边或左边也没有设置边距.我错过了什么?
我想在我的应用程序中集成google plus登录,所以我需要SHA 1.
所以我试图通过命令行使用生成
keytool -exportcert -alias androiddebugkey -keystore~/.android/debug.keystore -list -v
但是当我输入密码时(我在签署apk时使用密码)它要求密钥存储密码.它说错了密码.
如何重置密码?