當前位置: 首頁>>代碼示例>>Java>>正文


Java AccessibilityEvent.setPackageName方法代碼示例

本文整理匯總了Java中android.view.accessibility.AccessibilityEvent.setPackageName方法的典型用法代碼示例。如果您正苦於以下問題:Java AccessibilityEvent.setPackageName方法的具體用法?Java AccessibilityEvent.setPackageName怎麽用?Java AccessibilityEvent.setPackageName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.view.accessibility.AccessibilityEvent的用法示例。


在下文中一共展示了AccessibilityEvent.setPackageName方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: dispatchPopulateAccessibilityEvent

import android.view.accessibility.AccessibilityEvent; //導入方法依賴的package包/類
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
    event.setClassName(getClass().getName());
    event.setPackageName(getPackageName());

    LayoutParams params = getWindow().getAttributes();
    boolean isFullScreen = (params.width == LayoutParams.MATCH_PARENT) &&
            (params.height == LayoutParams.MATCH_PARENT);
    event.setFullScreen(isFullScreen);

    CharSequence title = getTitle();
    if (!TextUtils.isEmpty(title)) {
        event.getText().add(title);
    }

    return true;
}
 
開發者ID:JessYanCoding,項目名稱:ProgressManager,代碼行數:17,代碼來源:a.java

示例2: announceForAccessibility

import android.view.accessibility.AccessibilityEvent; //導入方法依賴的package包/類
/**
 * Sends the specified text to the {@link AccessibilityManager} to be
 * spoken.
 *
 * @param view The source view.
 * @param text The text to speak.
 */
public void announceForAccessibility(final View view, final CharSequence text) {
    if (!mAccessibilityManager.isEnabled()) {
        Log.e(TAG, "Attempted to speak when accessibility was disabled!");
        return;
    }

    // The following is a hack to avoid using the heavy-weight TextToSpeech
    // class. Instead, we're just forcing a fake AccessibilityEvent into
    // the screen reader to make it speak.
    final AccessibilityEvent event = AccessibilityEvent.obtain();

    event.setPackageName(PACKAGE);
    event.setClassName(CLASS);
    event.setEventTime(SystemClock.uptimeMillis());
    event.setEnabled(true);
    event.getText().add(text);

    // Platforms starting at SDK version 16 (Build.VERSION_CODES.JELLY_BEAN) should use
    // announce events.
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        event.setEventType(AccessibilityEventCompat.TYPE_ANNOUNCEMENT);
    } else {
        event.setEventType(AccessibilityEvent.TYPE_VIEW_FOCUSED);
    }

    final ViewParent viewParent = view.getParent();
    if ((viewParent == null) || !(viewParent instanceof ViewGroup)) {
        Log.e(TAG, "Failed to obtain ViewParent in announceForAccessibility");
        return;
    }

    viewParent.requestSendAccessibilityEvent(view, event);
}
 
開發者ID:sergeychilingaryan,項目名稱:AOSP-Kayboard-7.1.2,代碼行數:41,代碼來源:AccessibilityUtils.java

示例3: createEventForChild

import android.view.accessibility.AccessibilityEvent; //導入方法依賴的package包/類
private AccessibilityEvent createEventForChild(int virtualViewId, int eventType) {
    AccessibilityEvent event = AccessibilityEvent.obtain(eventType);
    event.setEnabled(true);
    event.setClassName(DEFAULT_CLASS_NAME);
    onPopulateEventForVirtualView(virtualViewId, event);
    if (event.getText().isEmpty() && event.getContentDescription() == null) {
        throw new RuntimeException("Callbacks must add text or a content description in populateEventForVirtualViewId()");
    }
    event.setPackageName(this.mView.getContext().getPackageName());
    AccessibilityEventCompat.asRecord(event).setSource(this.mView, virtualViewId);
    return event;
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:13,代碼來源:ExploreByTouchHelper.java

示例4: onInitializeAccessibilityEvent

import android.view.accessibility.AccessibilityEvent; //導入方法依賴的package包/類
@Override
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
    if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) {
        // Action mode started
        //TODO event.setSource(this);
        event.setClassName(getClass().getName());
        event.setPackageName(getContext().getPackageName());
        event.setContentDescription(mTitle);
    } else {
        //TODO super.onInitializeAccessibilityEvent(event);
    }
}
 
開發者ID:treasure-lau,項目名稱:CSipSimple,代碼行數:13,代碼來源:ActionBarContextView.java

示例5: sendAccessibilityEventForVirtualButton

import android.view.accessibility.AccessibilityEvent; //導入方法依賴的package包/類
private void sendAccessibilityEventForVirtualButton(int virtualViewId, int eventType,
                                                    String text) {
    AccessibilityManager accessibilityManager = (AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
    if (accessibilityManager.isEnabled()) {
        AccessibilityEvent event = AccessibilityEvent.obtain(eventType);
        AccessibilityRecordCompat record = AccessibilityEventCompat.asRecord(event);
        event.setPackageName(getContext().getPackageName());
        record.setClassName(Button.class.getName());
        record.getText().add(text);
        record.setEnabled(isEnabled());
        record.setSource(mNumberPicker, virtualViewId);

        ViewParentCompat.requestSendAccessibilityEvent(mNumberPicker, mNumberPicker, event);
    }
}
 
開發者ID:h6ah4i,項目名稱:android-numberpickercompat,代碼行數:16,代碼來源:AccessibilityNodeProviderImpl.java

示例6: sendAccessibilityEventForVirtualButton

import android.view.accessibility.AccessibilityEvent; //導入方法依賴的package包/類
private void sendAccessibilityEventForVirtualButton(int virtualViewId, int eventType,
                                                    String text) {
    //if (AccessibilityManager.getInstance(mContext).isEnabled()) {
    if (accessibilityManager != null && accessibilityManager.isEnabled()) {
        AccessibilityEvent event = AccessibilityEvent.obtain(eventType);
        event.setClassName(Button.class.getName());
        event.setPackageName(getContext().getPackageName());
        event.getText().add(text);
        event.setEnabled(NumberPicker.this.isEnabled());
        AccessibilityRecordCompat.setSource(event, NumberPicker.this, virtualViewId);
        //event.setSource(NumberPicker.this, virtualViewId);
        requestSendAccessibilityEvent(NumberPicker.this, event);
    }
}
 
開發者ID:Gericop,項目名稱:DateTimePicker,代碼行數:15,代碼來源:NumberPicker.java

示例7: onInitializeAccessibilityEvent

import android.view.accessibility.AccessibilityEvent; //導入方法依賴的package包/類
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
    if (VERSION.SDK_INT < 14) {
        return;
    }
    if (event.getEventType() == 32) {
        event.setSource(this);
        event.setClassName(getClass().getName());
        event.setPackageName(getContext().getPackageName());
        event.setContentDescription(this.mTitle);
        return;
    }
    super.onInitializeAccessibilityEvent(event);
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:14,代碼來源:ActionBarContextView.java


注:本文中的android.view.accessibility.AccessibilityEvent.setPackageName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。