Posts

Showing posts with the label Kotlin

Stop using third party packages that has many dependencies that the author didn't have a check before they use

33. "remove every backend project that uses node third party packages, they might has backdoor that could use your VPS as their VPS to act like a general web client for hackers"   it is even worse if you use npm in root VPS, because the npm will always use new version of a package or sub_package, how can you make sure your 3000 dependencies will not have a virus that could use your VPS root permission to do bad things?   it is the same for other package manager, for example, python pip. or golang package, java package, rust package, flutter package. in chinese, people usally call those machine that has those software running 'rou ji'. """ 利用 package manager 自动更新新版本的特性,做远控 轻而易举 就算不更新,利用现有的package,二进制文件或者脚本 一个post发到黑客服务器,它就知道你的电脑能不能被控制 对于root设备,被控制就是被完全控制,对于普通设备,就是被当成hacker web 客户端,可以被拿来在网上发垃圾信息、垃圾账号注册 到时候你的ip就会被当成坏ip被服务器墙掉 """

Kotlin: How to override a class, then pass it to a function as an anonymous function argument

```kotlin val commonDestureDetector = GestureDetector( this, object : GestureDetector.OnGestureListener { // 1. 用户轻触触摸屏 override fun onDown (e: MotionEvent): Boolean { Log.i( "MyGesture" , "onDown" ) return false } // 2. 用户轻触触摸屏,尚未松开或拖动 // 与onDown()的区别:无松开 / 拖动 // 即:当用户点击的时,onDown()就会执行,在按下的瞬间没有松开 / 拖动时onShowPress就会执行 override fun onShowPress (e: MotionEvent) { Log.i( "MyGesture" , "onShowPress" ) } // 3. 用户长按触摸屏 override fun onLongPress (e: MotionEvent) { Log.i( "MyGesture" , "onLongPress" ) } // 4. 用户轻击屏幕后抬起 override fun onSingleTapUp (e: MotionEvent): Boolean { Log.i( "MyGesture" , "onSingleTapUp" ) return true } // 5. 用户按下触摸屏 & 拖动 override fun onScroll ( e1: MotionEvent , e2: MotionEvent , distanceX: Float , distanceY: Float ): Boolean { Log.i( "MyGesture...

How to mix kotlin code and java code

First I must say, I misunderstood kotlin before. It’s a good language to simplify android development if you know java already. Here is what the official says: Kotlin is 100% interoperable with the Java programming language, so you can have as little or as much of Kotlin in your project as you want. How to use java code in kotlin You just have to create a java class besides your .kt file, then you are ready to go. Just import that file by `import ** ` , then instantiate it as you would do with any class. Then it’s done. Quite simple. The source and the author https://kotlinlang.org/docs/tutorials/mixing-java-kotlin-intellij.html https://yingshaoxo.blogspot.com ​

Golang for Android Development

It’s good to write Golang for producing binary file, then use it everywhere Cython could do the same thing by convert python to c, then c to binary. First, you should write a program at ~/go/github/yingshaoxo/hi/main.go package greeting func SayHi() string { return "Hi!" } Capitalize the function name, so golang would treat that function as public. Then, compile it to a binary file go get golang.org/x/mobile/cmd/gomobile gomobile init gomobile bind -target=android If it ask for NDK, install it and make sure the Environmental-Variable was set right. #add the following to your `~/.bashrc`: export ANDROID_HOME= $HOME /Android/Sdk export ANDROID_NDK_HOME= $ANDROID_HOME /ndk/ 21.3 . 6528147 export PATH= $PATH : $GOPATH /bin: $ANDROID_HOME /platform-tools/ If everything was right, you’ll get two files: greeting.aar and greeting-sources.jar Let’s import it to Android Studio Project Let’s assume you have a project which was named A...