Found 1631 Articles for Android

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

How to enable/disable the GPS programmatically in Android?

Azhar
Updated on 02-Aug-2019 06:57:46

3K+ Views

This example demonstrates how do I get enable/disable GPS programmatically 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.content.Intent; import android.location.LocationManager; import android.provider.Settings; 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 {    Button button;    Context context;    Intent intent1;    TextView textview;    LocationManager locationManager ;    boolean ... Read More

How to get current GPS location programmatically on Android?

Azhar
Updated on 02-Aug-2019 06:50:51

6K+ Views

This example demonstrates how do I get current GPS location programmatically 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.pm.PackageManager; import android.location.Location; import android.os.Bundle; import android.support.v4.app.ActivityCompat; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.Button; import android.widget.TextView; import com.google.android.gms.location.FusedLocationProviderClient; import com.google.android.gms.location.LocationServices; import com.google.android.gms.tasks.OnSuccessListener; import static android.Manifest.permission.ACCESS_FINE_LOCATION; public class MainActivity extends AppCompatActivity {    private FusedLocationProviderClient client;    @Override    protected void onCreate(Bundle ... Read More

How to get screen dimensions in pixels in Android app?

Azhar
Updated on 02-Aug-2019 06:43:06

167 Views

This example demonstrates how do I get screen dimensions in pixels 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.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.util.DisplayMetrics; import android.view.WindowManager; import android.widget.TextView; public class MainActivity extends AppCompatActivity {    TextView one, two;    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       ... Read More

How to use custom font in a android project?

Azhar
Updated on 02-Aug-2019 06:37:24

123 Views

This example demonstrates how do I use custom font in Android project.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.graphics.Typeface; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.TextView; public class MainActivity extends AppCompatActivity {    TextView tv;    Typeface myFont;    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       tv = (TextView) findViewById(R.id.textView);   ... Read More

Advertisements