- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 1966 Articles for Apps/Applications
947 Views
This example demonstrates about How to detect airplane mode is on or off 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. Step 3 − Add the following code to src/MainActivity.javapackage app.com.sample; import androidx.appcompat.app.AppCompatActivity; import android.content.Context; import android.os.Bundle; import android.provider.Settings; import android.widget.TextView; public class MainActivity extends AppCompatActivity { TextView textView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); textView ... Read More
1K+ Views
This example demonstrates about How to play a custom ringtone/alarm sound 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. Step 3 − Add the following code to src/MainActivity.javapackage app.com.sample; import androidx.appcompat.app.AppCompatActivity; import android.media.Ringtone; import android.media.RingtoneManager; import android.net.Uri; import android.os.Bundle; import android.view.View; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } public void playRingtone(View view) ... Read More
638 Views
This example demonstrates about How do I display the current date and time in an Android applicationStep 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 app.com.sample; import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.widget.TextView; import java.text.DateFormat; import java.util.Date; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); TextView tvDateTime ... Read More
2K+ Views
This example demonstrates about How do I change the color of Button in Android when clicked.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 app.com.sample; import androidx.appcompat.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 androidManifest.xml ... Read More
2K+ Views
This example demonstrates about how do I create a custom message 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 projectStep 2 − Add the following code to res/layout/activity_main.xml. Step 3 − Click res from Project → Right click on layout → Select New → Layout resource file → Name the layout = “ custom_dialog, enter Linear layout in the “Root element” and click okayStep 4 − Add the following code to custom_dialog.xml ... Read More
19K+ Views
This example demonstrates about how do I start new Activity on click button 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 projectStep 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.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; public class MainActivity extends AppCompatActivity { Button button; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); button = (Button) ... Read More
862 Views
This example demonstrates about how do I get date and time from internet 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 projectStep 2 − Add the following code to res/layout/activity_main.xml. Step 3 − Add the following code to src/MainActivity.javaimport java.text.SimpleDateFormat; import java.util.Calendar; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.TextView; public class MainActivity extends AppCompatActivity { Calendar calendar; SimpleDateFormat simpledateformat; String Date; TextView DisplayDateTime; Button btn; @Override protected void ... Read More
1K+ Views
This example demonstrates about how do I set the date in datepicker dialog 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 projectStep 2 − Add the following code to res/layout/activity_main.xml. Step 3 − Add the following code to res/layout/DatePickerFragment.java (Right click on the package, click new – Java Class)import android.app.DatePickerDialog; import android.app.Dialog; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.v4.app.DialogFragment; import java.util.Calendar; public class DatePickerFragment extends DialogFragment { @NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { ... Read More
211 Views
This example demonstrates about how do I pass a String from one Activity to another 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 projectStep 2 − Add the following code to res/layout/activity_main.xml. Step 3 − Add the following code to src/MainActivity.javapackage app.com.sample; import android.content.Intent; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText; public class MainActivity extends AppCompatActivity { Button changeActivityButton; EditText messageEditText; @Override protected void onCreate(Bundle savedInstanceState) { ... Read More
1K+ Views
This example demonstrates about how do I change the Screen Orientation programmatically using a Button 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 projectStep 2 − Add the following code to res/layout/activity_main.xml. Step 3 − Add the following code to src/MainActivity.javapackage app.com.sample; import android.content.pm.ActivityInfo; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ... Read More