Articles on Trending Technologies

Technical articles with clear explanations and examples

How to listen for volume buttons in Android background service using kotlin?

Azhar
Azhar
Updated on 20-Apr-2020 602 Views

This example demonstrates how to listen for volume buttons in Android background service 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.ktpackage app.com.kotlinapp import android.os.Bundle import android.os.Handler import android.provider.Settings import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    private lateinit var settingsContentObserver: SettingsContentObserver    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)       settingsContentObserver ...

Read More

How to play sound using SoundPool in Kotlin?

Azhar
Azhar
Updated on 20-Apr-2020 3K+ Views

This example demonstrates how to play sound using SoundPool in 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 − Create a new Android Resource folder (raw) and copy-paste your sound file in the res/raw/filename.mp3 as shown below −Step 4 − Add the following code to src/MainActivity.ktpackage app.com.myapplication import android.media.AudioManager import android.media.SoundPool import android.os.Bundle import android.view.View import android.widget.Toast import androidx.appcompat.app.AppCompatActivity @Suppress("DEPRECATION") class MainActivity : AppCompatActivity() {    private var ...

Read More

Write a program to calculate pow(x,n) in C++

sudhir sharma
sudhir sharma
Updated on 20-Apr-2020 460 Views

In this problem, we are given two integers x and n. Our task is to write a program to calculate the pow(x,n). Let's take an example to understand the problem, Input: x = 5 , n = 3 Output: 125 Example Program to calculate the pow(x,n): #include using namespace std; float myPow(float x, int y) { if (y == 0) return 1; float temp = myPow(x, y / 2); if (y % 2 == 0) return temp * temp; else { if (y > 0) return x * temp * temp; else return (temp * temp) / x; } } int main() { float x = 5; int n = 7; cout

Read More

How to create Html5 compliant Javadoc in Java 9?

raja
raja
Updated on 20-Apr-2020 308 Views

Before Java 9, we have to search in google to find out particular packages, class, interface, and method information. Since Java 9, Javadoc includes search options in the API documentation itself, and the output is HTML5 compliant.In the below example, we have created the "JavaDocTest.java" file in the "C:/JAVA" folder.Examplepublic class JavaDocTest { /** * Default method to be run to print * Tutorialspoint * @param args command-line arguments */ public static ...

Read More

How to Secure ZOOM application

Ajay yadav
Ajay yadav
Updated on 20-Apr-2020 257 Views

This article poses a common advisory and security measure note for the Zoom users to protect themself from presumptive hacking attempt, as this application is quite vulnerable to breach. Zoom is quite trending and its popularity mysteriously skyrocket in last 3 month in terms of downloads (20 CR) despite having other plethora of amazing video conferencing application. Zoom does not have the End-to-end encryption facility like whatsapp and WebEx and attackers can potentially gain control to the ZOOM without its user’s cognizance by mean of a secret tools called zWarDial.However, I am not going to discuss the usage of this ...

Read More

Importance of Optional.or() method in Java 9?

raja
raja
Updated on 17-Apr-2020 936 Views

In Java 9, few static methods: stream(), or(), and ifPresentOrElse() have added to Optional class. The introduction of an Optional class solves the null pointer exception.Optional.or() method returns an Optional describing the value if a value is present, otherwise returns an Optional produced by the supplying function. Syntaxpublic Optional or(Supplier

Read More

How to pass the parameters in the PowerShell function?

Chirag Nagrekar
Chirag Nagrekar
Updated on 17-Apr-2020 20K+ Views

You can pass the parameters in the PowerShell function and to catch those parameters, you need to use the arguments. Generally, when you use variables outside the function, you really don’t need to pass the argument because the variable is itself a Public and can be accessible inside the function. But in some cases we need to pass the parameters to the function and below is the example explains how you can write the code for it.The single parameter passed in function, function writeName($str){    Write-Output "Hi! there .. $str" } $name = Read-Host "Enter Name" writeName($name)Here, we are passing ...

Read More

Explain variable / Array scope in PowerShell function.

Chirag Nagrekar
Chirag Nagrekar
Updated on 17-Apr-2020 365 Views

Generally, when the variable is declared as a Public variable or outside the function in the script (not in any other variable or condition), you don’t need to pass that value to function because the function retains the value of the variable when the variable is initialized before the function is called.Examplefunction PrintOut{    Write-Output "your Name is : $name" } $name = Read-Host "Enter your Name" PrintOutIn the above example, $name variable is declared outside the function called PrintOut. So as the variable can be read inside the function, you can directly use the variable by its name.OutputEnter your ...

Read More

Explain the PowerShell Function.

Chirag Nagrekar
Chirag Nagrekar
Updated on 17-Apr-2020 1K+ Views

Function in a PowerShell is to reduce the redundancy of the repeated codes this means codes which are repeating, bind them into a function and call the function whenever necessary, so you don’t need to write codes multiple times.ExampleLet assume, you want to perform arithmetic operations (multiply, sum, divide and subtraction) of two values 5 and 4 in one go, so you will write different operations for two values or you will assign values to the variable called $val1 and $val2 and perform various operations on them as shown below in the example.$val1 = 5 $val2 = 4 $val1 ...

Read More

Z-Buffer or Depth-Buffer method in C++

sudhir sharma
sudhir sharma
Updated on 17-Apr-2020 2K+ Views

The z-buffer also known as depth-buffer is a method that is used for hidden surface detection.Hidden surface detectionFor any picture that has objects and surfaces that are transparent. In this case, objects that are behind other objects are hidden. For proper visual of the image, we need to remove these hidden surfaces is required. The identification is called hidden surface problem.In z-buffer, we will compare surfaces in the z-axis as depths.AlgorithmStep 1: initialize the depth of all pixel max.    d(i, j) = infinity Step 2: Initialize color for all pixels.    c(i, j) = background-color Step 3: for each ...

Read More
Showing 54311–54320 of 61,297 articles
Advertisements