本文整理汇总了Java中android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS属性的典型用法代码示例。如果您正苦于以下问题:Java Settings.ACTION_LOCATION_SOURCE_SETTINGS属性的具体用法?Java Settings.ACTION_LOCATION_SOURCE_SETTINGS怎么用?Java Settings.ACTION_LOCATION_SOURCE_SETTINGS使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.provider.Settings
的用法示例。
在下文中一共展示了Settings.ACTION_LOCATION_SOURCE_SETTINGS属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sendNotification
private void sendNotification(String s) {
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this);
mBuilder.setSmallIcon(R.drawable.logo);
mBuilder.setContentTitle("Event-Me");
mBuilder.setContentText(s);
Intent i = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
i.putExtra("from","notif");
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, i,
PendingIntent.FLAG_UPDATE_CURRENT);
mBuilder.setContentIntent(contentIntent);
NotificationManager mNotificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(001, mBuilder.build());
}
示例2: onConnected
@SuppressWarnings("MissingPermission")
@Override
public void onConnected(@Nullable Bundle bundle) {
mLocationRequest = LocationRequest.create();
mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
mLocationRequest.setInterval(1000); // Intervals millis
mLocationRequest.setFastestInterval(500); //If avaible sooner
if (!isPermissionGranted(this, Manifest.permission.ACCESS_FINE_LOCATION)) {
return;
}
if (!checkGPSisOpen()) {
Toast.makeText(this, "Enable location services for accurate data.", Toast.LENGTH_SHORT)
.show();
Intent viewIntent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
startActivity(viewIntent);
} else {
LocationServices.FusedLocationApi
.requestLocationUpdates(mGoogleApiClient, mLocationRequest, this);
mLocation = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient);
getCoords(LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient));
}
}
示例3: startMap
private void startMap(){
if( isLocationEnable() ){
mapFragment.getMapAsync( this );
}else{
Intent myIntent = new Intent( Settings.ACTION_LOCATION_SOURCE_SETTINGS );
startActivity( myIntent );
}
}
示例4: startGPSSetting
/**
* 打开gps设置
*/
public static void startGPSSetting() {
// 转到手机设置界面,用户设置GPS
Intent intent = new Intent(
Settings.ACTION_LOCATION_SOURCE_SETTINGS);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
UtilManager.getContext().startActivity(intent);
}
示例5: onGPS
/**
* Opens GPS settings to allow user turn GPS on.
*/
@Override
public void onGPS() {
Intent gpsIntent = new Intent(
Settings.ACTION_LOCATION_SOURCE_SETTINGS
);
startActivityForResult(gpsIntent, gpsReqCode);
}
示例6: onCreate
/**
* On create, check if the user has location enabled.
* Obtain the MapFragment and get notified when the map is ready to be used.
* @param savedInstanceState
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
// Obtain the MapFragment and get notified when the map is ready to be used.
MapFragment mapFragment = (MapFragment) getFragmentManager().findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
options = (Button) findViewById(R.id.map_options);
mFusedLocationClient = LocationServices.getFusedLocationProviderClient(this);
try {
toDisplayAL = (ArrayList<Markers>) getIntent().getExtras().getSerializable("toDisplay");
} catch (Exception e) {
// no events to display
}
// If GPS (location) is not enabled, User is sent to the settings to turn it on!
service = (LocationManager) getSystemService(LOCATION_SERVICE);
boolean enabled = service.isProviderEnabled(LocationManager.GPS_PROVIDER);
if (!enabled) {
Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
startActivity(intent);
} else {
getDeviceLoc();
}
options.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
finish();
}
});
}
示例7: openGpsSettings
/**
* 打开Gps设置界面
*/
public static void openGpsSettings() {
Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Utils.getContext().startActivity(intent);
}
示例8: onCreate
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) {
Toast.makeText(this, R.string.ble_not_supported, Toast.LENGTH_LONG).show();
mBleSupported = false;
}
mBluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
mBtAdapter = mBluetoothManager.getAdapter();
if (mBtAdapter == null || !mBtAdapter.isEnabled()) {
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (this.checkCallingOrSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("This app needs location access");
builder.setMessage("Please grant location access so this app can detect beacons.");
builder.setPositiveButton(android.R.string.ok, null);
builder.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
requestPermissions(new String[]{Manifest.permission.ACCESS_COARSE_LOCATION}, PERMISSION_REQUEST_COARSE_LOCATION);
}
}
});
builder.show();
} else {
if(isLocationProviderEnabled((LocationManager) getSystemService(Context.LOCATION_SERVICE))) {
initBluManager();
}else{
Intent myIntent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
startActivityForResult(myIntent, REQUEST_ENABLE_LOCATION);
}
}
} else if (savedInstanceState == null && mBleSupported) {
initBluManager();
} else {
//Error TODO
}
}
示例9: goToGpsSettings
/**
* Redirect user to enable GPS
*/
public void goToGpsSettings() {
Intent callGPSSettingIntent = new Intent(
Settings.ACTION_LOCATION_SOURCE_SETTINGS);
mContext.startActivity(callGPSSettingIntent);
}
示例10: onProviderDisabled
@Override
public void onProviderDisabled(String provider) {
Intent i = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
startActivity(i);
}
示例11: onSelected
@Override
public void onSelected(int buttonIndex) {
Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
mActivity.startActivity(intent);
}
示例12: requestLocationEnabling
public static void requestLocationEnabling(@NonNull Activity activity) {
Log.d(TAG, "Requesting location enabling");
Intent locationSettings = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
activity.startActivity(locationSettings);
}
示例13: onProviderDisabled
@Override
public void onProviderDisabled(String provider) {
// TODO Auto-generated method stub
/*************************************Notify***************************************/
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this);
Intent resultIntent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
stackBuilder.addParentStack(Location_event.class);
stackBuilder.addNextIntent(resultIntent);
PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(02,PendingIntent.FLAG_UPDATE_CURRENT);
mBuilder.setContentIntent(resultPendingIntent);
mBuilder.setSmallIcon(R.drawable.findx_logo);
mBuilder.setContentTitle("digiPune Disconnected");
mBuilder.setContentText("Please turn on Location");
mBuilder.addAction(R.drawable.ic_action_settings, "Settings", resultPendingIntent);
// Adds the Intent that starts the Activity to the top of the stack
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
// notificationID allows you to update the notification later on.
mNotificationManager.notify(0, mBuilder.build());
/*************************************Notify***************************************/
}
示例14: startLocationSettings
/**
* 或要去开启结果,必须实现startActivityForResult
*
* @param context
* @param requestCode
*/
public static void startLocationSettings(Activity context, int requestCode) {
Intent enableLocationIntent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
context.startActivityForResult(enableLocationIntent, requestCode);
}
示例15: openGps
/**
* 打开 Gps 系统设置页面
*
* @param activity
* @param requestCode 请传入 {@link BluetoothUtils#REQUEST_CODE_GPS} 常量
*/
public static void openGps(Activity activity, int requestCode) {
Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
activity.startActivityForResult(intent, requestCode);
}