Found 1966 Articles for Apps/Applications

How to detect user pressing Home Key in an Activity on Android?

Azhar
Updated on 02-Aug-2019 08:08:34

421 Views

This example demonstrates how do I detect user pressing home key in an activity 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.javaimport android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.TextView; import android.widget.Toast; 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 close all activities at once in android?

Azhar
Updated on 02-Aug-2019 08:03:06

2K+ Views

This example demonstrates how do I close all activities at once 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 − 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 = ... Read More

How to pick an image from image gallery in Android?

Azhar
Updated on 02-Aug-2019 07:56:39

4K+ Views

This example demonstrates how do I pick an image from image gallery in android appStep 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.Activity; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.provider.MediaStore; import android.view.View; import android.widget.Button; import android.widget.ImageView; public class MainActivity extends Activity {    ImageView imageView;    Button button;    private static final int PICK_IMAGE = 100;    Uri imageUri; ... Read More

How to create a scrollable textView Android app?

Azhar
Updated on 02-Aug-2019 07:48:11

2K+ Views

This example demonstrates how do I create a scrollable textView 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 − Add the following code to src/MainActivity.javapackage app.com.sample; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.text.method.ScrollingMovementMethod; import android.widget.TextView; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       TextView textView = (TextView) findViewById(R.id.textView);       ... Read More

How to create a WebView in android app?

Azhar
Updated on 02-Aug-2019 07:38:20

3K+ Views

This example demonstrates how do I create a WebView 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 − Add the following code to src/MainActivity.javaimport android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.webkit.WebSettings; import android.webkit.WebView; import android.webkit.WebViewClient; public class MainActivity extends AppCompatActivity {    private WebView webView;    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       WebView webView = ... Read More

Custom progress Bar in Android?

Azhar
Updated on 02-Aug-2019 07:32:51

790 Views

This example demonstrates how do I create a progress bar 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 − Create a drawable resource file, name it as circle.xml and add the following code −    Step 4 − Add the following code to src/MainActivity.javaimport android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.ProgressBar; public class MainActivity extends AppCompatActivity {    ProgressBar progressBar;    @Override    protected void onCreate(Bundle savedInstanceState) {     ... Read More

How to change the app language programmatically in android?

Azhar
Updated on 02-Aug-2019 07:27:25

1K+ Views

This example demonstrates how do I in change the app language programmatically 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.res.Configuration; import android.content.res.Resources; import android.os.Build; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.util.DisplayMetrics; import java.util.Locale; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setAppLocale("bg");       setContentView(R.layout.activity_main);    }   ... Read More

How to implement Alarm Manager in android?

Azhar
Updated on 02-Aug-2019 07:19:32

1K+ Views

This example demonstrates how do I implement alarm manager 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.AlarmManager; import android.app.PendingIntent; 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; import android.widget.Toast; public class MainActivity extends AppCompatActivity {    Button start;    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main); ... Read More

How to check Internet connection availability on Android?

Azhar
Updated on 02-Aug-2019 07:13:31

340 Views

This example demonstrates how do I check internet connection availability 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.net.ConnectivityManager; import android.net.NetworkInfo; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.Toast; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       if (haveNetwork()){          Toast.makeText(MainActivity.this, "Network connection ... Read More

How to pass an object from one Activity to another in Android?

Azhar
Updated on 02-Aug-2019 07:02:51

3K+ Views

This example demonstrates how do I pass an object 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 project.Step 2 − Add the following code to res/layout/activity_main.xml.     Step 3 − Create a java class and add the following code in Character.javaimport java.io.Serializable; public class Character implements Serializable {    String name, Proffession, Position;    String[] abilities;    public Character(String name, String proffession, String position, String[] abilities) {       this.name = name;     ... Read More

Advertisements