Giter Site home page Giter Site logo

androidcompose-kotlin's Introduction

image
image

Android-Kotlin-Compose Basics :

  • Manifest file

The Android Manifest is an XML file that provides important information about the app to the Android operating system. It includes details such as the app's package name, the permissions the app requires, the app's components (activities, services, broadcast receivers, etc.), the minimum API level required to run the app, and other app-related details. The Android Manifest is an essential part of every Android app,and must beincluded in the app's root directory for the app to work properly.

  • What is Activity

An activity in Android is a single, focused task that a user can perform. An activity represents a screen in an app with which the user can interact in order to do something, such as view a list of items, take a photo, or send an email. An Android app can have multiple activities, each with a different screen, and the activities can be navigated between using intents. An activity is implemented as a Java or Kotlin class that extends the Activity class and must be declared in the Android Manifest file.


Activity LifeCycle

  • onCreate()

The onCreate() function is the entry point to this app and calls other functions to build the user interface. In Kotlin programs, the main() function is the specific place in your code where the Kotlin compiler starts. In Android apps, the onCreate() function fills that role. ``

  • setContent()

The setContent() function within the onCreate() function is used to define your layout through composable functions. All functions marked with the @Composable annotation can be called from the setContent() function or from other Composable functions. The annotation tells the Kotlin compiler that this function is used by Jetpack Compose to generate the UI.

The compiler takes the Kotlin code you wrote, looks at it line by line, and translates it into something that the computer can understand. This process is called compiling your code.

  • onStart()

The onStart() lifecycle method is called just after onCreate(). After onStart() runs, your activity is visible on the screen. Unlike onCreate(), which is called only once to initialize your activity, onStart() can be called by the system many times in the lifecycle of your activity.

  • onRestart()
  • onResume()
  • onPause()
  • onDestroy()

summary

When an activity starts from the beginning, you see all three of these lifecycle callbacks called in order:

  • onCreate() when the system creates the app.
  • onStart() makes the app visible on the screen, but the user is not yet able to interact with it.
  • onResume() brings the app to the foreground, and the user is now able to interact with it.

Jetpack Compose:

  • Composable function

A Composable function (@Composable annotation above it) takes some input and generates what's shown on the screen.

  • @Composable function names are capitalized.
  • You add the @Composable annotation before the function.
  • @Composable functions can't return anything. read more
  • Modifier

Compose uses a Modifier object, which is a collection of elements that decorate or modify the behavior of Compose UI elements. You use this to style the UI components of the Dice Roller app's components.

  • state in Compose

State in an app is any value that can change over time. In this app, the state is the cost of service. learn more..


Compose Animations:

  • Spring Bounce Animation

Spring animation is a physics-based animation driven by a spring force. With a spring animation, the value and velocity of movement are calculated based on the spring force that is applied read more..


Kotlin:

  • Kotlin Nullabilty HandLing

  • Use classes and objects in Kotlin

  • Use function types and lambda expressions in Kotlin

  • Additional Resources

  • Generic data types

  • enum class

  • data class

  • singleton object

  • collections

  • Higher order functions

  • Coroutines:

    Concurrency involves performing multiple tasks in your app at the same time. For example, your app can get data from a web server or save user data on the device, while responding to user input events and updating the UI accordingly.

    To do work concurrently in your app, you will be using Kotlin coroutines. Coroutines allow the execution of a block of code to be suspended and then resumed later, so that other work can be done in the meantime. Coroutines make it easier to write asynchronous code, which means one task doesn't need to finish completely before starting the next task, enabling multiple tasks to run concurrently.

    • Synchronous:

    In synchronous code, only one conceptual task is in progress at a time. You can think of it as a sequential linear path. One task must finish completely before the next one is started.

    • Asynchronous:

    Use the launch() function from the coroutines library to launch a new coroutine. To execute tasks concurrently, add multiple launch() functions to your code so that multiple coroutines can be in progress at the same time. read more...

    • async()
    • In the real world, you won't know how long the network requests for forecast and temperature will take. If you want to display a unified weather report when both tasks are done, then the current approach with launch() isn't sufficient. That's where async() comes in.
    • Use the async() function from the coroutines library if you care about when the coroutine finishes and need a return value from it. read how to use
    • Parallel Decomposition

    Parallel decomposition involves taking a problem and breaking it into smaller subtasks that can be solved in parallel. When the results of the subtasks are ready, you can combine them into a final result.

    • EXCEPTION and CANCELLATION

    An exception is an unexpected event that happens during execution of your code. You should implement appropriate ways of handling these exceptions, to prevent your app from crashing and impacting the user experience negatively.

    A similar topic to exceptions is cancellation of coroutines. This scenario is typically user-driven when an event has caused the app to cancel work that it had previously started. read more..

    • CoroutineContext

    The CoroutineContext provides information about the context in which the coroutine will be running in. The CoroutineContext is essentially a map that stores elements where each element has a unique key. These are not required fields, but here are some examples of what may be contained in a context: read more...


Testing:

  • Automated tests

Automated testing is code that checks to ensure that another piece of code that you wrote works correctly. read more...

  • Unit tests to test coroutines:
  • Unit testing code that uses coroutines requires some extra attention, as their execution can be asynchronous and happen across multiple threads.
  • To call suspending functions in tests, you need to be in a coroutine. As JUnit test functions themselves aren't suspending functions, you need to use the runTest coroutine builder. This builder is part of the kotlinx-coroutines-test library and is designed to execute tests. The builder executes the test body in a new coroutine.
    example

UI-UX Design Best Practise:


Testing for App Accessibility

  • TalkBack

TalkBack is a Google screen reader that provides spoken feedback so users can navigate their device without looking at the screen. This is especially helpful for people with impaired vision.

  • Switch Access

Switch Access lets you interact with your Android device using one or more switches instead of the touchscreen. This alternative to using the touchscreen for users is especially helpful to users with limited dexterity.


Networks

  • Http response

  • REST

    REST is a software architectural style that defines the set of rules to be used for creating web service

    REST architecture must have:

    * Client-server architecture
    * Resources exposed as URIs (Uniform Resource Idetifiers)
    * Uniform Interface
    * Stateless
    
  • Data Layer

    A data layer is responsible for the business logic of your app and for sourcing and saving data for your app. The data layer exposes data to the UI layer using the Unidirectional Data Flow pattern.more...


Additionals:

Descriptions (Project Wise):

8). Mars Photo

7). Race Tracker

6). DesertClicker

5).

4).AffirmationApp

3).

2). Lemonade

1). Dice Roller

androidcompose-kotlin's People

Contributors

vikas-kmr1 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.