Java源码示例:com.eveningoutpost.dexdrip.utils.LocationHelper
示例1
public void addListenerOnButton() {
button = (Button) findViewById(R.id.startNewSensor);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && DexCollectionType.hasBluetooth()) {
if (!LocationHelper.locationPermission(StartNewSensor.this)) {
LocationHelper.requestLocationForBluetooth(StartNewSensor.this);
} else {
sensorButtonClick();
}
} else {
sensorButtonClick();
}
}
});
}
示例2
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = ActivityThinJamBinding.inflate(getLayoutInflater());
binding.setVm(new ViewModel(this));
setContentView(binding.getRoot());
JoH.fixActionBar(this);
scanMeister.setFilter(customFilter);
scanMeister.allowWide().unlimitedMatches();
scanMeister.addCallBack2(this, TAG);
((TextView) findViewById(R.id.tjLogText)).setMovementMethod(new ScrollingMovementMethod());
// handle incoming extras - TODO do we need to wait for service connect?
final Bundle bundle = getIntent().getExtras();
processIncomingBundle(bundle);
LocationHelper.requestLocationForBluetooth(this);
}
示例3
public void addListenerOnButton() {
button = (Button) findViewById(R.id.startNewSensor);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && DexCollectionType.hasBluetooth()) {
if (!LocationHelper.locationPermission(StartNewSensor.this)) {
LocationHelper.requestLocationForBluetooth(StartNewSensor.this);
} else {
sensorButtonClick();
}
} else {
sensorButtonClick();
}
}
});
}
示例4
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = ActivityThinJamBinding.inflate(getLayoutInflater());
binding.setVm(new ViewModel(this));
setContentView(binding.getRoot());
JoH.fixActionBar(this);
scanMeister.setFilter(customFilter);
scanMeister.allowWide().unlimitedMatches();
scanMeister.addCallBack2(this, TAG);
((TextView) findViewById(R.id.tjLogText)).setMovementMethod(new ScrollingMovementMethod());
// handle incoming extras - TODO do we need to wait for service connect?
final Bundle bundle = getIntent().getExtras();
processIncomingBundle(bundle);
LocationHelper.requestLocationForBluetooth(this);
}
示例5
public void addListenerOnButton() {
button = (Button)findViewById(R.id.startNewSensor);
linkPickers = (CheckBox)findViewById(R.id.startSensorLinkPickers);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
linkPickers.setChecked(prefs.getBoolean("start_sensor_link_pickers", false));
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (!LocationHelper.locationPermission(StartNewSensor.this)) {
requestPermissions(new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, 0);
} else {
sensorButtonClick();
}
} else {
sensorButtonClick();
}
}
});
}
示例6
@Override
protected void onCreate(Bundle savedInstanceState) {
setTheme(R.style.OldAppTheme); // or null actionbar
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_bluetooth_scan);
final BluetoothManager bluetooth_manager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
bluetooth_adapter = bluetooth_manager.getAdapter();
mHandler = new Handler();
if (bluetooth_adapter == null) {
Toast.makeText(this, R.string.error_bluetooth_not_supported, Toast.LENGTH_LONG).show();
finish();
return;
}
if (!bluetooth_manager.getAdapter().isEnabled()) {
if (Pref.getBoolean("automatically_turn_bluetooth_on", true)) {
JoH.setBluetoothEnabled(getApplicationContext(), true);
Toast.makeText(this, "Trying to turn Bluetooth on", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(this, "Please turn Bluetooth on!", Toast.LENGTH_LONG).show();
}
} else {
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN_MR2) {
Toast.makeText(this, "The android version of this device is not compatible with Bluetooth Low Energy", Toast.LENGTH_LONG).show();
}
}
// Will request that GPS be enabled for devices running Marshmallow or newer.
LocationHelper.requestLocationForBluetooth(this);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
initializeScannerCallback();
mLeDeviceListAdapter = new LeDeviceListAdapter();
setListAdapter(mLeDeviceListAdapter);
}
示例7
@Override
protected void onResume() {
super.onResume();
if (LocationHelper.isLocationPermissionOk(this) && (JoH.ratelimit("auto-start-bt-scan", 20))) {
doScan();
}
}
示例8
@Override
protected void onCreate(Bundle savedInstanceState) {
setTheme(R.style.OldAppTheme); // or null actionbar
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_bluetooth_scan);
final BluetoothManager bluetooth_manager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
bluetooth_adapter = bluetooth_manager.getAdapter();
mHandler = new Handler();
if (bluetooth_adapter == null) {
Toast.makeText(this, R.string.error_bluetooth_not_supported, Toast.LENGTH_LONG).show();
finish();
return;
}
if (!bluetooth_manager.getAdapter().isEnabled()) {
if (Pref.getBoolean("automatically_turn_bluetooth_on", true)) {
JoH.setBluetoothEnabled(getApplicationContext(), true);
Toast.makeText(this, "Trying to turn Bluetooth on", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(this, "Please turn Bluetooth on!", Toast.LENGTH_LONG).show();
}
} else {
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN_MR2) {
Toast.makeText(this, "The android version of this device is not compatible with Bluetooth Low Energy", Toast.LENGTH_LONG).show();
}
}
// Will request that GPS be enabled for devices running Marshmallow or newer.
LocationHelper.requestLocationForBluetooth(this);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
initializeScannerCallback();
mLeDeviceListAdapter = new LeDeviceListAdapter();
setListAdapter(mLeDeviceListAdapter);
}
示例9
@Override
protected void onResume() {
super.onResume();
if (LocationHelper.isLocationPermissionOk(this) && (JoH.ratelimit("auto-start-bt-scan", 20))) {
doScan();
}
}
示例10
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_bluetooth_scan);
final BluetoothManager bluetooth_manager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
bluetooth_adapter = bluetooth_manager.getAdapter();
mHandler = new Handler();
if (bluetooth_adapter == null) {
Toast.makeText(this, R.string.error_bluetooth_not_supported, Toast.LENGTH_LONG).show();
finish();
return;
}
if (!bluetooth_manager.getAdapter().isEnabled()) {
Toast.makeText(this, "Bluetooth is turned off on this device currently", Toast.LENGTH_LONG).show();
} else {
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN_MR2) {
Toast.makeText(this, "The android version of this device is not compatible with Bluetooth Low Energy", Toast.LENGTH_LONG).show();
}
}
// Will request that GPS be enabled for devices running Marshmallow or newer.
LocationHelper.requestLocationForBluetooth(this);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
initializeScannerCallback();
mLeDeviceListAdapter = new LeDeviceListAdapter();
setListAdapter(mLeDeviceListAdapter);
}
示例11
private void checkLocationPermission() {
LocationHelper.requestLocationForEmergencyMessage(this);
}
示例12
private void checkLocationPermission() {
LocationHelper.requestLocationForEmergencyMessage(this);
}