Found 1631 Articles for Android

Difference between Parcelable and Serializable in android

Vrundesha Joshi
Updated on 30-Jul-2019 22:30:25

3K+ Views

This example demonstrates about Difference between Parcel able and Serializable in androidSerializableSerializable is a markable interface or we can call as an empty interface. It doesn’t have any pre-implemented methods. Serializable is going to convert an object to byte stream. So the user can pass the data between one activity to another activity. The main advantage of serializable is the creation and passing data is very easy but it is a slow process compare to parcelable.A simple example of serializable as shown below –import java.io.Serializable; class serializableObject implements Serializable {    String name;    public serializableObject(String name) {     ... Read More

Detect home button press in android

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

2K+ Views

This example demonstrates about Detect home button press in 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.     In the above code, we have taken a text view.Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.TextView; import android.widget.Toast; public class MainActivity extends Activity {    TextView text;    @Override    public void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main); ... Read More

Best replacement of onItemClickListner in android recyclerview?

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

83 Views

This example demonstrates about Best replacement of onItemClickListner in android recyclerviewStep 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 recyclerview.Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.annotation.TargetApi; import android.os.Build; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.DefaultItemAnimator; import android.support.v7.widget.DividerItemDecoration; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.support.v7.widget.Toolbar; import android.widget.TextView; import java.util.ArrayList; public class MainActivity extends AppCompatActivity { ... Read More

Android Recyclerview GridLayoutManager column spacing

Vrundesha Joshi
Updated on 30-Jul-2019 22:30:25

2K+ Views

This example demonstrates about Android Recyclerview GridLayoutManager column spacingStep 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 recyclerview.Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.annotation.TargetApi; import android.os.Build; import android.os.Bundle; import android.support.v4.content.ContextCompat; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.DefaultItemAnimator; import android.support.v7.widget.DividerItemDecoration; import android.support.v7.widget.GridLayoutManager; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.support.v7.widget.Toolbar; import android.widget.TextView; import android.widget.Toast; import java.util.ArrayList; public class ... Read More

Android create shortcuts on the home screen

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

766 Views

This example demonstrates about Uninstall APKs programmaticallyStep 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.Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.app.Activity; import android.content.Intent; import android.content.SharedPreferences; import android.net.Uri; import android.os.Bundle; import android.support.v4.content.pm.ShortcutInfoCompat; import android.support.v4.content.pm.ShortcutManagerCompat; import android.support.v4.graphics.drawable.IconCompat; import android.view.View; import android.widget.TextView; import android.widget.Toast; public class MainActivity extends Activity {    private static final String PREF_KEY_SHORTCUT_ADDED = "Sairam";    TextView ... Read More

How to use take() in android ArrayBlockingQueue?

Vrundesha Joshi
Updated on 30-Jul-2019 22:30:25

62 Views

Before getting into the example, we should know what arrayblockingqueue is, it travels FIFO manner and the first element going to live the longest period of time and last element of the queue going to live a short period of the time.This example demonstrates about How to use take() in android ArrayBlockingQueueStep 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 ... Read More

How to use take() in android PriorityBlockingQueue?

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

104 Views

Before getting into the example, we should know what PriorityBlockingQueue is. It is an unbounded queue and follows the same order as a priority queue. The main usage of priority blocking queue is, it going to handle out of memory error.This example demonstrates about How to use take() in android PriorityBlockingQueueStep 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 PriorityBlockingQueue ... Read More

How to use subList() in android CopyOnWriteArrayList?

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

88 Views

Before getting into the example, we should know what CopyOnWriteArrayList is. It is a thread-safe variant of ArrayList and operations add, set, and so on by making a fresh copy of the underlying array.This example demonstrates about How to use subList() in android CopyOnWriteArrayListStep 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 CopyOnWriteArrayList elements.Step 3 − Add the following code ... Read More

How to use size() in android ConcurrentLinkedQueue?

Vrundesha Joshi
Updated on 30-Jul-2019 22:30:25

67 Views

Before getting into the example, we should know what ConcurrentLinkedQueue is, it is an unbounded queue based on linked nodes. Multiple threads can access queue elements with safety. Elements travel based on queue strategy as FIFO and elements going to insert from a tail. It does not allow null values.This example demonstrates about How to use size() in android ConcurrentLinkedQueueStep 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, ... Read More

How to use size() in android PriorityBlockingQueue?

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

57 Views

Before getting into the example, we should know what PriorityBlockingQueue is. It is an unbounded queue and follows the same order as a priority queue. The main usage of priority blocking queue is, it going to handle out of memory error.This example demonstrates about How to use size() in android PriorityBlockingQueueStep 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 PriorityBlockingQueue ... Read More

Advertisements