Alarm Manager Example
I want to implement a schedule function in my project. So I Googled for an Alarm manager program but I can`t find any examples. Can anyone help me with a basic alarm manager program? 10 Answers 10
I want to implement a schedule function in my project. So I Googled for an Alarm manager program but I can`t find any examples. Can anyone help me with a basic alarm manager program? 10 Answers 10
I have recently read about the const keyword, and I’m so confused! I can’t find any difference between const and the val keyword, I mean we can use both of them to make an immutable variable, is there anything else that I’m missing? 8 Answers 8
In Kotlin, if you don’t want to initialize a class property inside the constructor or in the top of the class body, you have basically these two options (from the language reference): Lazy Initialization lazy() is a function that takes a lambda and returns an instance of Lazy<T> which can serve as a delegate for … Read more
I have a Kotlin source file, but I want to translate it to Java. How can I convert Kotlin to Java source? 8 s 8 As @Vadzim said, in IntelliJ or Android Studio, you just have to do the following to get java code from kotlin: Menu > Tools > Kotlin > Show Kotlin Bytecode … Read more
I want to launch an installed package from my Android application. I assume that it is possible using intents, but I didn’t find a way of doing it. Is there a link, where to find the information? 19 s 19 If you don’t know the main activity, then the package name can be used to … Read more
I wrote an Android application. Now, I want to make the device vibrate when a certain action occurs. How can I do this? 13 s 13 Try: import android.os.Vibrator; … Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); // Vibrate for 500 milliseconds if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { v.vibrate(VibrationEffect.createOneShot(500, VibrationEffect.DEFAULT_AMPLITUDE)); } else { //deprecated in API 26 v.vibrate(500); … Read more
What is the equivalent of this expression in Kotlin? a ? b : c This is not valid code in Kotlin. 33 s 33
I wonder if there is a way to check if a lateinit variable has been initialized. For example: class Foo() { private lateinit var myFile: File fun bar(path: String?) { path?.let { myFile = File(it) } } fun bar2() { myFile.whateverMethod() // May crash since I don’t know whether myFile has been initialized } } … Read more
When trying to run the Example CorDapp (GitHub CorDapp) via IntelliJ, I receive the following error: Cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6 How can I modify the IntelliJ settings so that all the bytecode is built with the same JVM target? 34 s … Read more
I am developing an application, and everytime I run it, I get the message: Unfortunately, MyApp has stopped. What can I do to solve this? About this question – obviously inspired by What is a stack trace, and how can I use it to debug my application errors?, there are lots of questions stating that … Read more