Found 1966 Articles for Apps/Applications

How can I get battery level and state (plugged in, discharging, charging, etc) in Android?

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

895 Views

This example demonstrates how do I get battery level and state (plugged in, discharging, charging, etc) 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.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.os.BatteryManager; import android.os.Bundle; import android.widget.TextView; import android.widget.Toast; public class MainActivity extends AppCompatActivity {    TextView textView;    Context context;    @Override    protected void onCreate(Bundle savedInstanceState) {   ... Read More

Android imageView Zoom-in and Zoom-Out?

Azhar
Updated on 07-Jul-2020 11:53:39

6K+ Views

This example demonstrates how do I Zoom In and Zoom Out an android ImageView.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.view.MotionEvent; import android.view.ScaleGestureDetector; import android.widget.ImageView; public class MainActivity extends AppCompatActivity {    private ScaleGestureDetector scaleGestureDetector;    private float mScaleFactor = 1.0f;    private ImageView imageView;      @Override    protected void onCreate(Bundle savedInstanceState) {       ... Read More

How to disable back button in android while logging out the application?

Azhar
Updated on 07-Jul-2020 11:54:34

982 Views

This example demonstrates how do I disable back button in android while logging out the application.Step 1 − Create a new project in Android Studio, go to File rArr; 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.widget.Toast; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);    }    @Override    public void onBackPressed() {       ... Read More

How to disable Mobile Data on Android?

Azhar
Updated on 07-Jul-2020 11:48:58

1K+ Views

This example demonstrates how do I disable Mobile data in Android.For your find Information, unless you have a rooted phone I don't think you can enable and disable data programmatically because in order to do so we have to include MODIFY_PHONE_STATE permission which is only given to system or signature apps.setMobileDataEnabled() method is no longer callable via reflection. It was callable since Android 2.1 (API 7) to Android 4.4 (API 19) via reflection, but as of Android 5.0 and later, even with the rooted phones, the setMobileDataEnabled() method is not callable.Step 1 − Create a new project in Android Studio, ... Read More

How do we set the input type for an Android EditText programatically?

Azhar
Updated on 07-Jul-2020 11:47:39

156 Views

This example demonstrates how do I set the input type for an Android EditText 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 androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.text.InputType; import android.view.View; import android.widget.EditText; public class MainActivity extends AppCompatActivity {    EditText editText;    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);     ... Read More

How to set the value for the attribute layout_weight for button in Android dynamically from java code?

Azhar
Updated on 08-Jul-2020 05:50:42

1K+ Views

This example demonstrates how do I set the value for the attribute layout_weight for button in android dynamically from java code.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.widget.Button; import android.widget.LinearLayout; public class MainActivity extends AppCompatActivity {    LinearLayout linearLayout;    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       linearLayout ... Read More

How do I hide and show a menu item in the Android ActionBar?

Azhar
Updated on 07-Jul-2020 11:43:04

4K+ Views

This example demonstrates how do I hide and show a menu item in the Android ActionBar.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.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.widget.CompoundButton; import android.widget.ToggleButton; public class MainActivity extends AppCompatActivity {    ToggleButton button1;    Menu myMenu;    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);     ... Read More

How to load files from asset directory into WebView in Android?

Azhar
Updated on 07-Jul-2020 11:44:21

3K+ Views

This example demonstrates how do I load files from asset directory into 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.webkit.WebView; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       WebView webView = findViewById(R.id.webView);       webView.loadUrl("file:///android_asset/mytext.html"); ... Read More

How to send an attachment in email using Swift(ios)?

Mohtashim M
Updated on 23-Oct-2019 09:05:25

2K+ Views

Knowing how to send attachments in the email is very important since most of the application has sharing features. Hence having hands-on experience is important.In this post, we will be seeing how to send an attachment in the mail using Swift.So, let’s get started.For this, we will be using MFMailComposeViewController, which is a standard view controller, whose interface lets the user manage, edit, and send email messages.You can read more about it here https://developer.apple.com/documentation/messageui/mfmailcomposeviewcontrollerWe will also be using MFMailComposeViewControllerDelegate to handle results from MFMailComposeResult.You can read about it here https://developer.apple.com/documentation/messageui/mfmailcomposeviewcontrollerdelegateWe will be creating one sample application to understand, Step 1 ... Read More

How to call a method after a delay in Swift(iOS)?

Mohtashim M
Updated on 23-Oct-2019 08:40:00

2K+ Views

In this post, we will be seeing how you can delay a method call using Swift. Here we will be seeing how you can achieve the same in two ways, So let’s get started, We will be seeing both the example in Playground, Step 1 − Open Xcode → New Playground.In the first approach, we will be using asyncAfter(deadline: execute:) instance method, which Schedules a work item for execution at the specified time and returns immediately.You can read more about it here https://developer.apple.com/documentation/dispatch/dispatchqueue/2300020-asyncafterStep 2 − Copy the below code in Playground and run, func functionOne() {    let delayTime = ... Read More

Advertisements