Go to the gps setting page - Android Hardware

Android examples for Hardware:Gps

Description

Go to the gps setting page

Demo Code


//package com.java2s;

import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;

import android.provider.Settings;

public class Main {
    /**/*from   w  w  w.j  a  v a  2s .  c om*/
     * Go to the gps setting page
     *
     * @param context Context
     */
    public static void openGPSSetting(Context context) {
        Intent intent = new Intent();
        intent.setAction(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        try {
            context.startActivity(intent);
        } catch (ActivityNotFoundException ex) {
            intent.setAction(Settings.ACTION_SETTINGS);
            try {
                context.startActivity(intent);
            } catch (ActivityNotFoundException e) {
                e.printStackTrace();
            }
        }
    }
}

Related Tutorials