Detect User Inactivity for 5 Seconds in Android Using Kotlin

Azhar
Updated on 30-Nov-2020 12:13:12

798 Views

This example demonstrates how to detect user inactivity for 5 seconds in Android using Kotlin.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.         Step 3 − Add the following code to src/MainActivity.ktimport android.os.Bundle import android.os.Handler import android.widget.Toast import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    lateinit var handler: Handler    lateinit var runnable: Runnable    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)     ... Read More

Use Custom Font in Android Project Using Kotlin

Azhar
Updated on 30-Nov-2020 12:07:50

725 Views

This example demonstrates how to use a custom font in an Android project using Kotlin.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xm         Step 3 − Create an asset folder and add the fonts in the font folder.Step 4 − Add the following code to src/MainActivity.ktimport android.graphics.Typeface import android.os.Bundle import android.widget.TextView import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)     ... Read More

Use AutoCompleteTextView in an Android App using Kotlin

Azhar
Updated on 30-Nov-2020 12:02:32

1K+ Views

This example demonstrates how to use AutoCompleteTextView in an Android App using Kotlin.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.         Step 3 − Add the following code to src/MainActivity.ktimport android.os.Bundle import android.widget.ArrayAdapter import android.widget.AutoCompleteTextView import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    private val fruits = arrayOf("Apple", "Banana", "Cherry", "Date", "Grape", "Kiwi", "Mango", "Pear")    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)   ... Read More

Get Resource Name Using Resource ID in Android with Kotlin

Azhar
Updated on 30-Nov-2020 11:59:15

809 Views

This example demonstrates how to get Resource Name using Resource id in Android using Kotlin.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.         Step 3 − Add the following code to src/MainActivity.ktimport android.os.Bundle import android.widget.TextView import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)       title = "KotlinApp"       val textView: TextView = findViewById(R.id.textView) ... Read More

Pickup and Hangup Calls in Android Using Kotlin

Azhar
Updated on 30-Nov-2020 11:56:08

345 Views

This example demonstrates how to pickup & hangup calls in Android using KotlinStep 1 − Create a new project in Android Studio, go to File ⇒ New Project, and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.         Step 3 − Add the following code to src/MainActivity.ktimport android.Manifest import android.content.BroadcastReceiver import android.content.Context import android.content.Intent import android.content.pm.PackageManager import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import android.widget.Toast import androidx.core.app.ActivityCompat import androidx.core.content.ContextCompat class MainActivity : AppCompatActivity() {    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)     ... Read More

Set Margins in Android LinearLayout Programmatically Using Kotlin

Azhar
Updated on 30-Nov-2020 11:48:23

3K+ Views

This example demonstrates how to set margins in an Android LinearLayout programmatically using Kotlin.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.     Step 3 − Add the following code to src/MainActivity.ktimport android.os.Bundle import android.view.Gravity import android.widget.Button import android.widget.RelativeLayout import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)       title = "KotlinApp"       val relativeLayout: RelativeLayout = ... Read More

Get Resource ID of an Image by Name in Android Using Kotlin

Azhar
Updated on 30-Nov-2020 11:43:36

1K+ Views

This example demonstrates how to get the resource id of an image if I know its name in Android using Kotlin.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.         Step 3 − Add the following code to src/MainActivity.ktimport androidx.appcompat.app.AppCompatActivity import android.os.Bundle import android.widget.TextView class MainActivity : AppCompatActivity() {    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)       title = "KotlinApp"     ... Read More

Make Android Device Vibrate Programmatically Using Kotlin

Azhar
Updated on 30-Nov-2020 11:40:34

2K+ Views

This example demonstrates how to make an Android device vibrate programmatically using Kotlin.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.         Step 3 − Add the following code to src/MainActivity.ktimport android.content.Context import android.os.Build import android.os.Bundle import android.os.VibrationEffect import android.os.Vibrator import androidx.appcompat.app.AppCompatActivity @Suppress("DEPRECATION") class MainActivity : AppCompatActivity() {    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)       title = "KotlinApp"       ... Read More

Find Selenium WebDriver Release Notes

Debomita Bhattacharjee
Updated on 30-Nov-2020 11:02:41

122 Views

We can find the release notes of Selenium webdriver. They reside within the source control under the specific folder for the particular language libraries. Follow the steps one by one −Navigate to the link − http://docs.seleniumhq.org/.Click on the Download tab.Move to the Selenium Client & WebDriver Language Binding section.Click on the Change Log link for each of the languages.

Pause Selenium for X Seconds

Debomita Bhattacharjee
Updated on 30-Nov-2020 10:58:55

2K+ Views

We can get Selenium to pause for X seconds with the concept of synchronization. There are two types of waits − implicit and explicit. Apart from this there is the Thread.sleep method that halts Selenium for a certain time. The wait time is passed as an argument to the method.ExampleCode Implementation with Thread.sleep.import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; public class ThreadWt{    public static void main(String[] args) {       System.setProperty("webdriver.chrome.driver",       "C:\Users\ghs6kor\Desktop\Java\chromedriver.exe");       WebDriver driver = new ChromeDriver();       driver.get("https://www.tutorialspoint.com/index.htm");       // identify element, enter text     ... Read More

Advertisements