Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
102 views
in Technique[技术] by (71.8m points)

java 8 - CompletableFuture in the Android Support Library?

So I was migrating an Android Studio project to Java 8, Android API level 24 and the Jack toolchain today to check out the new features, especially lambdas and CompletableFuture.

Unfortunately, CompletableFuture seems to be available only from API level 24 on (my minimum API level for that project being 16).

Do you know of any plans on bringing CompletableFuture to the Android support library? It looks like a nice solution for the Promises pattern.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The streamsupport project provides a backport of CompletableFuture in its streamsupport-cfuture component which can be used for Android development, supported on all devices.

Either use

dependencies {
    compile 'net.sourceforge.streamsupport:streamsupport-cfuture:1.7.3'
}

or the more modern android-retrofuture fork for Android Studio >= 3.x

dependencies {
    compile 'net.sourceforge.streamsupport:android-retrofuture:1.7.3'
}

if you can use Android Studio 3.x and above.

The new Java 12 exception handling methods for CompletableFuture JDK-8211010 have been integrated in release 1.7.0


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...