While designing any iOS Application you might come across a scenario where you have to do some sort of action if the screen is inactive for some amount of time.Here we will be seeing the same, we will be detecting user inactivity for 5 seconds.We will be using Apple’s UITapGestureRecognizer you can read more about it herehttps://developer.apple.com/documentation/uikit/uitapgesturerecognizer.So Let’s get started! We will be designing a basic application where we will start the timer as soon as the application is launched. If the user fails to touch the screen or does not perform any operation till 5 seconds we will be ... Read More
This example demonstrate about How to lock the Android device programmatically.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 res/xml/policies.xml Step 4 − Add the following code to src/DeviceAdminpackage app.tutorialspoint.com.sample ; import android.app.admin.DeviceAdminReceiver ; import android.content.Context ; import android.content.Intent ; import android.widget.Toast ; public class ... Read More
Use aggregate framework along with $literal operator. Let us first create a collection with documents −> db.replaceValueDemo.insertOne( { _id : 100, "EmployeeName" :"Chris", "EmployeeOtherDetails": { "EmployeeDesignation" : "HR", "EmployeeAge":27 } } ); { "acknowledged" : true, "insertedId" : 100 } > db.replaceValueDemo.insertOne( { _id : 101, "EmployeeName" :"David", "EmployeeOtherDetails": { "EmployeeDesignation" : "Tester", "EmployeeAge":26 } } ... Read More
Indexes in a table are pointers to the data, these speed up the data retrieval from a table. If we use indexes, the INSERT and UPDATE statements get executed in a slower phase. Whereas SELECT and WHERE get executed with in lesser time.Creating an indexCTREATE INDEX index_name on table_name (column_name);Displaying the IndexesSHOW INDEXES FROM table_name;Dropping an indexDROP INDEX index_name;Following JDBC program creates a table with name Emp in JavaDB. creates an index on it, displays the list of indexes and, deletes the created index.Exampleimport java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.sql.Statement; public class IndexesExample { public static void main(String ... Read More
Following is the syntax executing the plus (+) operator −update yourTableName set yourColumnName3=(yourColumnName1+yourColumnName2)The above syntax is only for plus operator. You need to change symbol like -, *, / for other operations. Let us first create a table −mysql> create table DemoTable -> ( -> Number1 int, -> Number2 int, -> AddResult int, -> MinusResult int, -> MultiplyResult int, -> DivideResult int -> ); Query OK, 0 rows affected (0.89 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(Number1, Number2) values(40, 20); Query OK, 1 row affected (0.16 ... Read More
Here we will see the extended Euclidean algorithm implemented using C. The extended Euclidean algorithm is also used to get the GCD. This finds integer coefficients of x and y like below −𝑎𝑥+𝑏𝑦 = gcd(𝑎, 𝑏)Here in this algorithm it updates the value of gcd(a, b) using the recursive call like this − gcd(b mod a, a). Let us see the algorithm to get the ideaAlgorithmEuclideanExtended(a, b, x, y)begin if a is 0, then x := 0 y := 1 return b end if gcd := EuclideanExtended(b mod ... Read More
At first set the label on which you want the custom cursor to be visible on hover:JLabel label = new JLabel("Demo text! Hand cursor is visible on hover...");Now, set cursor to be visible as Hand Cursor instead of the default Cursor:label.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));The following is an example to make a custom cursor appear when the user moves the mouse over some text:Exampleimport java.awt.Cursor; import javax.swing.JDialog; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; public class SwingDemo extends JFrame { private void ShowDialog() { JLabel label = new JLabel("Demo text! Hand cursor is visible on hover..."); label.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); ... Read More
With Java Swing, you can set JLabel size as preferred size different than the default −JLabel label.setPreferredSize(new Dimension(250, 100));The following is an example to change JLabel size −Exampleimport java.awt.Color; import java.awt.Dimension; import java.awt.Font; import javax.swing.*; import javax.swing.border.Border; public class SwingDemo { public static void main(String args[]) { JFrame frame = new JFrame("Demo"); JLabel label; label = new JLabel("This is demo label!", JLabel.RIGHT); label.setVerticalAlignment(JLabel.TOP); label.setFont(new Font("Verdana", Font.PLAIN, 15)); label.setPreferredSize(new Dimension(250, 100)); label.setForeground(new Color(120, 90, 40)); label.setBackground(new ... Read More
You can change the MySQL date format with a specific format using DATE_FORMAT(). Following is the syntax −select date_format(yourColumnName, yourFormatSpecifier) from yourTableName;Let us first create a table −mysql> create table DemoTable ( ShippingDate date ); Query OK, 0 rows affected (0.48 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('2016-01-21'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values('2018-05-24'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values('2019-12-31'); Query OK, 1 row affected (0.18 sec)Display all records from the table using select statement −mysql> ... Read More
Notifications communicate important information to users of your app, regardless of whether your app is running on the user's device.For example, a sports app can let the user know when their favourite team scores. Notifications can also tell your app to download information and update its interface. Notifications can display an alert, play a sound, or badge the app's icon.You can read more about notification status here https://developer.apple.com/documentation/usernotificationsApple recommend to user UserNotifications framework, So let’s get started. We will be seeing very simple and easy solution to get the notification status.Step 1 − Firstly you need to import the UserNotifications ... Read More