Found 1966 Articles for Apps/Applications

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

How to delete an SMS from the inbox in Android programmatically?

Azhar
Updated on 02-Aug-2019 06:28:23

2K+ Views

This example demonstrates how do I delete an sms from inbox in Android programmatically.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.net.Uri; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.Toast; public class MainActivity extends AppCompatActivity {    private Context mContext;    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);     ... Read More

How to set only numeric value for edittext in Android?

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

580 Views

This example demonstrates how do I set only numeric value for editText 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.text.InputType; import android.view.View; import android.widget.Button; import android.widget.EditText; public class MainActivity extends AppCompatActivity {    Button button;    EditText editText;    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main); ... Read More

How to add a TextView to a LinearLayout dynamically in Android?

Azhar
Updated on 31-Jul-2019 11:41:25

2K+ Views

This example demonstrates about How to add a TextView to a LinearLayout dynamically 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.java packagepackage app.com.sample; import android.os.Bundle; import android.widget.LinearLayout; import android.widget.TextView; import androidx.appcompat.app.AppCompatActivity; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       LinearLayout llMain = findViewById(R.id.rlMain);       TextView ... Read More

How can I set an ImageView's width and height programmatically in Android?

Azhar
Updated on 31-Jul-2019 11:36:38

3K+ Views

This example demonstrates about How can I set an ImageView's width and height programmatically 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 android.os.Bundle; import android.widget.ImageView; import android.widget.RelativeLayout; import androidx.appcompat.app.AppCompatActivity; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       RelativeLayout rlMain = findViewById(R.id.rlMain);       ImageView ... Read More

How to set an Android App's background image repeated?

Azhar
Updated on 31-Jul-2019 11:32:54

1K+ Views

This example demonstrates about How to set an Android App's background image repeatedStep 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/drawable/app_background.xml. Step 2 − Add the following code to res/values/styles.xml.           @color/colorPrimary       @color/colorPrimaryDark       @color/colorAccent       @drawable/app_background     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.os.Bundle; import androidx.appcompat.app.AppCompatActivity; public class ... Read More

How can we get the current language selected in the Android device?

Azhar
Updated on 31-Jul-2019 11:28:06

97 Views

This example demonstrates about How can we get the current language selected in the Android deviceStep 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.

Advertisements