Android App Module - Activity Result Contracts

Overview

Activity Result Contract with async & await (Asynchronous) - Android App Module

App Features Activity Result Contract :

  • ActivityResultContracts
    • Permissions
      • Request Permission
      • Multiple Request Permissions
    • Image
      • Pick Image from Camera
      • Select Image from Gallery
      • CropImageActivity with Pick Image or Select Image
    • Document
      • Open Single Document
      • Open Multiple Documents
  • CoroutineScope
    • GlobalScope
    • async{}
    • await()

Design UI App Activity Result Contract

Preview UI FirebaseAuth-Google

Name Page Preview UI Preview UI
Home none
Permissions
Crop Image
Open Single Document
Open Multiple Documents

Dependencies used

    // Kotlin Coroutine
    implementation 'androidx.activity:activity-ktx:1.4.0'
    // Image Cropper
    api 'com.theartofdev.edmodo:android-image-cropper:2.8.0'

Integration Step Used Binding in Kotlin

  1. Add viewBinding true build.gralde (Module)
android {
   ...
   buildFeatures {
      viewBinding true
   }
}
  1. Activity Kotlin Class
class MainActivity : AppCompatActivity() {

    /** Add this */
    private lateinit var binding: ActivityMainBinding

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        /** Add this */
        binding = ActivityMainBinding.inflate(layoutInflater)

        /** Change this */
        setContentView(binding.root)

        /** Without findViewById */
        binding.textView.text = "Bye bye findViewById"
    }
}
  1. Activity Java Class
public class MainActivity extends AppCompatActivity {

    /** Add this */
    private ActivityMainBinding binding;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        /** Add this */
        binding = ActivityMainBinding.inflate(getLayoutInflater());

        /** Change this */
        setContentView(binding.getRoot());

        /** Without findViewById */
        binding.textView.setText("Bye bye findViewById");
    }
}

binding in kotlin can be used directly without initializing findViewById on widgets in layout xml

You might also like...
Multi module architecture Android template project using MVVM, Dagger-Hilt, and Navigation Components
Multi module architecture Android template project using MVVM, Dagger-Hilt, and Navigation Components

ModularAppTemplate An Android template project following a multi module approach with clean architecture. It has been built following Clean Architectu

Example Multi module architecture Android project using MVVM, Dynamic Features, Dagger-Hilt, Coroutines and Navigation Components
Example Multi module architecture Android project using MVVM, Dynamic Features, Dagger-Hilt, Coroutines and Navigation Components

ModularDynamicFeatureHilt An Android template project following a multi module approach with clean architecture. It has been built following Clean Arc

A set of highly-opinionated, batteries-included gradle plugins to get you started building delicious multi-module Kotlin projects

Sourdough Gradle What is Sourdough Gradle? Sourdough is a set of highly opinionated gradle plugins that aim to act as the starter for your Kotlin proj

🚧 General-Purpose Module System for Kotlin.

🚧 Modules: General-Purpose Module System A module system & loader for Kotlin. Made for me to use. Architecture Module is a building block for this sy

A simple xposed module that helps you fully control your location.

FuckLocation An simple xposed module that helps you fully control your location. 一个可以帮助你完全控制位置授权的模块 Currently, you may return custom location to speci

A CLI tool to convert multi-module Jetpack Compose compiler metrics into beautiful HTML reports
A CLI tool to convert multi-module Jetpack Compose compiler metrics into beautiful HTML reports

A CLI tool to convert multi-module Jetpack Compose compiler metrics into beautiful HTML reports 1. What are Jetpack Compose compiler metrics? The Comp

This is a demo android app representing implementation of SE principles in android app development

Articles Demo This repository contains a sample Android App that shows most popular articles data from NY Times API. This is a sample app that shows h

Name of your app is an android app that allows building a todo list
Name of your app is an android app that allows building a todo list

Project 1 - SimpleToDo Name of your app is an android app that allows building a todo list and basic todo items management functionality including add

Matches-simulator-app - App Android Nativo de Simulação de Partidas

Matches Simulator App App Android Nativo de Simulação de Partidas. Este repositório foi organizado em algumas branches que representam as implementaçõ

Owner
Alvin Setiawan
Android, Kotlin, Java, Firebase, PHP, CodeIgniter, NodeJS, MySQL, MongoDB, RestAPI
Alvin Setiawan
🚆 Retrofit adapters for modeling network responses with Kotlin Result, Jetpack Paging3, and Arrow Either.

Retrofit Adapters ?? Retrofit adapters for modeling network responses with Kotlin Result, Jetpack Paging3, and Arrow Either. Sandwich If you're intere

Jaewoong Eum 293 Dec 26, 2022
A lightweight Android activity router

Krouter A lightweight Android activity router written in Kotlin. Basic usage // anywhere in the app, preferably on application creation val krouter =

Denis Isidoro 121 Nov 29, 2022
LifecycleAwareGitHubSearch - The Activity Lifecycle and the ViewModel Architecture

Lifecycle-Aware GitHub Search In this project, we'll modify our GitHub search ap

null 1 Feb 8, 2022
A multi module app, for improve knowledges

MultiModuleApp App multimódulos para estudos Aqui existem vários apps simples (1 em cada módulo) e está sendo construído por: App multi módulos Consum

PLINIO DA SILVA ALENCAR 0 Dec 27, 2021
Workout Journal is a mobile app based on Multi-Module and Clean Architecture for those who want to track their progress over a workout and a calendar period.

Workout-Journal Workout Journal is a mobile app for those who want to track their progress over a workout and a calendar period. The app allows you to

Maxim Smolyakov 4 Oct 23, 2022
Course_modularizing_android_apps - Multi-module demo app that gets data from a Dota2 api

Work in progress Multi-module demo app that gets data from a Dota2 api. Module n

Julio Ribeiro 1 Dec 30, 2021
PackageReferenceComparison - Do app/module dependencies that share a dependency use the same Singleton ref?

PackageReferenceComparison Do app/module dependencies that share a dependency us

Liam Niehus-Staab 0 Feb 3, 2022
Calorie tracking app using multi-module CLEAN architecture

CalorieTrack Calorie tracking app using multi-module CLEAN architecture Tech used Multi-module Application (Improve build time & componentization) Kot

Chris Athanas 4 Aug 14, 2022
Sample project that shows an approach for designing a multi-module architecture for Jetpack Compose Android applications.

Compose Multi-Module Architecture Sample Sample project that shows an approach for designing a multi-module architecture for Jetpack Compose Android a

Pavlo Stavytskyi 77 Jan 3, 2023
Sample application to demonstrate Multi-module Clean MVVM Architecture and usage of Android Hilt, Kotlin Flow, Navigation Graph, Unit tests etc.

MoneyHeist-Chars Sample application to demonstrate Multi-module Clean MVVM Architecture and usage of Android Hilt, Kotlin Flow, Navigation Graph, Room

Hisham 20 Nov 19, 2022