This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@objc func proximityStateDidChange(notification: Notification) { | |
if let device = notification.object as? UIDevice { | |
let currentProximityState = device.proximityState | |
// true: user is close to the device; false: vice versa | |
print("currentProximityState: \(currentProximityState ? "near" : "far")") | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SharingActivity : AppCompatActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_sharing) | |
val isActivityLaunchedFromActionSend = intent?.action == Intent.ACTION_SEND | |
val isImageData = intent.type?.startsWith("image/") == true | |
if (isActivityLaunchedFromActionSend && isImageData) { | |
handleSendImage(intent) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"mAccurancy": 281.71, | |
"mProvider": "gps" | |
... | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val insertCalendarIntent = Intent(Intent.ACTION_INSERT) | |
.setData(CalendarContract.Events.CONTENT_URI) | |
.putExtra(... , ...) | |
startActivity(insertCalendarIntent) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<FrameLayout | |
xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:tools="http://schemas.android.com/tools" | |
... | |
android:id="@+id/backgroundFrameLayout" | |
android:padding="16dp"> | |
<TextView | |
... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<shape xmlns:android="http://schemas.android.com/apk/res/android"> | |
<size android:height="6dp"/> | |
</shape> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override func viewWillDisappear(_ animated: Bool) { | |
super.viewWillDisappear(animated) | |
// Solution: Stop speaking to prevent blocking of ViewControler deinitialization | |
avSpeechSynthesizer.stopSpeaking(at: .immediate) | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import AVFoundation | |
class AVFoundataionDemoViewController: BaseViewController { | |
var avSpeechSynthesizer: AVSpeechSynthesizer! | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
avSpeechSynthesizer = AVSpeechSynthesizer() | |
avSpeechSynthesizer.speak(AVSpeechUtterance(string: "Hello world")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Short form: en (English) | |
let voice = AVSpeechSynthesisVoice(language: "en") | |
// Long form: en-AU (Australia English) | |
let voice = AVSpeechSynthesisVoice(language: "en-AU") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let avSpeechSynthesizer = AVSpeechSynthesizer() | |
... | |
avSpeechSynthesizer.stopSpeaking(at: .immediate) |
NewerOlder