kotlin

【14】 Kotlin 导出可执行文件

▼魔方 西西 提交于 2020-08-06 23:30:54
最后导出文件格式为 Chapter1.bat 效果展示 下面就是具体步骤了 修改此文件 新增插件 id 'application' 和要打包的程序名称 mainClassName="com.yzdzy.kotlin.calc.CalcKt" 注意这个CalcKt K大写。t小写 没有空格 这里没有点 对应文件 弄好了以后同步下文件 第一次同步较慢 之后双击下这个脚本 过一会 就执行成功了 然后可以在目录文件 H:\project\kotlin\build\install\Chapter1\bin 也就是对应项目中的 \build\install\Chapter1\bin 文件看到编译的文件 第一个文件对应linux下面的文件 要改权限后执行 chmod 755 bin/Chapter3 然后直接执行 bin/Chapter3 运行程序 windwos 直接双击就好、 双击打不开,或者打开立马闪退 请用命令行 打开 就可以看到 具体错误 来源: oschina 链接: https://my.oschina.net/u/4370838/blog/4314479

Android面试经验一:

让人想犯罪 __ 提交于 2020-08-06 20:33:22
一、第一轮我是在前程无忧投的简历,然后hr打电话给我,进行首轮电话面试 首先是他介绍公司的情况,和了解我一些的基本情况,比如,之前的实习情况,做过哪些项目,自己负责哪部分,以及那些项目发布了没。其实,就是简单大概的了解我的基本情况和技术。 第一轮电话面试通过了,约我去公司进行二轮笔试加面试 二、第二轮,我很信心满满带着简历,身份证、学历学位证的复印件(我面试的是国企,要求带上这些)就去公司面试了 首先就是填表,就是面试表(入职表,去面试每个公司都要你填的) 填完表格,前台的小姐姐开开心心的拿笔试题给我做了,我看了一下,两道单选,三道多选,六道大题,一道附加题,满分一百分,总共一个小时的时间 记得不是很清楚了 (1)HashMap的原理,关键字key不能重复 (2)以下哪些情况会出现ANR错误:activity 按键或触摸事件在5s无响应,broadcastreceiver 10s内无法做出回应,service20s内无法处理完成;都会导致应用无响应。(在主线程做耗时操作都会导致ANR) (3)handle的消息机制:messege,messegequeue,looper,handle (4)wait和sleep的区别:sleep来自Thread类,wait来自Object类,调用sleep()方法的过程中,线程不会释放对象锁。而 调用 wait 方法线程会释放对象锁

ViewModelProviders is not working inside my Fragment

◇◆丶佛笑我妖孽 提交于 2020-08-06 12:47:07
问题 This is what I'm trying to do. Set an ArrayList of object inside a Fragment Get that array from an observer within the FragmentActivity container (the activity that hosts all the fragments) So, What I have done is the following. First I created the SharedViewModel from where I will set and get the data from : SharedViewModel.kt class SharedViewModel: ViewModel() { var personArrayObj:MutableLiveData<ArrayList<Person>> = MutableLiveData() fun setPersonArray(personArray:ArrayList<Person>){

一头不安分的蜗牛/classic-bluetooth

筅森魡賤 提交于 2020-08-06 10:42:21
Android传统(经典)蓝牙框架 最新版本 功能 支持多设备同时连接 支持观察者监听或回调方式。注意:观察者监听和回调只能取其一! 支持使用注解@RunOn控制回调线程 支持设置回调或观察者的方法默认执行线程 配置 因为使用了jdk8的一些特性,需要在module的build.gradle里添加如下配置: //纯java的项目 android { compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } } //有kotlin的项目还需要在project的build.gradle里添加 allprojects { tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all { sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 kotlinOptions { jvmTarget = '1.8' apiVersion = '1.3' languageVersion = '1.3' } } } module的build

Kotlin could not find the required JDK tools in the Java installation

旧巷老猫 提交于 2020-08-06 07:58:50
问题 When running ./gradlew clean build I get following message: > Task :compileKotlin FAILED FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':compileKotlin'. > Kotlin could not find the required JDK tools in the Java installation '/usr/lib/jvm/java-8-openjdk-amd64/jre' used by Gradle. Make sure Gradle is running on a JDK, not JRE. I have JDK, JAVA_HOME is set properly, so is update-alternatives . # java -version openjdk version "1.8.0_191" OpenJDK Runtime

How to convert imageview to bytearray in kotlin

橙三吉。 提交于 2020-08-06 07:19:11
问题 How to convert imageview to bytearray kotlin android In java Bitmap bitmap = ((BitmapDrawable)image.getDrawable()).getBitmap(); ByteArrayOutputStream stream=new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.PNG, 90, stream); byte[] image=stream.toByteArray(); return image 回答1: Here it is use java to kotlin converter. val bitmap = (image.getDrawable() as BitmapDrawable).getBitmap() val stream = ByteArrayOutputStream() bitmap.compress(Bitmap.CompressFormat.PNG, 90, stream) val

Deleted API data not reflecting in android app re-posted

╄→尐↘猪︶ㄣ 提交于 2020-08-06 07:09:09
问题 I am very experienced developer but very new to mobile app dev. I am using Kotlin, Android Studio & Amplify with a DynamoDB APi. When I add data via the AWS website it shows on the device. When I delete it doesn't reflect unless I uninstall/reinstall. I assume this is some sort of basic cache management/sync issue but like I said I am very new. I have tried removing context.cacheDir but the deleted record persists. Any help would be appreciated. Here is some more info. As I say I am

Deleted API data not reflecting in android app re-posted

三世轮回 提交于 2020-08-06 07:07:10
问题 I am very experienced developer but very new to mobile app dev. I am using Kotlin, Android Studio & Amplify with a DynamoDB APi. When I add data via the AWS website it shows on the device. When I delete it doesn't reflect unless I uninstall/reinstall. I assume this is some sort of basic cache management/sync issue but like I said I am very new. I have tried removing context.cacheDir but the deleted record persists. Any help would be appreciated. Here is some more info. As I say I am

How to hide visibility of Kotlin internal class in Java from different modules?

拜拜、爱过 提交于 2020-08-06 05:53:07
问题 I was working on the Android library which I'm developing in Kotlin. I kept access modifier of some classes as internal . Internal classes are only visible in that library module in Kotlin. If I implement that library in the app then it's not visible at all. But the problem comes when accessing that library from Java code. If I create .java file and type name of that internal class of library then IDE is suggesting name and it's resolved and compiled without any error. For e.g. Library Module