Skip to main content

Posts

Showing posts from October, 2020

Interview Questions which are asked frequently

  What do you think are the advantages of using Java? Java is a high-level object-oriented programming language used for developing games, device systems, and applications. It is secure, fast, reliable, portable and platform independent. 2. What do you understand by Object and Class? An object is understood as a collection of methods and classes which represent its state and executes operations. A class is used to define new types of data which in turn is used to create objects. 3. What are JVM, JDK, and JRE? • JVM (Java Virtual Machine) offers the runtime environment for codes to be executed. • JRE (Java Runtime Environment) is the collection of files needed during runtime by JVM. • JDK (Java Development Kit) is needed to write and execute a program and contains the JRE with necessary development tools. 4. What is meant by looping? Loops are used to repeatedly execute a certain statement or block of statements. They are of three types- For Loops, While Loops and Do While Loops. 5....

Color Picker Dialog(Ambilwarna)

  In this tutorial, we will use a 3rd party library called AmbilWarna to implement a color picker into our app. We will then use the picked color and set the background of our Activity to it. In build.gradle file add these dependency:- implementation 'com.github.yukuku:ambilwarna:2.0.1' In MainActivity.java class file add these lines of codes:- package com.deftskill.colorpickerexample; import androidx.appcompat.app.AppCompatActivity; import androidx.constraintlayout.widget.ConstraintLayout; import androidx.core.content.ContextCompat; import android.os.Bundle; import android.view.View; import android.widget.Button; import yuku.ambilwarna.AmbilWarnaDialog; public class MainActivity extends AppCompatActivity { ConstraintLayout mLayout ; int mDefaultColor ; Button mButton ; @Override protected void onCreate(Bundle savedInstanceState) { super .onCreate(savedInstanceState); setContentView(R.layout. activity_main ); mLayout = (ConstraintLayo...

EasyPermission Library

In this tutorial,we will learn, how to use the EasyPermissions library to request a dangerous permission at run time, which is necessary since Android Marshmallow (API level 23). This library provides an easy way to request multiple permissions at once, handle the results (granted or denied), show a rationale when the user previously denied a permission with an explanation of why this permission is needed and it even provides an easy way to create an AlertDialog that sends the user directly to the settings of the phone to manually grant a permission if he previously checked the “don’t ask again” box. In MainActivity.java class file add these lies of codes:- package com.deftskill.easypermissionexample; import androidx.annotation. NonNull ; import androidx.appcompat.app.AppCompatActivity; import android.Manifest; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.Toast; import java.util.List; import pub.d...

Validate Email & Password with Regular Expression

  In this video we will learn, how to validate an email address and password client side, by using regular expressions (regex). This way we can check, if the inserted email address is formed like an email address, and if the password contains certain characters, like upper and lower case letters, digits and special characters. For this we will use the Pattern class, with which we can compile a regex from a string and then use the matcher method to compare it with the input. In build.gradle file add this dependency:- implementation 'com.google.android.material:material:1.0.0' In MainActivity.java class file add these lines of codes:- import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.util.Patterns; import android.view.View; import android.widget.Toast; import com.google.android.material.textfield.TextInputLayout; import java.util.regex.Pattern; public class MainActivity extends AppCompatActivity { private static final Pattern PASSWORD_P...