can someone please guide me on how to record audio using an accessibility service any help would be greatly appreciated.
manifests.xml declaration
<service
android:name=".services.call.StartAccessibilityService"
android:enabled="true"
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE">
<intent-filter>
<action android:name="android.accessibilityservice.AccessibilityService" />
</intent-filter>
<meta-data
android:name="android.accessibilityservice"
android:resource="@xml/start_accessibility_service" />
</service>
kotlin code
class StartAccessibilityService : AccessibilityService() {
override fun onAccessibilityEvent(accessibilityEvent: AccessibilityEvent) {
if (accessibilityEvent.eventType == AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED) {
Log.d(TAG, "accessibilityEvent " +accessibilityEvent.eventType)
val instance = RecordingApplication.getInstance()
if (instance != null && !RecordingApplication.isServiceStarted()) {
RecordingApplication.getCallLog()?.let {
RecordingJobService.startRecording(instance, it)
RecordingApplication.setServiceStarted(true)
}
}
}
}
override fun onInterrupt() {}
companion object {
val TAG = StartAccessibilityService::class.java.name
}
}
xml/start_accessibility_service
<accessibility-service xmlns:android="http://schemas.android.com/apk/res/android"
android:accessibilityEventTypes="typeNotificationStateChanged"
android:accessibilityFeedbackType="feedbackSpoken|feedbackHaptic|feedbackAudible|feedbackVisual|feedbackGeneric|feedbackAllMask"
android:accessibilityFlags="flagDefault"
android:description="@string/acces_serv_description"
/>
from Record calls using accessibility service android 10
No comments:
Post a Comment