Mobile Development Articles

Page 42 of 156

How to make an Android status bar notification persist across phone reboot?

Nishtha Thakur
Nishtha Thakur
Updated on 03-Jul-2020 599 Views

This example demonstrate about How to make an Android status bar notification persist across phone rebootStep 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.package app.tutorialspoint.com.notifyme ; import android.os.Bundle ; import android.support.v7.app.AppCompatActivity ; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate (Bundle savedInstanceState) {       super .onCreate(savedInstanceState) ;       setContentView(R.layout. activity_main ) ;    } }Step 4 − Add ...

Read More

How do I change current theme at runtime in my android app?

Azhar
Azhar
Updated on 03-Jul-2020 1K+ Views

This example demonstrates how do I change current theme at runtime in my 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.support.v7.app.AppCompatActivity; import android.os.Bundle; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setTheme(android.R.style.Theme_Black);       setContentView(R.layout.activity_main);    } }Step 4 − Add the following code to androidManifest.xml ...

Read More

How to detect long press in Android?

Azhar
Azhar
Updated on 03-Jul-2020 1K+ Views

This example demonstrates how do I detect long Press 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.GestureDetector; import android.view.MotionEvent; import android.widget.Toast; public class MainActivity extends AppCompatActivity {    GestureDetector gestureDetector;    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       gestureDetector = new GestureDetector(this, new GestureListener());   ...

Read More

How to detect end of ScrollView in Android?

Azhar
Azhar
Updated on 03-Jul-2020 2K+ Views

This example demonstrates how do I detect end of scrollView 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.MotionEvent; import android.view.View; import android.view.ViewTreeObserver; import android.webkit.WebView; import android.widget.ScrollView; import android.widget.Toast; public class MainActivity extends AppCompatActivity implements View.OnTouchListener,    ViewTreeObserver.OnScrollChangedListener {    ScrollView scrollView;    WebView webView;    @Override ...

Read More

How to create spinner Programmatically from array in Android?

Azhar
Azhar
Updated on 03-Jul-2020 2K+ Views

This example demonstrates how do I create spinner programmatically from 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.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.ArrayAdapter; import android.widget.Spinner; public class MainActivity extends AppCompatActivity {    Spinner spinner;    String colors[] = {"Red", "Blue", "White", "Yellow", "Black", "Green", "Purple", "Orange", "Grey"};    ArrayAdapter spinnerArrayAdapter;    @Override    protected void onCreate(Bundle ...

Read More

How to check grant permission at run-time in android?

Azhar
Azhar
Updated on 03-Jul-2020 2K+ Views

This example demonstrates how do I check grant permission at un-time 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.Manifest; import android.content.pm.PackageManager; import android.os.Build; import android.support.annotation.NonNull; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.support.v4.app.ActivityCompat; import android.widget.Toast; public class MainActivity extends AppCompatActivity{    private static final int REQUEST_PERMISSION_CODE = 101;    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);     ...

Read More

How to use a Volley Library to parse a JSON in android App?

Azhar
Azhar
Updated on 03-Jul-2020 1K+ Views

This example demonstrates how do I use a volley Library to parse a JSON in 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 – To create a JsonArray, go to https://myjson.com/ create your own JsonArray, for example, refer the code below.{    "employees": [       {          "firstname": "Niyaz",          "age": 30,          "mail": "niyaz3444@gmail.com" ...

Read More

How to jump to the home screen of the app using a button in android?

Azhar
Azhar
Updated on 03-Jul-2020 1K+ Views

This example demonstrates how do I jump to the home screen of the app 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 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.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);       Button button ...

Read More

How to create TextToSpeech in an android app?

Azhar
Azhar
Updated on 03-Jul-2020 278 Views

This example demonstrates how do I create TextToSpeech in 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.speech.tts.TextToSpeech; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.SeekBar; import java.util.Locale; public class MainActivity extends AppCompatActivity {    private TextToSpeech textToSpeech;    private EditText editText;    private ...

Read More

How to send data back to the main Activity in android?

Azhar
Azhar
Updated on 03-Jul-2020 1K+ Views

This example demonstrates how do I send data back to the main activity 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.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; import android.widget.Toast; public class MainActivity extends AppCompatActivity {    private TextView textViewResult;    private EditText editTextNumber1;    private EditText editTextNumber2;   ...

Read More
Showing 411–420 of 1,551 articles
« Prev 1 40 41 42 43 44 156 Next »
Advertisements