Android Question Convert Lambda expression

kkkpe

Member
Licensed User
Inserting the code between #if java end if b4a returns error:
lambda expressions are not supported.
how can i replace the code?

B4X:
downloadDialog.setPositiveButton(yes, (dialogInterface, i) -> {
            Uri uri = Uri.parse("market://details?id=sv.ziwi");
            Intent intent = new Intent(Intent.ACTION_VIEW, uri);
            try {
                if (fragment == null) {
                    activity.startActivity(intent);
                } else {
                    fragment.startActivity(intent);
                }
            } catch (ActivityNotFoundException anfe) {
                // Hmm, market is not installed
                Log.w(TAG, "Google play non installata; impossibile installare Ziwi!");
            }
        });
 

kkkpe

Member
Licensed User
Yes, you are right, but the code is inside a class that I will have to call with JavaObject. So I need the equivalent in JAVA and not B4A.
 
Upvote 0

Erel

Administrator
Staff member
Licensed User
I saw the class. You already made 10 threads about it. The correct thing to do is to convert it to B4A. There is nothing special in that class.
If you do want to waste some time then compile it into a jar and run desugar to remove the Java 8 features.

Another option is to learn Java and understand how to convert lambdas. It is quite simple.
 
Upvote 0

kkkpe

Member
Licensed User
I solved it using Eclipse. I set the compiler to version 1.7, I linked to the android.jar project from add external jar, after which in the class positioned the cursor on lambda and pressing the yasto ctrl 1 the popup for the conversion appears
 
Upvote 0
Top