-
Notifications
You must be signed in to change notification settings - Fork 0
Kotlin and Android
Android now officially supports the object-oriented programming language Kotlin.
A plugin for Kotlin is embedded in Android Studio (starting from version 3.0).
See the article from the official Android documentation: https://developer.android.com/kotlin/index.html
Kotlin is entirely supported by Android Studio 3.0, so it 's relatively simple to create new projects containing Kotlin files, add Kotlin files to an existing project, or convert Java code into Kotlin (see the “Get Started with Kotlin” section of the official documentation for more details).
Kotlin enables full interoperability with Java language. This is why the operating principles and the integration methods documented in your “Getting started” section remain unchanged.
Android Studio 3.0 offers different conversion tools. It 's therefore possible to convert a Java file (with a .java extension) into a Kotlin file (with a .kt extension) by opening the file, then by selecting the menu Code > Convert Java File to Kotlin File.You may also create a new Kotlin file (menu File > New > Kotlin File/Class) and then insert Java code. In this case, a dialog box will open, asking if you wish to automatically convert the code. The examples of Android tagging defined in Java can therefore be inserted as is, leading to automatic conversion.
Tagging a Gesture with Debugger in Java
package com.atinternet;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import com.atinternet.tracker.ATInternet;
import com.atinternet.tracker.Debugger;
import com.atinternet.tracker.Tracker;
public class MainActivity extends AppCompatActivity {
Tracker tracker;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tracker = ATInternet.getInstance().getDefaultTracker();
findViewById(R.id.sendHit).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
tracker.Gestures().add("TouchTest").sendTouch();
}
});
Debugger.create(this, tracker);
}
}Equivalent tagging in Kotlin
package com.atinternet
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.widget.Button
import com.atinternet.tracker.ATInternet
import com.atinternet.tracker.Debugger
import com.atinternet.tracker.Tracker
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val tracker: Tracker = ATInternet.getInstance().getDefaultTracker()
val button = findViewById<Button>(R.id.sendHit)
button.setOnClickListener(object : View.OnClickListener {
override fun onClick(v: View?) {
tracker.Gestures().add("TouchTest").sendTouch()
}
})
Debugger.create(this, tracker)
}
}Last update: 03/01/2018
-
Data API
- Data flow
- Advice optimizations data flow
- Error codes data flow
- Faq data flow
- General information data flow
- Technical information data flow
- Reporting API v3
- Getting started
- Methods
- Parameters
- Technical information
- REST API
- Campaigns
- Custom variables
- Getting started rest
- Methods rest
- Response structure parameters rest
- Fixed periods
- Parameters compatibility
- Relative periods
- Structure of the response
- “code” parameter
- “columns” parameter
- “evo” parameter
- “filter” parameter
- “include” parameter
- “lng” parameter
- “max-results” parameter
- “page-num” parameter
- “period” parameter
- “period” parameter: “H” v. “He” & “MN” v. “MNe”
- “retention” parameter
- “segmentdesc” parameter
- “segment” parameter
- “sep” parameter
- “sort” parameter
- “space” parameter
- Technical specifications rest
- Data flow
-
Data collection
- Android
- Advanced features
- Campaigns
- Changelog
- Content
- Ecommerce
- Getting started
- Users
- Apple
- Advanced features
- Campaigns
- Changelog
- Content
- Ecommerce
- Getting started
- Users
- General
- Cddc renew staging process
- Changelog
- Craft your hit
- Encoded parameters
- Server side cookie management
- Supported taggings
- Tagging deletion
- Utilisation of dispatch sdks
- JavaScript
- Advanced features
- Campaigns
- Changelog
- Content
- Ecommerce
- Getting started
- Partners javascript
- Users
- Piano Analytics
- Event tagging piano analytics
- Getting started piano analytics
- Piano analytics tagging
- Feeding piano analytics with as2 tagging
- Tagging custom properties sdk
- Android