Found 2041 Articles for Mobile Development

How to make an application ignore screen orientation change in Android?

Azhar
Updated on 07-Jul-2020 12:53:46

292 Views

This example demonstrates how to make an application ignore screen orientation change 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.javapackage com.app.sample; import androidx.appcompat.app.AppCompatActivity; import android.content.pm.ActivityInfo; import android.os.Bundle; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);    } }Step 4 − Add the following code ... Read More

How to create directory programmatically in Android?

Azhar
Updated on 07-Jul-2020 12:54:18

4K+ Views

This example demonstrates how to create directory 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 com.app.sample; import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import java.io.File; import android.os.Bundle; import android.os.Environment; import android.app.Activity; import android.view.Menu; import android.widget.Toast; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       File file = new ... Read More

How to add table rows Dynamically in Android Layout?

Azhar
Updated on 07-Jul-2020 12:50:22

7K+ Views

This example demonstrates how to add table rows Dynamically in Android Layout.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 com.app.sample; import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.app.ProgressDialog; import android.graphics.Color; import android.os.AsyncTask; import android.os.Bundle; import android.util.TypedValue; import android.view.Gravity; import android.view.View; import android.widget.FrameLayout; import android.widget.LinearLayout; import android.widget.TableLayout; import android.widget.TableRow; import android.widget.TextView; import java.math.BigDecimal; import java.text.DecimalFormat; import java.text.SimpleDateFormat; public class MainActivity extends AppCompatActivity { ... Read More

How to work with Glide in Android

Azhar
Updated on 07-Jul-2020 12:51:06

607 Views

This example demonstrates how to work with GlideStep 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 androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.ImageView; import com.bumptech.glide.Glide; import com.bumptech.glide.request.RequestOptions; public class MainActivity extends AppCompatActivity implements View.OnClickListener {    ImageView imageView;    Button btnDrawableImage, btnUrlImage, btnErrorImage, btnPlaceholderImage, btnResizeImage, btnRotateImage;    @Override    protected void onCreate(Bundle savedInstanceState) { ... Read More

How to work with Picasso in Android

Azhar
Updated on 07-Jul-2020 12:51:55

150 Views

This example demonstrates how to work with PicassoStep 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 androidx.appcompat.app.AppCompatActivity; import android.graphics.Bitmap; import android.graphics.drawable.Drawable; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.ImageView; import android.widget.Toast; import com.squareup.picasso.Callback; import com.squareup.picasso.Picasso; import com.squareup.picasso.Target; public class MainActivity extends AppCompatActivity implements View.OnClickListener {    ImageView imageView;    int i ... Read More

How do add dependency in Android studio

Azhar
Updated on 07-Jul-2020 12:46:34

1K+ Views

This example demonstrates about How to add dependency in Android studioStep 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 androidx.annotation.NonNull; import androidx.appcompat.app.AppCompatActivity; import androidx.core.app.ActivityCompat; import android.Manifest; import android.annotation.SuppressLint; import android.app.Activity; import android.content.Intent; import android.content.IntentSender; import android.content.pm.PackageManager; import android.location.Location; import android.net.Uri; import android.os.Bundle; import android.os.Looper; import android.provider.Settings; import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.TextView; import android.widget.Toast; import ... Read More

Android GPS, Location Manager tutorial

Azhar
Updated on 07-Jul-2020 12:47:44

2K+ Views

This example demonstrates how to access Android GPS, Location ManagerStep 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 androidx.annotation.NonNull; import androidx.appcompat.app.AppCompatActivity; import androidx.core.app.ActivityCompat; import android.Manifest; import android.annotation.SuppressLint; import android.app.Activity; import android.content.Intent; import android.content.IntentSender; import android.content.pm.PackageManager; import android.location.Location; import android.net.Uri; import android.os.Bundle; import android.os.Looper; import android.provider.Settings; import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.TextView; import android.widget.Toast; import com.google.android.gms.common.api.ApiException; ... Read More

How to set an alert in Android to fire at given date and time?

Azhar
Updated on 07-Jul-2020 12:48:44

799 Views

This example demonstrates how to do I an alert in Android to fire at a given date and time 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.javapackage app.com.sample; import androidx.appcompat.app.AppCompatActivity; import androidx.fragment.app.DialogFragment; import android.app.AlarmManager; import android.app.PendingIntent; import android.app.TimePickerDialog; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.widget.TimePicker; import java.text.DateFormat; import java.util.Calendar; import java.util.Objects; public class MainActivity extends AppCompatActivity implements TimePickerDialog.OnTimeSetListener{    String timeText;   ... Read More

How to play videos in Android from assets folder or raw folder?

Azhar
Updated on 07-Jul-2020 12:41:01

4K+ Views

This example demonstrates how do I play videos in Android from the assets folder or raw folder 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 android resource folder(raw) and copy-paste your video file in that folder.Step 4 − Add the following code to src/MainActivity.javaimport androidx.appcompat.app.AppCompatActivity; import android.net.Uri; import android.os.Bundle; import android.widget.MediaController; import android.widget.VideoView; public class MainActivity extends AppCompatActivity {    @Override    protected void ... Read More

How can I get onclick event on webview in Android?

Azhar
Updated on 07-Jul-2020 12:41:36

4K+ Views

This example demonstrates how do I get onClick event on webView 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 androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.view.MotionEvent; import android.view.View; import android.webkit.WebView; import android.webkit.WebViewClient; import android.widget.Toast; public class MainActivity extends AppCompatActivity implements View.OnTouchListener, Handler.Callback {    private static final int CLICK_ON_WEBVIEW = 1;    private static final int CLICK_ON_URL = 2;   ... Read More

Advertisements