Develop a WiFi Scanner for Android

Jennifer Nicholas
Updated on 30-Jul-2019 22:30:25

2K+ Views

This example demonstrate about How to develop a WiFi Scanner for AndroidStep 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.javapackage com.example.myapplication; import android.Manifest; import android.content.Context; import android.content.IntentFilter; import android.content.pm.PackageManager; import android.net.wifi.WifiManager; import android.os.Build; import android.support.annotation.NonNull; import android.support.v4.app.ActivityCompat; import android.support.v4.content.ContextCompat; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.ListView; import android.widget.Toast; public class MainActivity extends AppCompatActivity {    private ... Read More

Floor Decimal Values in MySQL Instead of Round

Ankith Reddy
Updated on 30-Jul-2019 22:30:25

193 Views

You can use TRUNCATE() method to floor the values instead of round. Let us first create a table −mysql> create table DemoTable (    Value DECIMAL(20, 8) ); Query OK, 0 rows affected (0.54 sec)Insert records in the table using insert command −mysql> insert into DemoTable values(23.5654433); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values(12.345542211); Query OK, 1 row affected, 1 warning (0.21 sec) mysql> insert into DemoTable values(12345.678543); Query OK, 1 row affected (0.22 sec)Following is the query to display all records from the table using select statement −mysql> select *from DemoTable;This will produce the ... Read More

FloatBuffer put Method in Java

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

143 Views

The required value can be written at the current position of the buffer and then the current position is incremented using the method put() in the class java.nio.FloatBuffer. This method requires a single parameter i.e. the value to be written in the buffer and it returns the buffer in which the value is inserted.A program that demonstrates this is given as follows −Example Live Demoimport java.nio.*; import java.util.*; public class Demo {    public static void main(String[] args) {       int n = 5;       try {          FloatBuffer buffer = FloatBuffer.allocate(n);     ... Read More

GetAlgorithm Method in Java

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

93 Views

The algorithm name for the parameter generator can be obtained using the method getAlgorithm() in the class java.security.AlgorithmParameterGenerator. This method requires no parameters and it returns the algorithm name in string form.A program that demonstrates this is given as follows −Example Live Demoimport java.security.*; import java.util.*; public class Demo {    public static void main(String[] argv) {       try {          AlgorithmParameterGenerator apGenerator = AlgorithmParameterGenerator.getInstance("DiffieHellman");          apGenerator.init(1024);          String algorithm = apGenerator.getAlgorithm();          System.out.println("The Algorithm is: " + algorithm);       } catch (NoSuchAlgorithmException e) { ... Read More

Use ORDER BY in Android SQLite

Anvi Jain
Updated on 30-Jul-2019 22:30:25

525 Views

Before getting into example, we should know what sqlite data base in android is. SQLite is an open source SQL database that stores data to a text file on a device. Android comes in with built in SQLite database implementation. SQLite supports all the relational database features. In order to access this database, you don't need to establish any kind of connections for it like JDBC, ODBC etc.This example demonstrate about How to use ORDER BY in Android sqlite.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to ... Read More

Define Multiple Filters in JSP

Arjun Thakur
Updated on 30-Jul-2019 22:30:25

819 Views

Your web application may define several different filters with a specific purpose. Consider, you define two filters AuthenFilter and LogFilter. Rest of the process will remain as explained above except you need to create a different mapping as mentioned below −    LogFilter    LogFilter           test-param       Initialization Paramter        AuthenFilter    AuthenFilter           test-param       Initialization Paramter        LogFilter    /* AuthenFilter /* Filters Application OrderThe order of filter-mapping elements ... Read More

Get Current Status Bar Elevation in Android

Nitya Raut
Updated on 30-Jul-2019 22:30:25

313 Views

This example demonstrates How to get current status bar elevation in android.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.     In the above code, we have taken text view to show status bar elevation.Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.app.ActivityManager; import android.app.admin.DevicePolicyManager; import android.content.ComponentName; import android.content.Context; import android.net.wifi.WifiInfo; import android.net.wifi.WifiManager; import android.os.Build; import android.os.Bundle; import android.support.annotation.RequiresApi; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.TextView; public class MainActivity extends AppCompatActivity ... Read More

MonthDay Format Method in Java

Nancy Den
Updated on 30-Jul-2019 22:30:25

137 Views

The MonthDay can be formatted with the specified formatter using the format() method in the MonthDay class in Java. This method requires a single parameter i.e. the MonthDay object to be formatted and it returns the formatted MonthDay with the specified formatter.A program that demonstrates this is given as followsExample Live Demoimport java.time.*; import java.time.temporal.*; import java.time.format.DateTimeFormatter;    public class Demo {       public static void main(String[] args) {       MonthDay md = MonthDay.parse("--02-22");       LocalDate ld = md.atYear(2019);       System.out.println("The MonthDay is: " + md);       DateTimeFormatter dtf = DateTimeFormatter.ofPattern("YYYY-MM-dd"); ... Read More

Duration minusDays Method in Java

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

151 Views

An immutable copy of a duration where some days are removed from it can be obtained using the minusDays() method in the Duration class in Java. This method requires a single parameter i.e. the number of days to be subtracted and it returns the duration with the subtracted days.A program that demonstrates this is given as follows −Example Live Demoimport java.time.Duration; public class Demo {    public static void main(String[] args) {       Duration d = Duration.ofDays(5);       System.out.println("The duration is: " + d);       System.out.println("A copy with 2 days removed from the duration is: ... Read More

Identify Last Document from MongoDB Find Result Set

Nishtha Thakur
Updated on 30-Jul-2019 22:30:25

245 Views

To identify the last document from MongoDB find() result set, you can use sort() in descending order. The syntax is as follows −db.yourCollectionName.find().sort( { _id : -1 } ).limit(1).pretty();To understand the above syntax, let us create a collection with the document. The query to create a collection with a document is as follows −> db.identifyLastDocuementDemo.insertOne({"UserName":"Larry", "UserAge":24, "UserCountryName":"US"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c94a2ff4cf1f7a64fa4df57") } > db.identifyLastDocuementDemo.insertOne({"UserName":"Chris", "UserAge":21, "UserCountryName":"UK"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c94a3094cf1f7a64fa4df58") } > db.identifyLastDocuementDemo.insertOne({"UserName":"David", "UserAge":25, "UserCountryName":"AUS"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c94a3174cf1f7a64fa4df59") } > db.identifyLastDocuementDemo.insertOne({"UserName":"Sam", "UserAge":26, "UserCountryName":"US"}); { ... Read More

Advertisements