Android Articles

Page 70 of 125

How to pick an image from image gallery in Android?

Azhar
Azhar
Updated on 02-Aug-2019 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
Azhar
Updated on 02-Aug-2019 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 change the app language programmatically in android?

Azhar
Azhar
Updated on 02-Aug-2019 2K+ 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
Azhar
Updated on 02-Aug-2019 2K+ 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 pass an object from one Activity to another in Android?

Azhar
Azhar
Updated on 02-Aug-2019 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
Azhar
Updated on 02-Aug-2019 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
Azhar
Updated on 02-Aug-2019 8K+ 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
Azhar
Updated on 02-Aug-2019 296 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
Azhar
Updated on 02-Aug-2019 226 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
Azhar
Updated on 02-Aug-2019 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
Showing 691–700 of 1,250 articles
« Prev 1 68 69 70 71 72 125 Next »
Advertisements