Articles on Trending Technologies

Technical articles with clear explanations and examples

How to use drag and drop in Android?

Azhar
Azhar
Updated on 21-Aug-2019 619 Views

This example demonstrates how do I use drag and drop 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.                     Step 3 − Add the following code to src/MainActivity.javaimport android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.DragEvent; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.widget.LinearLayout; public class MainActivity extends AppCompatActivity implements View.OnTouchListener, View.OnDragListener {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);     ...

Read More

How to convert java bitmap to byte array In android?

Azhar
Azhar
Updated on 21-Aug-2019 5K+ Views

This example demonstrates how do I convert java bitmap to byte array 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.             Step 3 − Add the following code to src/MainActivity.javaimport android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.ImageView; import android.widget.Toast; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; public class MainActivity extends AppCompatActivity {    Button button;    ImageView ivSource, ivCompressed;    @Override    protected ...

Read More

Communication between Activity and Service in Android?

Azhar
Azhar
Updated on 21-Aug-2019 3K+ Views

This example demonstrates how do I communicate between Activity and Service 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.         Step 3 − Add the following code to src/MainActivity.javaimport android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.support.v7.app.AppCompatActivity; public class MainActivity extends AppCompatActivity implements View.OnClickListener {    Button buttonStart, buttonStop;    @Override    public void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       ...

Read More

How to ping external IP from java Android?

Azhar
Azhar
Updated on 21-Aug-2019 3K+ Views

This example demonstrates how do I ping external IP from java 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.     Step 3 − Add the following code to src/MainActivity.javaimport android.content.Context; import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.Toast; import java.io.IOException; public class MainActivity extends AppCompatActivity {    Boolean isConnected = false,    isWiFi = false,    isMobile = false;    @Override    protected void onCreate(Bundle savedInstanceState) {       ...

Read More

How to check the amount of RAM to be used by an Android App?

Azhar
Azhar
Updated on 21-Aug-2019 814 Views

This example demonstrates how do I check the amount of RAM to be used by an android app.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.javaimport android.app.ActivityManager; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.TextView; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       final TextView textView = findViewById(R.id.text); ...

Read More

HTML DOM Input Radio form Property

AmitDiwan
AmitDiwan
Updated on 21-Aug-2019 187 Views

The HTML DOM Input Radio form property is used for returning the form reference that contains the given input radio button. If the radio button is outside the form then it will simply return NULL. This property is read-only.SyntaxFollowing is the syntax for input radio form property −radioObject.formExampleLet us look at an example for the Input radio form property. Input radio form Property FRUIT: Mango Get the form id by clicking on the below button GET FORM    function formId() {       var P=document.getElementById("Mango").form.id;       document.getElementById("Sample").innerHTML = "The id of ...

Read More

HTML DOM Input Radio autofocus property

AmitDiwan
AmitDiwan
Updated on 21-Aug-2019 340 Views

The HTML DOM input radio autofocus property is associated with the HTML element’s autofocus attribute. This property is used for setting or returning whether the input radio button automatically be focused when the page loads or not.SyntaxFollowing is the syntax for −Setting the autofocus property.radioObject.autofocus = true|falseHere, true represents the radio button should get focus and false represents otherwise. It is set to false by default.ExampleLet us look at an example for the Input Radio autofocus property − Input password autofocus property RADIO: CHECK FOCUS    function FocusVal() {     ...

Read More

Baum Sweet Sequence in C Program?

Arnab Chakraborty
Arnab Chakraborty
Updated on 20-Aug-2019 245 Views

Here we will see the Baum Sweet Sequence. This sequence is one binary sequence. If a number n has an odd number of contiguous 0s, then nth bit will be 0, otherwise nth bit will be 1.We have a natural number n. Our task is to find the n-th term of Baum Sweet sequence. So we have to check whether it has any consecutive block of zeros of odd length.If the number is 4 then the term will be 1, because 4 is 100. So it has two (even) number of zeros.AlgorithmBaumSweetSeqTerm (G, s) −begin    define bit sequence seq ...

Read More

Binary Search using pthread in C Program?

Arnab Chakraborty
Arnab Chakraborty
Updated on 20-Aug-2019 620 Views

We know that the binary search approach is one of the most suitable and effective sorting algorithm. This works on sorted sequence. The algorithm is simple, it simply finds the element from middle, then divide the list by two parts, and moves either towards the left sublist, or right sublist.We know the algorithm of it. Now we will see how to use binary search technique in multithreading environment. The number of threads depends on number of cores are present in the system. Let us see the code to get the idea.Example#include #define MAX 16 #define MAX_THREAD 4 using namespace ...

Read More

Binary representation of next greater number with same number of 1’s and 0’s in C Program?

Arnab Chakraborty
Arnab Chakraborty
Updated on 20-Aug-2019 336 Views

Suppose we have one binary number, that is representation of a number n. We have to find binary representation of a number which is smallest but larger than n, and it also has same number of 0s and 1s. So if the number is 1011 (11 in decimal), then the output will be 1101 (13). This problem can be found using the next-permutation calculation. Let us see the algorithm to get the idea.AlgorithmnextBin(bin) −Begin    len := length of the bin    for i in range len-2, down to 1, do       if bin[i] is 0 and bin[i+1] ...

Read More
Showing 56381–56390 of 61,248 articles
Advertisements