7. Kenapa Developer Memilih Android?
Android memanjakan penggunanya dengan fitur
yang sangat canggih dan tampilan yang indah.
Sistem Android dapat digunakan sebagai alat
multimedia seperti pemutar musik dan video. Ia juga
memiliki perangkat keras seperti accelerometer,
gyroscope dan sensor lainnya.
10. Pada tahun 2013, Android menjadi operation system (OS) terlaris pada tablet dan
smartphone. Dan tercatat pada bulan Maret 2019 store Android memiliki lebih dari 2.6
juta aplikasi.
(https://www.statista.com/statistics/266210/number-of-available-applications-in-the-google-play-store/)
16. https://teknojurnal.com/pilih-membuat-aplikasi-mobile-native-atau-hybrid/
Native Hybrid
Development Language Native Only Native and Web / Web Only
Device Access Complete Complete
Device Specific Features High Moderate
Speed Very Fast Medium
App Store Available Available
Approval Process Mandatory Low Overhead
Code Portability None High
Advanced Graphics High Moderate
UI / UX High Moderate
Access to Native APIs High Moderate
Development Cost Expensive Reasonable
Native vs Hybrid
26. Foundation - AppCompat
Before After
com.android.support:cardview-v7 androidx.cardview:cardview:1.0.0
com.android.support:appcompat-v7 androidx.appcompat:appcompat:1.0.0
com.android.support:recyclerview-v7 androidx.recyclerview:recyclerview:1.0.0
android.arch.persistence.room:common androidx.room:room-common:2.0.0-rc01
android.arch.core:common androidx.arch.core:core-common:2.0.0-rc01
android.arch.core:core androidx.arch.core:core:2.0.0-rc01
android.arch.paging:common androidx.paging:paging-common:2.0.0-rc01
.... ....
Degrade gracefully on older versions of Android
27. Foundation - Android KTX
Getting Started
dependencies {
implementation 'androidx.core:core-ktx:1.0.0'
}
Before
sharedPreferences.edit()
.putBoolean("key", value)
.apply()
After
sharedPreferences.edit {
putBoolean("key", value)
}
Write more concise, idiomatic Kotlin code
28. Kotlin
Concise
Drastically reduce the
amount of boilerplate code.
Safe
Avoid entire classes of errors
such as null pointer
exceptions.
Tool-friendly
Choose any Java IDE or
build from the command
line.
Interoperable
Leverage existing libraries
for the JVM, Android, and
the browser.
Kotlin/Native
reached beta
Coroutines
are now stable
Learning Kits
start easily
Multiplatform
code reuse
Kotlin 1.3 Released
29. Parts of
Anko Layouts: a fast and type-safe way to write dynamic Android
layouts.
Anko Commons: a lightweight library full of helpers for intents,
dialogs, logging and so on.
Anko SQLite: a query DSL and parser collection for Android SQLite.
Anko Coroutines: utilities based on the kotlinx.coroutines library.
31. Foundation - Benchmark
Quickly benchmark your Kotlin-based or Java-based code from within Android Studio
Add the library to your module’s build.gradle file:
project_root/module_dir/build.gradle
To disable debugging in the test manifest, update your <application> element to force-disable debugging
temporarily as follows:
project_root/module_dir/src/androidTest/AndroidManifest.xml
32. Foundation - Benchmark
Quickly benchmark your Kotlin-based or Java-based code from within Android Studio
To add your benchmark, add an instance of BenchmarkRule in a test file in the androidTest directory. For more
information on writing benchmarks, see Write a benchmark.
The following code snippet shows how to add a benchmark to a JUnit test:
33. Foundation - Multidex
Multidex Support prior to Android 5.0 (Api 21)
android {
defaultConfig {
...
minSdkVersion 15
targetSdkVersion 28
multiDexEnabled true
}
...
}
dependencies {
compile 'com.android.support:multidex:1.0.3'
}
Provide support for apps with multiple DEX files
Enable multidex for apps
with over 64K methods
34. Foundation - Security
Read and write encrypted files and shared preferences by following security best practices.
● Strong security that balances great encryption and good performance.
● Maximum security.
The Security library uses a 2-part system for key management:
● A keyset that contains one or more keys to encrypt a file or shared preferences data. The keyset itself is
stored inSharedPreferences.
● A master key that encrypts all keysets. This key is stored using the Android keystore system.
35. New Feature New Bugs . . .
https://gph.is/2jt9RvW
Foundation - Test
An Android testing framework for unit and runtime UI tests
47. Architecture - LiveData
Ensures your UI matches your data state
No memory leaks
No crashes due to stopped activities
No more manual lifecycle handling
Always up to date data
Proper configuration changes
Sharing resources
Notify views when underlying database changes
48. Architecture - LiveData
public class NameViewModel extends ViewModel {
// Create a LiveData with a String
private MutableLiveData<String> currentName;
public MutableLiveData<String> getCurrentName() {
if (currentName == null) {
currentName = new MutableLiveData<String>();
}
return currentName;
}
// Rest of the ViewModel...
}
Notify views when underlying database changes
49. public class NameActivity extends AppCompatActivity {
private NameViewModel model;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Other code to setup the activity...
// Get the ViewModel.
model = ViewModelProviders.of(this).get(NameViewModel.class);
// Create the observer which updates the UI.
final Observer<String> nameObserver = new Observer<String>() {
@Override
public void onChanged(@Nullable final String newName) {
// Update the UI, in this case, a TextView.
nameTextView.setText(newName);
}
};
// Observe the LiveData, passing in this activity as the LifecycleOwner and the observer.
model.getCurrentName().observe(this, nameObserver);
}
}
50. Architecture - Data Binding
Getting Started
android {
....
dataBinding {
enabled = true
}
}
Declaratively bind observable data to UI elements
Activity
TextView textView = findViewById(R.id.sample_text);
textView.setText(viewModel.getUserName());
Layout
<TextView
android:text="@{viewmodel.userName}" />
51. Architecture - Lifecycles
class MyLocationListener {
public MyLocationListener(Context context, Callback callback) {
// ...
}
void start() {
// connect to system location service
}
void stop() {
// disconnect from system location service
}
}
Manage your activity and fragment lifecycles
52. class MyActivity extends AppCompatActivity {
private MyLocationListener myLocationListener;
@Override
public void onCreate(...) {
myLocationListener = new MyLocationListener(this, (location) -> {
// update UI
});
}
@Override
public void onStart() {
super.onStart();
myLocationListener.start();
// manage other components that need to respond to the activity lifecycle
}
@Override
public void onStop() {
super.onStop();
myLocationListener.stop();
// manage other components that need to respond to the activity lifecycle
}
}
53. class MyActivity extends AppCompatActivity {
...
@Override
public void onStart() {
super.onStart();
Util.checkUserStatus(result -> {
// what if this callback is invoked AFTER activity is stopped?
if (result) {
myLocationListener.start();
}
});
}
...
}
55. Architecture - Lifecycles
public class MyObserver implements LifecycleObserver {
@OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
public void connectListener() {
...
}
@OnLifecycleEvent(Lifecycle.Event.ON_PAUSE)
public void disconnectListener() {
...
}
}
myLifecycleOwner.getLifecycle().addObserver(new MyObserver());
Manage your activity and fragment lifecycles
57. Architecture - Room
Entity
@Entity
public class User {
@PrimaryKey
public int uid;
@ColumnInfo(name = "first_name")
public String firstName;
@ColumnInfo(name = "last_name")
public String lastName;
}
58. Architecture - Room
Dao
@Dao
public interface UserDao {
@Query("SELECT * FROM user")
List<User> getAll();
@Query("SELECT * FROM user WHERE uid IN (:userIds)")
List<User> loadAllByIds(int[] userIds);
@Query("SELECT * FROM user WHERE first_name LIKE :first AND " + "last_name LIKE :last LIMIT 1")
User findByName(String first, String last);
@Insert
void insertAll(User... users);
@Delete
void delete(User user);
}
59. Architecture - Room
Database
@Database(entities = {User.class}, version = 1)
public abstract class AppDatabase extends RoomDatabase {
public abstract UserDao userDao();
}
Create Database
AppDatabase db = Room.databaseBuilder(getApplicationContext(),
AppDatabase.class, "database-name").build();
61. Architecture - Paging
Gradually load information on demand from your data source
PagedList
public class ConcertViewModel extends ViewModel {
private ConcertDao concertDao;
public final LiveData<PagedList<Concert>> concertList;
// Creates a PagedList object with 50 items per page.
public ConcertViewModel(ConcertDao concertDao) {
this.concertDao = concertDao;
concertList = new LivePagedListBuilder<>(
concertDao.concertsByDate(), 50).build();
}
}
62. Architecture - Paging
Gradually load information on demand from your data source
Data
@Dao
public interface ConcertDao {
// The Integer type parameter tells Room to use a
// PositionalDataSource object.
@Query("SELECT * FROM concerts ORDER BY date DESC")
DataSource.Factory<Integer, Concert> concertsByDate();
}
63. Architecture - Paging
Gradually load information on demand from your data source
UI
public class BookmarkPagedAdapter extends PagedListAdapter<DataModel, ViewHolder> {
...
}
64. Architecture - Navigation
● Handling Fragment transactions
● Handling Up and Back actions correctly by default
● Providing standardized resources for animations and transitions
● Treating deep linking as a first-class operation
● Including Navigation UI patterns, such as navigation drawers and bottom navigation, with minimal
additional work
● Providing type safety when passing information while navigating
● Visualizing and editing navigation graphs with Android Studio's Navigation Editor
Handle everything needed for in-app navigation
If you want to use the Navigation Architecture Component with Android Studio, you must use Android Studio 3.2 Canary 14 or higher.
66. Architecture - WorkManager
Key features:
● Backwards compatible up to API 14
○ Uses JobScheduler on devices with API 23+
○ Uses a combination of BroadcastReceiver + AlarmManager on devices with API 14-22
● Add work constraints like network availability or charging status
● Schedule asynchronous one-off or periodic tasks
● Monitor and manage scheduled tasks
● Chain tasks together
● Guarantees task execution, even if the app or device restarts
Manage your Android background jobs
67. Architecture - WorkManager
public class UploadWorker extends Worker {
public UploadWorker(@NonNull Context context, @NonNull WorkerParameters params) {
super(context, params);
}
@Override
public Result doWork() {
// Do the work here--in this case, upload the images.
uploadImages()
// Indicate whether the task finished successfully with the Result
return Result.success()
}
}
Manage your Android background jobs
68. Architecture - WorkManager
OneTimeWorkRequest
OneTimeWorkRequest uploadWorkRequest = new OneTimeWorkRequest.Builder(UploadWorker.class).build()
PeriodicWorkRequest
Constraints constraints = new Constraints.Builder().setRequiresCharging(true).build();
PeriodicWorkRequest saveRequest = new PeriodicWorkRequest.Builder(SaveImageFileWorker.class, 1,
TimeUnit.HOURS).setConstraints(constraints).build();
WorkManager.getInstance().enqueue(saveRequest);
Manage your Android background jobs
71. Behavior - CameraX
Easily add camera capabilities to your apps
● Ease of use
○ Preview: get an image on the display
○ Image analysis: access a buffer seamlessly for use in your algorithms, such as to pass into MLKit
○ Image capture: save high-quality images
● Consistency across devices
● New camera experiences
72. Behavior - Download Manager
Schedule and manage large downloads
class DownloadManager.Query
This class may be used to filter download manager queries.
class DownloadManager.Request
This class contains all the information necessary to request a new download.
73. Behavior - Media & Playback
Backwards compatible APIs for media playback and routing (including Google Cast)
A multimedia application that plays audio or video usually has two parts:
● A player that takes digital media in and renders it as video and/or audio.
● A UI with transport controls to run the player and optionally display the player's state.
74. Behavior - Media & Playback
Backwards compatible APIs for media playback and routing (including Google Cast)
76. Behavior - Notifications
Provides a backwards-compatible notification API with support for Wear and Auto
Status bar and notification drawer Heads-up notification
77. Behavior - Notifications
Provides a backwards-compatible notification API with support for Wear and Auto
Lock screen App icon badge Wear OS devices
78. Behavior - Notifications
Provides a backwards-compatible notification API with support for Wear and Auto
1. Small icon: This is required and set with setSmallIcon().
2. App name: This is provided by the system.
3. Time stamp: This is provided by the system but you can override with setWhen() or hide it with
setShowWhen(false).
4. Large icon: This is optional (usually used only for contact photos; do not use it for your app icon) and set
withsetLargeIcon().
5. Title: This is optional and set with setContentTitle().
6. Text: This is optional and set with setContentText().
87. Behavior - Slices
Example Use Case
adb install -r -t slice-viewer.apk
Enter slice-<your slice URI> in the URL field
Example: slice-content://com.example.your.sliceuri
94. UI - Layout
Lay out widgets using different algorithms
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello, I am a TextView" />
<Button android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello, I am a Button" />
</LinearLayout>
107. Future of Firebase
Make smart,
data-driver decisions
Free to start. scale
with ease
Forget abaout
infrastructure
Get free support
Work across platform
126. Google releases source code for Google I/O 2019 for Android
https://android-developers.googleblog.com/2019/08/google-releases-source-code-for-google.html
127. Android Q out of the box
Gesture navigation
Gesture navigation navigating back
and to the home screen
128. Android Q out of the box
Dark Theme
Schedule UI in dark theme
142. Sertifikat / Sertifikasi
Kebutuhan
Industri IT
Talenta
Digital
Lulusan universitas
Lulusan SMK
Otodidak
Kursus
Profesional
dll (re-skilling)
Training /
Matrikulasi
Sertifikasi