Code example for Context

Methods: getContentResolvergetSystemService

0
 
    private final ContentResolver mContentResolver;
    private final AudioManager mAudioManager;
 
    public ObscureSpeechDelegate(Context context) {
        mContentResolver = context.getContentResolver();
        mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
    } 
 
    @Override 
    public void sendAccessibilityEvent(View host, int eventType) {
        super.sendAccessibilityEvent(host, eventType);
 
        // Play the "headset required" announcement the first time the user 
        // places accessibility focus on a key. 
        if ((eventType == AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED)
                && !sAnnouncedHeadset && shouldObscureSpeech()) {
            sAnnouncedHeadset = true;
            host.announceForAccessibility(host.getContext().getString(
                    R.string.keyboard_headset_required_to_hear_password)); 
        }