Posts

Kotlin Coroutines

Coroutines are nothing but lightweight threads. Coroutines provide us an easy way to do synchronous and asynchronous programming. Coroutines allow execution to be suspended and resumed later at some point in the future which is best suited for performing non-blocking operations in the case of multithreading. Coroutines is a lightweight thread because creating coroutines doesn't allocate new threads. Instead, they use predefined thread pools, and smart scheduling. Scheduling is the process of determining which piece of work you will execute next.. Is called on suspending functions. We can suspend and resume the Coroutines while execution. This means we can have a long-running task, which can be executed one by one or  which can be executed little-by-little.. We can pause it any number of times and resume it when we are ready again. Advantages/Properties : Run 1 background thread & Multiple Coroutines Light Weight Threads Can run in parallel Can wait for each other Communicate wi...

Use of Camera

We can make use of the Camerax API Since out application is a software and the camera is a hardware, we need to bind it with our application On doing this we will get signal in our application which we need to show in our application  using the PreviewView and then use ImageCapture to capture the image that's been displayed on the screen and then store the file as required we need to add the camerax dependencies namely camera-camera, camera-lifecycle, camera-view We need to have camera permission <Uses-permission> android.permission.camera <Uses-feature> android.hardware.camera.any In the layout we can add a button to capture the image and a PreviewView avaialble from androidx.camera.view.PreviewView In the activity, Check if the permissions are granted or not  var camera : Camera in onCreate(){ if(ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA)==PERMISSION_GRANTED) { startCamera() } else {      ActvitiyCompat.requestPermissions(t...

Android Concepts

ADB Android Debug Bridge (adb) is a command-line tool that lets you communicate with a device. The adb command facilitates a variety of device actions, such as installing and debugging apps. It is a client-server program that includes three components: A client , which sends commands. The client runs on your development machine. You can invoke a client from a command-line terminal by issuing an adb command. A daemon (adbd) , which runs commands on a device. The daemon runs as a background process on each device. A server , which manages communication between the client and the daemon. The server runs as a background process on your development machine. Command to install an APK : adb install path_to_apk Command to check connected devices : adb devices Set up port forwarding :   sets up forwarding of host port 6100 to device port 7100 adb forward tcp:6100 tcp:7100 sets up forwarding of host port 6100 to local:logd adb forward tcp:6100 local:logd Copying the files : To copy a file ...