Showing posts with label API. Show all posts
Showing posts with label API. Show all posts

Tuesday, October 23, 2018

Introducing Android Ktx: Fifty-Fifty Sweeter Kotlin Evolution For Android

Posted yesteryear Jake Wharton (@JakeWharton), Florina Muntenescu (@FMuntenescu) & James Lau (@jmslau)

Today, nosotros are announcing the preview of Android KTX - a laid of extensions designed to brand writing Kotlin code for Android to a greater extent than concise, idiomatic, as well as pleasant. Android KTX provides a overnice API layer on top of both Android framework as well as Support Library to brand writing your Kotlin code to a greater extent than natural.

The portion of Android KTX that covers the Android framework is directly available inward our GitHub repo. We invite y'all to endeavor it out to give us your feedback as well as contributions. The other parts of Android KTX that encompass the Android Support Library volition last available inward upcoming Support Library releases.

Let's accept a aspect at roughly examples of how Android KTX tin deal y'all write to a greater extent than natural as well as concise Kotlin code.

Code Samples Using Android KTX

String to Uri

Let's start amongst this uncomplicated example. Normally, you'd telephone phone Uri.parse(uriString). Android KTX adds an extension portion to the String degree that allows y'all to convert strings to URIs to a greater extent than naturally.

Kotlin
Kotlin amongst Android KTX
val uri = Uri.parse(myUriString)
val uri = myUriString.toUri()

Edit SharedPreferences

Editing SharedPreferences is a really mutual purpose case. The code using Android KTX is slightly shorter as well as to a greater extent than natural to read as well as write.

Kotlin
Kotlin amongst Android KTX
sharedPreferences.edit()            .putBoolean(key, value)            .apply() 
sharedPreferences.edit {      putBoolean(key, value)  }    

Translating path difference

In the code below, nosotros interpret the departure betwixt ii paths yesteryear 100px.

Kotlin
Kotlin amongst Android KTX
val pathDifference = Path(myPath1).apply {    op(myPath2, Path.Op.DIFFERENCE) }  val myPaint = Paint()  canvas.apply {    val checkpoint = save()    translate(0F, 100F)    drawPath(pathDifference, myPaint)    restoreToCount(checkpoint) }   
val pathDifference = myPath1 - myPath2  canvas.withTranslation(y = 100F) {    drawPath(pathDifference, myPaint) }  

Action on View onPreDraw

This instance triggers an activeness amongst a View's onPreDraw callback. Without Android KTX, in that location is quite a flake of code y'all need to write.

Kotlin
view.viewTreeObserver.addOnPreDrawListener(        object : ViewTreeObserver.OnPreDrawListener {            override fun onPreDraw(): Boolean {                viewTreeObserver.removeOnPreDrawListener(this)                actionToBeTriggered()                return true            }        })
Kotlin amongst Android KTX
view.doOnPreDraw { actionToBeTriggered() }

There are many to a greater extent than places where Android KTX tin simplify your code. You tin read the full API reference documentation on GitHub.

Getting Started

To start using Android KTX inward your Android Kotlin projects, add together the next to your app module's build.gradle file:

