Found 1631 Articles for Android

How to use date time picker in Android?

Azhar
Updated on 07-Jul-2020 13:56:58

5K+ Views

This example demonstrates how do I use date and time picker 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.DatePickerDialog; import android.app.TimePickerDialog; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.text.format.DateFormat; import android.view.View; import android.widget.Button; import android.widget.DatePicker; import android.widget.TextView; import android.widget.TimePicker; import java.util.Calendar; public class MainActivity extends AppCompatActivity implements DatePickerDialog.OnDateSetListener, TimePickerDialog.OnTimeSetListener {    TextView textView;    Button button;    int day, month, ... Read More

How to use BroadcastReceiver in Android?

Azhar
Updated on 03-Jul-2020 09:03:21

338 Views

This example demonstrates how do I use BroadcastReceiver 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.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.net.wifi.WifiManager; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.CompoundButton; import android.widget.Switch; import android.widget.Toast; public class MainActivity extends AppCompatActivity {    Switch wifiSwitch;    WifiManager wifiManager;    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);     ... Read More

What permission do I need to access Internet from an Android application?

Azhar
Updated on 03-Jul-2020 09:04:06

546 Views

This example demonstrates how do I open google from android app using Internet permission.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.WebView; public class MainActivity extends AppCompatActivity {    WebView webView;    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       webView = findViewById(R.id.webView);       ... Read More

How to rotate an Image in ImageView by an angle on Android?

Azhar
Updated on 03-Jul-2020 09:05:03

1K+ Views

This example demonstrates how do I rotate an image in ImageView by an angle 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.Button; import android.widget.ImageView; public class MainActivity extends AppCompatActivity {    ImageView imageView;    Button btnRotate;    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);   ... Read More

How to determine the size of an android view at run time?

Azhar
Updated on 03-Jul-2020 09:06:06

139 Views

This example demonstrates how do I determine the size of an android view at run time.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 – Copy and paste an image (.png/.jpg/.jpeg) into res/drawableStep 4 − Add the following code to src/MainActivity.javaimport android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.view.ViewTreeObserver; import android.widget.ImageView; import android.widget.TextView; public class MainActivity extends AppCompatActivity {    ImageView imageView;    @Override    protected void onCreate(Bundle savedInstanceState) { ... Read More

How to get a bitmap from Url in Android app?

Azhar
Updated on 03-Jul-2020 08:50:38

4K+ Views

This example demonstrates how do I get a bitmap from Url 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 – Copy and paste an image (.png/.jpg/.jpeg) into res/drawableStep 4 − Add the following code to src/MainActivity.javaimport android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.os.AsyncTask; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.ImageView; import java.io.IOException; import java.io.InputStream; public class MainActivity extends AppCompatActivity {    Bitmap ... Read More

How to use ScrollBar in Android?

Azhar
Updated on 03-Jul-2020 08:51:27

4K+ Views

This example demonstrates how do I use 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.                                                                                       ... Read More

How to Start an service at boot time in android app?

Azhar
Updated on 03-Jul-2020 08:52:08

3K+ Views

This example demonstrates how do I 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 new Java class (StartAppOnBoot.java) and add the following code −import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; public class StartAppOnBoot extends BroadcastReceiver {    @Override    public void onReceive(Context context, Intent intent) {    if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {       Intent i = new Intent(context, MainActivity.class);       i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);       ... Read More

How to start an android application at boot time?

Azhar
Updated on 03-Jul-2020 09:00:11

3K+ Views

This example demonstrates how do I start an android application at boot time.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 new Java class (StartAppOnBoot.java) and add the following code −import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; public class StartAppOnBoot extends BroadcastReceiver {    @Override    public void onReceive(Context context, Intent intent) {       if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {          Intent i = new Intent(context, ... Read More

How to get a list of installed android Applications?

Azhar
Updated on 07-Jul-2020 13:54:23

795 Views

This example demonstrates how do I get a list of installed android applications.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.ApplicationInfo; import android.content.pm.PackageInfo; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.util.Log; import android.widget.ArrayAdapter; import android.widget.ListView; import java.util.List; public class MainActivity extends AppCompatActivity {    ListView listView;    ArrayAdapter arrayAdapter;    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       ... Read More

Advertisements