2014-09-01 2 views
11

나는 외부 조력 도구를 통해 제공되는 음성 컨트롤과 컨트롤을 혼합하여 안드로이드를 탐색하는 데 도움이되는 접근성 응용 프로그램을 작성 중입니다. MonkeyTalk Java API를 사용하여 더 많은 작업을 수행합니다.
사용자에게 일어나는 일을 돕기 위해 사용자 보조 기능 서비스도 사용합니다. 사용자가 조치를 취할 수 있도록 알림을 읽습니다.페이스 북의 메신저 접근성

내가 메시지가 페이스 북의 메신저에 도착했을 때 그들은 오디오 큐를 얻을 수 없음을 통보, 내가 무엇을보고 로그를 확인하는 것은 봤는데 : 0 (AccessibilityEvent 이벤트에)

D/NotificationService(2665): package com.facebook.orcaText: [] 

event.getText().size() 돌아갑니다.
지금은 앱을 열고 텍스트를 읽어야합니다. 두 음성 명령이 더 있습니다 ...
다른 모든 알림이 올바르게 표시됩니다. 접근성에 대한 입장을 페이스 북에서 찾았지만 아무 것도 발견하지 못했습니다.
알림에서 텍스트를 가져 오는 방법이 있습니까?

답변

2

: 당신과 해당 설정을 열 수 있습니다. 그리고 이것이 작동하더라도, 더 나은 해결책을 기다리는 것이 좋습니다.

API 19 이상부터 Notification이 처음 생성되었을 때 개체가 번들로 extras - 입력이 Notification.Builder으로 전달됩니다. 따라서이 Bundle에서 Notification.EXTRAS_XXXX 키를 사용하여 title, context, summary 등과 같은 정보를 추출 할 수 있습니다. 키는 여기에서 찾을 수 있습니다 : Link. 재정의 onAccessibilityEvent(AccessibilityEvent event) 방법에

:

@Override 
public void onAccessibilityEvent(AccessibilityEvent event) { 
    Parcelable data = event.getParcelableData(); 

    if (data != null && data instanceof Notification) { 
     Log.i("", "We have a notification to parse"); 

     Notification notification = (Notification) data; 

     // For API 19 and above, `Notifications` carry an `extras` bundle with them 
     // From this bundle, you can extract info such as: 

     //  `EXTRA_TITLE`  - as supplied to setContentTitle(CharSequence) 
     //  `EXTRA_TEXT `  - as supplied to setContentText(CharSequence) 
     //  `EXTRA_INFO_TEXT` - as supplied to setContentInfo(CharSequence) 
     //  ... more at: http://developer.android.com/reference/android/app/Notification.html 

     Bundle b = noti.extras; 
     Log.i("Notification", "Title: " + b.get(Notification.EXTRA_TITLE)); 
     Log.i("Notification", "Text: " + b.get(Notification.EXTRA_TEXT)); 
     Log.i("Notification", "Info Text: " + b.get(Notification.EXTRA_INFO_TEXT)); 

     ///////////////////////////////////////////////////////////////// 

     // For API 18 and under: 

     // Pass `notification` to a method that parses a Notification object - See link below 

     List<String> notificationText = extractTextFromNotification(notification); 
     .... 
     .... 
    } 
} 

extractTextFromNotification(Notification) 여기에서 방법 일 수있다 : Link. 말할 필요도없이이 방법이 해결책이며 필요에 따라 작동하는지 테스트하기 위해 많은 테스트가 필요합니다.

+0

지금 우리는 api19 +를 사용하므로 정말 좋습니다. 앞으로는 오래된 전화기를 지원할 것입니다. 아마도 풍선을 사용하는 뷰 트릭을 사용할 것입니다. – sokie

+1

추가 필드는 완벽하게 작동하는 것으로 판명되었습니다! 나머지 알림 메시지에도 지금 사용하고 있습니다. 감사합니다! – sokie

+0

@sokie'나머지 알림 메시지에도 지금 사용하고 있습니다 .' 굉장해! 네가 그 일을하도록 권유 한 것을 생각하지 않았다. – Vikram

0

getActiveNotifications 메서드를 NotificationListenerService으로 사용하면 현재 사용자에게 표시되는 알림 배열을 가져올 수 있습니다. 결과는 StatusBarNotification 배열입니다, 그래서 당신은

당신은 NotificationListenerService을 확장 할 수 있습니다 ... getPackageName로에 PackageName을 읽고 당신이 찾고있는 그와 일치하는 경우, 다음 (getNotification에) 해당 객체 알림 내용을 얻을 수 있습니다 클래스와 서비스로 등록 :

<service android:name=".NotificationListener" 
     android:label="@string/service_name" 
     android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE"> 
<intent-filter> 
    <action android:name="android.service.notification.NotificationListenerService" /> 
</intent-filter> 
</service> 

은 또한 알림을받을 onNotificationPosted 방법을 구현하고, 심지어 cancelNotification 방법 알림을 취소 할 수 있습니다.

이 서비스를 사용하는 예 : https://github.com/kpbird/NotificationListenerService-Example

: 사용자는 "설정> 보안> 알림 접근"에서 통지 권한을 사용하도록 설정해야합니다. 당신이 페이스 북 메신저 알림과 함께 작동하는지 확인하기 위해 시도 할 수

Intent intent=new Intent("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS"); 
startActivity(intent); 
+0

여전히 페이스 북의 메신저에는 공백이 반환됩니다. – sokie

+0

사용한 코드를 게시하십시오. – semsamot

+0

페이스 북의 메신저로이 코드를 사용해 보셨습니까? 나는 다른 어떤 통보든지 접근하는 아무 문제도 없다, 공백을 돌려 보내는 유일한 것은 facebook 메신저이다. – sokie

관련 문제