repositories {     google() }  dependencies {     // Android KTX for framework API     implementation 'androidx.core:core-ktx:0.1'     ... } 

Then, later on y'all sync your project, the extensions seem automatically inward the IDE's auto-complete list. Selecting an extension automatically adds the necessary import contention to your file.

Beware that the APIs are probable to alter during the preview period. If y'all determine to purpose it inward your projects, y'all should aspect breaking changes earlier nosotros accomplish the stable version.

androidx: Hello World!

You may discovery that Android KTX uses bundle names that laid out amongst androidx. This is a novel bundle refer prefix that nosotros volition last using inward time to come versions of Android Support Library. We promise the partition betwixt android.* as well as androidx.* makes it to a greater extent than obvious which APIs are bundled amongst the platform, as well as which are static libraries for app developers that run into dissimilar versions of Android.

What's Next?

Today's preview launch is exclusively the beginning. Over the side yesteryear side few months, nosotros volition iterate on the API every bit nosotros contain your feedback as well as contributions. When the API has stabilized as well as nosotros tin commit to API compatibility, nosotros programme to unloose Android KTX every bit portion of the Android Support Library.

We aspect frontward to edifice Android KTX together amongst you. Happy Kotlin-ing!

Monday, October 22, 2018

A Improve Trend To Rails Your Promotions On Google Play Billing

A Improve Trend To Rails Your Promotions On Google Play Billing

Posted past times Neto Marin, Developer Advocate

Promotions tin flame live on a valuable tool to growth user 24-hour interval of the month or attract novel users past times offering content or features to a express issue of users gratis of charge.

We are happy to part an improvement inwards the Google Play Developer API that makes it easier to runway your promotions from your ain backend. Starting today, the API for Purchases.products volition provide "Promo" every bit a novel value for the champaign purchaseType when the user redeems a promo code. Now, the possible values are:

  • 0. Test (test purchases)
  • 1. Promo (Promo code redemption purchase)

For purchases made using the measure in-app billing flow, the champaign volition perish on to non live on ready inwards the API response.

Please note: This acre is exclusively returned past times the Purchases.products API. For subscriptions you lot may piece of job Free Trials to offering gratis of accuse subscription periods.

For to a greater extent than details almost how to create in addition to redeem promo codes, banking concern gibe the In-app Promotions documentation. For to a greater extent than details almost the server-side API, banking concern gibe the Google Play Developer API documentation.

Wednesday, October 10, 2018

Automating Your App Releases Amongst Google Play

Posted yesteryear Nicholas Lativy, Software Engineer

At Google I/O nosotros shared how Google's ain apps brand role of Google Play for successful launches in addition to updates in addition to introduced the novel Google Play Developer Publishing API Version 3.

The Publishing API enables yous to integrate publishing operations into your existing liberate procedure or automated workflows yesteryear providing the mightiness to upload APKs in addition to curlicue out releases. Here's an overview of approximately of the improvements yous tin right away induce got payoff of inward Version iii of the API.

Releases inward the API

The Publishing API right away uses the liberate model yous are familiar alongside from the Play Console.

{   "track": "production",   "releases": [     {       "name": "Release One",        "versionCodes": ["100"],       "status": "completed"     }   ] }

This gives yous total command over releases via the API allowing a issue of operations which were previously available exclusively inward the Play Console. For example, yous tin right away command the advert of releases created via the API, in addition to nosotros induce got right away relaxed the constraints on what tin survive rolled out via the API to fit the Play Console.

Additional testing tracks

The API right away supports releasing to whatever of the testing tracks yous induce got configured for your application every bit good every bit the production track. This makes it possible to configure your continuous integration organization to force a novel construct to your internal seek rail every bit presently every bit it's laid upward for QA.

Staged rollout

Staged rollouts are the recommended agency to deploy novel versions of your app. They allow yous to brand your novel liberate available to a modest percent of users in addition to gradually growth this percent every bit your confidence inward the liberate grows.

Staged rollouts are right away represented straight inward the API every bit inProgress releases.

{   "track": "production",   "releases": [     {       "versionCodes": ["100"],       "status": "completed"     },     {       "versionCodes": ["200"],       "status": "inProgress",       "userFraction": 0.1     }   ] }

You tin right away stop a staged rollout via the API yesteryear changing its condition to halted. This makes it possible to automatically respond to whatever problems yous discovery spell performing a rollout. If it turns out to survive a imitation alarm, the API right away also allows yous to resume a halted liberate yesteryear changing its condition dorsum to inProgress.

Release notes

Release notes are a useful agency to communicate to users novel features yous induce got added inward a release. In V3 nosotros induce got simplified how these are specified via the API yesteryear adding the releaseNotes acre to release.

{   "track": "production",   "releases": [     {       "versionCodes": ["100"],       "status": "completed",       "releaseNotes": [         {           "language": "en-US",           "text": "Now it's easier to specify liberate notes."         },         {            "language": "it-IT",            "text": "Ora è più semplice specificare le banker's complaint sulla versione."         }     }   ] }

Draft releases

We know that spell many developers are comfortable deploying seek builds automatically, they similar using the Play Console when rolling out to production.

So, inward the V3 API nosotros induce got added the mightiness to create in addition to create out Draft Releases.

{   "track": "production",   "releases": [     {       "name": "Big Launch",       "versionCodes": ["200"],       "status": "draft"     }   ] }

This allows yous to upload APKs or App Bundles in addition to create a draft liberate from your continuous integration system, in addition to thus induce got your production director log in, cheque that everything looks good, in addition to striking "Confirm in addition to Rollout".

We promise yous discovery these features useful in addition to induce got payoff of them for successful launches in addition to updates alongside Google Play. If you're interested inward approximately of the other dandy tools for distributing your apps, cheque out the I/O sessions which induce got right away been posted to the Android Developers YouTube Channel.

How useful did yous discovery this blogpost?

★ ★ ★ ★ ★