Found 1626 Articles for Android

How to check if a bluetooth device is connected with Android device?

Azhar
Updated on 08-Jul-2020 06:22:24

3K+ Views

This example demonstrates how do I check if a Bluetooth device is connected with android device.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.bluetooth.BluetoothDevice; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.os.Bundle; import android.widget.Toast; import androidx.appcompat.app.AppCompatActivity; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);     ... Read More

How to add a shake feature that will refresh Android Application?

Azhar
Updated on 08-Jul-2020 06:02:40

477 Views

This example demonstrates how do I add a shake feature that will refresh 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.Context; import android.hardware.Sensor; import android.hardware.SensorEvent; import android.hardware.SensorEventListener; import android.hardware.SensorManager; import android.os.Bundle; import android.widget.Toast; import java.util.Objects; import androidx.appcompat.app.AppCompatActivity; public class MainActivity extends AppCompatActivity {    private SensorManager sensorManager;    private float mAccel;    private float mAccelCurrent;    private float mAccelLast;   ... Read More

How to dynamically update a listView in Android?

Azhar
Updated on 08-Jul-2020 06:03:18

4K+ Views

This example demonstrates how do I dynamically update a ListView 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.os.Bundle; import android.view.View; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.EditText; import android.widget.ListView; import java.util.ArrayList; import androidx.appcompat.app.AppCompatActivity; public class MainActivity extends AppCompatActivity {    EditText editText;    Button button;    ListView listView;    ArrayList list = new ArrayList();    ArrayAdapter adapter; ... Read More

How to detect application heap size in android?

Azhar
Updated on 08-Jul-2020 06:03:47

339 Views

This example demonstrates how do I detect application heap size 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 androidx.appcompat.app.AppCompatActivity; import android.app.ActivityManager; import android.os.Bundle; import android.view.View; import android.widget.TextView; import java.util.Objects; public class MainActivity extends AppCompatActivity {    TextView textView;    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       textView = ... Read More

How to resize an image in Android using Picasso?

Azhar
Updated on 08-Jul-2020 06:04:50

606 Views

This example demonstrates how to do I 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 − Open build.gradle (Module: app) and add the following dependency −implementation 'com.squareup.picasso:picasso:2.5.2'Step 3 − Add the following code to res/layout/activity_main.xml.     Step 3 − Add the following code to src/MainActivity.javaimport androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.widget.ImageView; import com.squareup.picasso.Picasso; public class MainActivity extends AppCompatActivity {    ImageView imageView;    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);   ... Read More

How to create different graphs in Android App?

Azhar
Updated on 08-Jul-2020 06:05:19

1K+ Views

This example demonstrates how to do I 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 dependency in the build.gradle (Module: app)implementation 'com.jjoe64:graphview:4.2.1'Step 3 − Add the following code to res/layout/activity_main.xml.     Step 4 − Add the following code to src/MainActivity.javaimport androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import com.jjoe64.graphview.GraphView; import com.jjoe64.graphview.series.DataPoint; import com.jjoe64.graphview.series.LineGraphSeries; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       ... Read More

How to check available space on Android Device?

Azhar
Updated on 08-Jul-2020 06:05:49

331 Views

This example demonstrates how do I check available space on an android device.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 androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.os.Environment; import android.os.StatFs; import android.text.format.Formatter; import android.util.Log; import android.widget.TextView; import java.io.File; public class MainActivity extends AppCompatActivity {    TextView textView;    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);     ... Read More

How to play videos in Android TextureView?

Azhar
Updated on 08-Jul-2020 06:06:21

1K+ Views

This example demonstrates how do I play videos in Android TextureView.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 − Create an asset folder and copy-paste the video into the asset folder.Step 4 − Add the following code to src/MainActivity.javaimport androidx.appcompat.app.AppCompatActivity; import android.content.res.AssetFileDescriptor; import android.graphics.SurfaceTexture; import android.media.MediaPlayer; import android.os.Build; import android.os.Bundle; import android.view.Surface; import android.view.TextureView; import java.io.IOException; public class MainActivity extends AppCompatActivity implements TextureView.SurfaceTextureListener, MediaPlayer.OnVideoSizeChangedListener {    TextureView textureView;    private ... Read More

How to detect scroll up and scroll down in android listView?

Azhar
Updated on 08-Jul-2020 05:55:30

1K+ Views

This example demonstrates how do I detect scroll up and down in android listView.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 androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.widget.AbsListView; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.ScrollView; import android.widget.Toast; public class MainActivity extends AppCompatActivity {    ScrollView scrollView;    ListView listView;    String[] numbers = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "X", "11", "12", "13", ... Read More

Playing an Arbitrary tone with Android?

Azhar
Updated on 08-Jul-2020 05:56:41

272 Views

This example demonstrates how do I playing an arbitrary tone with 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 androidx.appcompat.app.AppCompatActivity; import android.media.AudioFormat; import android.media.AudioManager; import android.media.AudioTrack; import android.os.Bundle; import android.os.Handler; public class MainActivity extends AppCompatActivity {    private final int duration = 10;    private final int sampleRate = 8000;    private final int numSamples = duration * sampleRate;   ... Read More

Advertisements