Showing posts with label settings. Show all posts
Showing posts with label settings. Show all posts

Sunday, November 09, 2014

Tip - Redirecting Users to the Setting Page (iOS 8)

In iOS, you often need to redirect the user to the Settings page. For example, if you detected that the user has turned off WiFi and your application needs to access the Internet using WiFi, you might want to automatically launch the Settings page so that the user can turn on the WiFi directly. In iOS 8, you can do so via the UIApplicationOpenSettingsURLString constant, like this:

        if UIApplicationOpenSettingsURLString != nil {
            var appSettings = NSURL(string: UIApplicationOpenSettingsURLString)
            UIApplication.sharedApplication().openURL(appSettings!)
        }


The above code snippet will redirect the user to the Settings page. 

Sunday, July 21, 2013

Windows Phone Tip: Using Schemes to Launch Settings Pages

Due to security reasons, your Windows Phone application is not allowed to modify some of the device’s settings directly. For example, you might want to programmatically turn on the airplane mode on the device. However, this is not allowed without the user’s explicit permission. The only way to turn on airplane mode is for the user to navigate to the Settings’s Airplane Mode page and turn it on manually.

In your application, instead of asking the user to navigate to the Settings page, you can directly bring them to the page, programmatically.

To launch the various Settings pages, you can use the Launcher class with the LaunchUriAsync() method. As you are launching the pages asynchronously, you need to wrap these calls in a async method, like this:

        private async void LaunchSettings(int mode)
        {
            switch (mode)
            {
                case 0: await Launcher.LaunchUriAsync(
                    new Uri("ms-settings-airplanemode:"));
                    break;
                case 1: await Launcher.LaunchUriAsync(
                    new Uri("ms-settings-bluetooth:"));
                    break;
                case 2: await Launcher.LaunchUriAsync(
                    new Uri("ms-settings-cellular:"));
                    break;
                case 3: await Launcher.LaunchUriAsync(
                    new Uri("ms-settings-wifi:"));
                    break;
                case 4: await Launcher.LaunchUriAsync(
                    new Uri("ms-settings-location:"));
                    break;
                case 5: await Launcher.LaunchUriAsync(
                    new Uri("ms-settings-emailandaccounts:"));
                    break;
                case 6: await Launcher.LaunchUriAsync(
                    new Uri("ms-settings-lock:"));
                    break;
            }
        }


The following figure shows the Airplane Mode settings page:

Saturday, June 01, 2013

Android Tip: Programmatically Displaying the Settings Page


Many a times, you need to programmatically redirect the user to the Settings page so that they can turn on certain features on the device before your application can work correctly For example, if your app uses Bluetooth and the Bluetooth radio is not turned on, you may want to programmatically display the Bluetooth settings page so that the user can turn it on.

Solution

To display the Settings page programmatically, you can use the startActivity() method together with an Intent object. The following shows some examples:

    //---display the main Settings page---
    startActivity(
        new Intent(Settings.ACTION_SETTINGS));
        
    //---display the Location access settings page---
    startActivity(new Intent(
        Settings.ACTION_LOCATION_SOURCE_SETTINGS));
                
    //---display the Wireless & networks settings page---
    startActivity(new Intent(
        Settings.ACTION_AIRPLANE_MODE_SETTINGS));
        
    //---display the Bluetooth settings page---
    startActivity(new Intent(
        Settings.ACTION_BLUETOOTH_SETTINGS));
        
        In general, you use the predefined constant Settings.ACTION__SETTINGS. The full list can be found here: http://developer.android.com/reference/android/provider/Settings.html