Found 1626 Articles for Android

How to execute Async task repeatedly after fixed time intervals in Android?

Azhar
Updated on 03-Jul-2020 12:48:21

767 Views

This example demonstrates how do I execute AsyncTask repeatedly after fixed time intervals 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.os.AsyncTask; import android.os.Bundle; import android.os.Handler; import android.widget.Toast; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       RunTask();    }   ... Read More

How to create a smooth image rotation in android?

Azhar
Updated on 03-Jul-2020 12:48:55

281 Views

This example demonstrates how do I create a smooth image rotation 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 − Create a new folder named “anim” in the res. Right click on anim folder and create an animation resource file (rotate.xml) and add the following code −     Step 3 − Add the following code to src/MainActivity.javaimport android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.view.animation.Animation; ... Read More

How to change the position of the dialog on Screen android?

Azhar
Updated on 03-Jul-2020 12:49:28

2K+ Views

This example demonstrates how do I change the position of the dialog on Screen 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.app.AlertDialog; import android.content.DialogInterface; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.Gravity; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       AlertDialog.Builder builder = new AlertDialog.Builder(this);     ... Read More

How can I set an icon for my Android application?

Azhar
Updated on 03-Jul-2020 12:50:50

4K+ Views

This example demonstrates how set an icon for my Android application .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  − Further follow the path to reach the desired folder to add icon (app → res → mipmap).Step 3 - Add you app icon. You can just simply copy and paste the image in mipmap folder.Step 4 - After placing the image in the mipmap folder. You need to rename the default icon name to your icon image name.Step 5  − Add the following ... Read More

How do I create a splash screen on Android App?

Azhar
Updated on 03-Jul-2020 12:51:30

779 Views

This example demonstrates how to pass data between activities.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.javapackage com.example.sample; import android.content.Intent; import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import static java.lang.Thread.sleep; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       startActivity(new Intent(MainActivity.this, SecondActivity.class));       try {          sleep(3000);     ... Read More

Android bundle to pass data between activities?

Azhar
Updated on 03-Jul-2020 12:40:01

257 Views

This example demonstrates how to pass data between activities.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 res/layout/activity_second.xml.               Step 4  − Add the following code to src/MainActivity.javapackage com.example.sample; import androidx.appcompat.app.AppCompatActivity; import android.content.Intent; import android.text.TextUtils; import android.view.View; import android.widget.Button; import android.widget.EditText; import ... Read More

How to pass data between Activities on Android application?

Azhar
Updated on 07-Jul-2020 14:42:22

184 Views

This example demonstrates how to pass data between Activities on Android application.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.                                                                                                   ... Read More

How to create Android Hello World App?

Azhar
Updated on 03-Jul-2020 12:41:23

418 Views

This example demonstrates how to create Android Hello World 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.javapackage com.example.sample; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);    } }Step 4  − Add the following code to Manifests/AndroidManifest.xml           ... Read More

How to Justify Text in TextView on Android?

Azhar
Updated on 03-Jul-2020 12:42:00

7K+ Views

This example demonstrates how to Justify Text in TextView on 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.javapackage com.example.sample; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);    } }Step 3  − Add the following code to Manifests/AndroidManifest.xml       ... Read More

How to change action bar size in Android?

Azhar
Updated on 03-Jul-2020 12:42:48

3K+ Views

This example demonstrates how to change action bar 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/values/styles.xml                     @color/colorAccent       @color/colorPrimary       @color/colorAccent       36dip     Step 3  − Add the following code to res/layout/activity_main.xml.     Step 4  − Add the following code to src/MainActivity.javapackage com.example.sample; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; public class MainActivity extends ... Read More

Advertisements