Skip to content

Instantly share code, notes, and snippets.

View MrCrambo's full-sized avatar
🏓
Win the world

mrcrambo MrCrambo

🏓
Win the world
  • Russia
View GitHub Profile
public void registerScanResultsCallback (Executor executor,
WifiManager.ScanResultsCallback callback);
public List<ScanResult> getScanResults ();
public void unregisterScanResultsCallback (WifiManager.ScanResultsCallback callback);
<manifest>
<!-- Grants the READ_PHONE_STATE permission only on devices that run
Android 10 (API level 29) and lower. -->
<uses-permission android:name="READ_PHONE_STATE"
android:maxSdkVersion="29" />
<uses-permission android:name="READ_PHONE_NUMBERS" />
</manifest>
public Set<Set<String>> getConcurrentCameraIds ();
public boolean isConcurrentSessionConfigurationSupported (Map<String, SessionConfiguration> cameraIdAndSessionConfig);
suspend fun fetchUser(): User {
return GlobalScope.async(Dispatchers.IO) {
// make network call
}.await()
}
<manifest>
...
<service ...
android:foregroundServiceType="location|camera|microphone" />
</manifest>
var locationManager: CLLocationManager = {
let locationManager = CLLocationManager()
locationManager.delegate = self
locationManager.allowsBackgroundLocationUpdates = true
return locationManager
}()
var region:CLBeaconRegion {
let region = CLBeaconRegion(proximityUUID: uuid, identifier: identifier)
region.notifyEntryStateOnDisplay = true
/*
For BLUETOOTH scans.
Create CBCentralManager class element and call its method for scanning Bluetooth devices.
Here is the function declaration
*/
func scanForPeripherals(withServices serviceUUIDs: [CBUUID]?, options: [String : Any]? = nil)
/*
For BEACONS scan.
/*
For BLUETOOTH scans.
Create CBCentralManager class element and call its method for scanning Bluetooth devices.
Here is the function declaration
*/
func scanForPeripherals(withServices serviceUUIDs: [CBUUID]?, options: [String : Any]? = nil)
/*
For BEACONS scan.
func getWiFiName() -> String? {
var ssid: String?
if let interfaces = CNCopySupportedInterfaces() as NSArray? {
for interface in interfaces {
if let interfaceInfo = CNCopyCurrentNetworkInfo(interface as! CFString) as NSDictionary? {
ssid = interfaceInfo[kCNNetworkInfoKeySSID as String] as? String
break
}
}
}
private static final Intent[] POWERMANAGER_INTENTS = {
new Intent().setComponent(new ComponentName("com.miui.securitycenter", "com.miui.permcenter.autostart.AutoStartManagementActivity")),
new Intent().setComponent(new ComponentName("com.letv.android.letvsafe", "com.letv.android.letvsafe.AutobootManageActivity")),
new Intent().setComponent(new ComponentName("com.huawei.systemmanager", "com.huawei.systemmanager.startupmgr.ui.StartupNormalAppListActivity")),
new Intent().setComponent(new ComponentName("com.huawei.systemmanager", "com.huawei.systemmanager.optimize.process.ProtectActivity")),
new Intent().setComponent(new ComponentName("com.huawei.systemmanager", "com.huawei.systemmanager.appcontrol.activity.StartupAppControlActivity")),
new Intent().setComponent(new ComponentName("com.coloros.safecenter", "com.coloros.safecenter.permission.startup.StartupAppListActivity")),
new Intent().setComponent(new ComponentName("com.coloros.safecenter", "com.coloros.safecenter.startupapp.Startup