Skip to main content

All Questions

Tagged with
0 votes
1 answer
2k views

onBackPressed is deprecated - webView in android app

I have an app where the main activity (which extends ComponentActivity) is pretty much just a webView. I have overriden onBackPressed, shown below. @Override public void onBackPressed(){ if(this....
yeswhatdoyouwant's user avatar
0 votes
2 answers
3k views

How to unit test a callback in parameter - Kotlin

I have a Client class (written in Kotlin in an Android app) that implements an interface ReadyCallback (written in Java in a library of the app, the app is dependent on this library). In Client I have ...
peanutnut's user avatar
1 vote
0 answers
184 views

Java callback in kotlin is never called

I'm trying to connect to Azure DPS and Azure IoT hub using this example: https://github.com/Azure/azure-iot-sdk-java I'm developing an Android app using Kotlin. I copied the code from the link and and ...
Finitely Failed's user avatar
1 vote
1 answer
1k views

How to pass callback function from Java to Kotlin class

I have a Kotlin class as follows (this is a sample for ease, hence it doesn't 'do' anything useful) class MyKotlinClass (private val handleSomeCallBack: (ByteArray) -> Unit) { private val ...
greysqrl's user avatar
  • 977
0 votes
0 answers
86 views

How to wait function call inside a function in Java, is it possible?

I'm working with a TCP server. For login action, I have a sendLogin and a receiveLogin functions, but I would like to have only one function to call like this. fun login(login: String, pwd : String){ ...
Sercurio's user avatar
0 votes
2 answers
91 views

How do I call this constuctor in java?

I have a library (.aar) file which i imported in java. The class is LSPatch which has a constructor. public final class LSPatch public constructor(options: org.json.JSONObject, onDiscovery: (org....
Sayan Sen's user avatar
  • 1,774
10 votes
2 answers
4k views

Kotlin result type in java

Kotlin introduced the new type: Result. I use it as a completion handler of several functions like this: fun myFunction(completion: (Result<Boolean>) -> Unit) Unfortunately I cannot use it ...
DEADBEEF's user avatar
  • 2,150
0 votes
1 answer
2k views

How to read with java a callback from a kotlin class (Android)

This is my kotlin class: class example { var a = 0 fun add(b: Int, callback: (Int) -> Unit){ a += b callback(a) } } How do I use this function in a java code?
Gius's user avatar
  • 89
0 votes
2 answers
214 views

Java/Kotlin callback syntax - do I really need 2 callback definitions after conversion to Kotlin?

I have a problem that has been challenging me for a few days with no resolution (more directly, no resolution I feel is correct). The issue is around callbacks, Java implementation vs Kotlin ...
Kenneth Argo's user avatar
  • 1,757
0 votes
2 answers
1k views

How convert a callback inside retrofit callback response from java to Kotlin

I am a newcomer to Kotlin and I have a simple question : I convert all my project from java to kotlin and I succeed to correct all bugs with the documentation. But I did not succeed to convert a call ...
ShikaZero's user avatar
2 votes
3 answers
6k views

Callback get response Sync kotlin

I'm tring to get the response of a callback in sync mode because I the value of the response is needed to all application to work, without this value ( token ) I can't continue to use the application. ...
Alessandro Candon's user avatar
1 vote
1 answer
2k views

Android Kotlin cancel callback

still very new to Kotlin, i'm trying not to call my callback if my activity is null. Let me explain, i have my DataManager that perform async work on some data: fun performWork(callback: ((param1: ...
user2434385's user avatar
10 votes
2 answers
18k views

Callback with parameters with Kotlin

I just started Kotlin so please be nice :) I have a class that is responsible for fetching some data and notify the main activity that its need to update its UI. So i have made a function in my ...
user2434385's user avatar