Get Current Location Provider Information in Android

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

562 Views

This example demonstrate about How to get current location provider information 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 a text view to show the current network location provider.Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.Manifest; import android.content.pm.PackageManager; import android.location.Address; import android.location.Geocoder; import android.location.Location; import android.location.LocationManager; import android.os.Build; import android.os.Bundle; import android.support.annotation.RequiresApi; import android.support.v4.app.ActivityCompat; import android.support.v7.app.AppCompatActivity; import android.widget.TextView; ... Read More

Use Action Up Event in Android

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

279 Views

This example demonstrate about How use action up event 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 a text view to perform action up event.Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.annotation.SuppressLint; import android.os.Build; import android.os.Bundle; import android.support.annotation.RequiresApi; import android.support.v4.view.MotionEventCompat; import android.support.v7.app.AppCompatActivity; import android.view.MotionEvent; import android.view.View; import android.widget.TextView; import android.widget.Toast; public class MainActivity extends AppCompatActivity {   ... Read More

Add Elements to AbstractSequentialList Class at a Specific Position in Java

George John
Updated on 30-Jul-2019 22:30:25

112 Views

The AbstractSequentialList class has the add() method to add an element to the specific position.The syntax is as followsadd(int index, E ele)Here, index is where the element is to be inserted. The ele is the element to be inserted.To work with the AbstractSequentialList class in Java, you need to import the following packageimport java.util.AbstractSequentialList;The following is an example to implement AbstractSequentialList add() method in JavaExample Live Demoimport java.util.LinkedList; import java.util.AbstractSequentialList; public class Demo {    public static void main(String[] args) {       AbstractSequentialList absSequential = new LinkedList();       absSequential.add(0, 50);       absSequential.add(1, 30);     ... Read More

DoubleStream empty Method in Java

Krantik Chavan
Updated on 30-Jul-2019 22:30:25

71 Views

The empty() method of the DoubleStream class in Java returns an empty sequential DoubleStream.The syntax is as follows:static DoubleStream empty()To use the DoubleStream class in Java, import the following package:import java.util.stream.DoubleStream;Let us create an empty DoubleStream:DoubleStream doubleStream = DoubleStream.empty();Now, let us check the number of elements in the stream. It will be 0, since the stream is set to empty:doubleStream.count()The following is an example to implement DoubleStream empty() method in Java:Example Live Demoimport java.util.stream.DoubleStream; public class Demo {    public static void main(String[] args) {       DoubleStream doubleStream = DoubleStream.empty();       System.out.println("Number of elements in the stream ... Read More

LongStream min() Method in Java

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

143 Views

The min() method of the LongStream class in Java returns an OptionalLong describing the minimum element of this stream, or an empty optional if this stream is empty.The syntax is as follows:OptionalLong min()Here, OptionalLong is a container object which may or may not contain a long value.To use the LongStream class in Java, import the following package:import java.util.stream.LongStream;The following is an example to implement LongStream min() method in Java. The isPresent() method of the OptionalLong class returns true if the value is present:Example Live Demoimport java.util.*; import java.util.stream.LongStream; public class Demo {    public static void main(String[] args) {     ... Read More

Use pollFirst in Android ConcurrentLinkedDeque

Samual Sam
Updated on 30-Jul-2019 22:30:25

131 Views

Before getting into an example, we should know what ConcurrentLinkedDeque is, it is unbounded deque based on linked nodes. Multiple threads can access deque elements with safety.This example demonstrates about How to use pollFirst() in android ConcurrentLinkedDequeStep 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 a text view to show ConcurrentLinkedDeque elements.Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.os.Build; import android.os.Bundle; ... Read More

What Are Hash Functions in Blockchain

Prasanna Kotamraju
Updated on 30-Jul-2019 22:30:25

427 Views

We know that bitcoins enter into the digital market only through mining. It is a cryptocurrency created as a peer-to-peer currency which can be traded without using any Bank or Payment gateway. When these transactions are made, they are accounted for using a publicly distributed ledger which keeps a record of all the transactions made to every Bitcoin.Every time a transaction is made, a new block is created. Every new block will be verified and added into the block chain by the miners. Here comes the purpose of hash functions to make the block chain secure.What is a Hash?Hash is ... Read More

Sort Map Values by Key in Java

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

226 Views

Let’s say the following is our Map with unsorted keys −HashMapmap = new HashMap(); map.put("1", "A"); map.put("6", "B"); map.put("3", "C"); map.put("7", "D"); map.put("5", "E"); map.put("2", "F"); map.put("4", "G"); map.put("8", "H");Now, sort the above Map. The result of tMap below would be a sorted map by key −MaptMap = new TreeMap(map);Example Live Demoimport java.util.HashMap; import java.util.Map; import java.util.TreeMap; public class Demo {    public static void main(String[] args) {       HashMapmap = new HashMap();       map.put("1", "A");       map.put("6", "B");       map.put("3", "C");       map.put("7", "D");       map.put("5", "E");   ... Read More

Compile 32 Bit Program on 64 Bit GCC in C and C++

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

1K+ Views

Nowadays the compiler comes with default 64-bit version. Sometimes we need to compile and execute a code into some 32bit system. In that time, we have to use thisS feature.At first, we Shave to check the current target version of the gcc compiler. To check this, we have to type this command.gcc –v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper OFFLOAD_TARGET_NAMES=nvptx-none OFFLOAD_TARGET_DEFAULT=1 Target: x86_64-linux-gnu ........... ........... ...........Here it is showing that Target is x86_64. So we are using the 64-bit version of gcc. Now to use the 32-bit system, we have to write the following command.gcc –m32 program_name.cSometimes this command may generate ... Read More

Control Port of 8255

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

6K+ Views

In 8255, there are two types of command words or control word are available. And they are −Mode definition control word andPort C bit set/reset control word.Both these are written to the control port only. From the point of view of the microprocessor there is a single 8-bit control port, which is selected when CS* = 0, WR* = 0, A1 = 1 and A0 = 1. But if we consider the architecture of 8255, internally there are two control ports, one for mode definition control and another for Port C bit set/reset control. The contents of the control port ... Read More

Advertisements