Found 2041 Articles for Mobile Development

How to open a website in iOS's web browser from my application?

Sadiqaadil
Updated on 11-Sep-2019 08:46:53

217 Views

In this post we will learn how to open website in iOS browser.We will open Facebook in iOS browser.Step 1 − Open Xcode → New Project → Single View Application → Let’s name it “OpenBrowser”Step 2 − Open Main.storyboard and add a button as shown below. I have given the button title as “Open Facebook”Step 3 − Attach one @IBAction function in ViewController, name it openBrowserStep 4 − In openBrowserFunction write the code to open URL like shown below@IBAction func openBrowsere(_ sender: Any) {    let url = URL(string: "https://www.facebook.com")!    if UIApplication.shared.canOpenURL(url) {       UIApplication.shared.open(url, options: [:], ... Read More

How to change action bar size in Android?

Azhar
Updated on 03-Jul-2020 12:42:48

2K+ Views

This example demonstrates how to change action bar size 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/values/styles.xml                     @color/colorAccent       @color/colorPrimary       @color/colorAccent       36dip     Step 3  − Add the following code to res/layout/activity_main.xml.     Step 4  − Add the following code to src/MainActivity.javapackage com.example.sample; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; public class MainActivity extends ... Read More

Launching the App Store from an iOS application

Sadiqaadil
Updated on 11-Sep-2019 08:43:48

947 Views

In this post we will learn how to open app store from iOS application.In this example we will open app store and show Facebook app on store. You can open your app if you want just by changing the ID to your app id.Lets do it.Step 1 − Open Xcode → New Project → Single View Application → Let’s name it “OpenAppStore”Step 2 − Open Main.storyboard and add a button as shown below.Step 3 − Attach one @IBAction for the button for click event. Name the function as openAppstoreClicked.Step 4 − In openAppstoreClicked we will write the code to open ... Read More

How to read value from string.xml in Android?

Azhar
Updated on 03-Jul-2020 12:35:28

1K+ Views

This example demonstrates how to read value from string.xml 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/values/strings.xml    Sample    Test string Step 3  − Add the following code to res/layout/activity_main.xml     Step 4  − Add the following code to src/MainActivity.javapackage com.example.sample; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);    } }Step ... Read More

How to make phone call in iOS 10 using Swift?

Sadiqaadil
Updated on 11-Sep-2019 08:40:24

2K+ Views

In this post we will be seeing how to make phone in iOS programmatically.So let’s get started.Step 1 − Open Xcode → New Project → Single View Application → Let’s name it “MakeCall”Step 2 − Open Main.storyboard and add one text field and one button as shown belowStep 3 − Create @IBOutlet for the text field, name it phoneNumberTextfield.Step 4 − Create @IBAction method callButtonClicked for call buttonStep 5 − To make a call we can use iOS openURL. In callButtonClicked add following linesif let url = URL(string: "tel://\(phoneNumberTextfield.text!)"), UIApplication.shared.canOpenURL(url) { UIApplication.shared.open(url, options: [:], completionHandler: nil)Step 6 − Run the ... Read More

How do I declare global variables on Android?

Azhar
Updated on 03-Jul-2020 12:36:21

1K+ Views

This example demonstrates how to declare global variables 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.example.sample; import android.os.Build; import android.os.Bundle; import android.support.annotation.RequiresApi; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.TextView; public class MainActivity extends AppCompatActivity {    TextView tvEvent;    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       ... Read More

How to get the build/version number of an iOS App?

Sadiqaadil
Updated on 11-Sep-2019 08:35:25

2K+ Views

In this post we will learn how to fetch and show the iOS build and version numberStep 1 − Open Xcode → New Project → Single View Application → Let’s name it “ShowBuildAndVersion”Step 2 − Open Main.storyboard and add two labels as shown below.Step 3 − Attach @IBOutLets for the two labels@IBOutlet weak var buildLabel: UILabel! @IBOutlet weak var versionLabel: UILabel!Step 4 − Change the build and version from project settings.Step 5 − In viewDidLoad of ViewController get the build and version number for infoDictionary of main bundle. Show it on the corresponding labels.override func viewDidLoad() {    super.viewDidLoad()   ... Read More

How do I create a transparent Activity in an Android App?

Azhar
Updated on 03-Jul-2020 12:37:06

2K+ Views

This example demonstrates how to create a transparent Activity 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/values/styles.xml.               #33000000       true       @android:color/transparent       @null       true       @android:style/Animation     Step 3  − Add the following code to res/layout/activity_main.xml.         Step 4  − Add the following code to src/MainActivity.javapackage com.example.transparentactivity; import android.support.v7.app.AppCompatActivity; ... Read More

How to get the Touch position on iOS device?

Sadiqaadil
Updated on 11-Sep-2019 08:30:35

815 Views

In this post we will be seeing how to get the touch position on device using Swift.So let’s get started.Step 1 − Open Xcode → New Project → Single View Application → Let’s name it “TouchMe”Step 2 − Open Main.storyboard and add one label as shown below. On this label we will show the touch position.Step 3 − Create @IBOutlet for the label, name it touchPositionLabel.Step 4 − We will be overriding the touchesBegan method in ViewController to get the touch position in the view. Override the method as shown belowoverride func touchesBegan(_ touches: Set, with event: UIEvent?) {   ... Read More

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

Sadiqaadil
Updated on 11-Sep-2019 08:25:16

560 Views

In this post we will be seeing how to get the battery state in iOS.So let’s get started.Step 1 − Open Xcode → New Project → Single View Application → Let’s name it “BatteryState”Step 2 − Open Main.storyboard and add two label as shown below. On this label we will show battery status.Step 3 − Enable the battery state monitoring, using the following code. You can put this code in viewDidLoad of ViewControllerUIDevice.current.isBatteryMonitoringEnabled = trueStep 4 − Declare a variable to hold the battery state. We will name this variable batteryState. From this variable we are returning UIDevice.current.batteryState, that would ... Read More

Advertisements