Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To answer your question: This does <em>not</em> seem possible in your case. Below I explain why.</p> <p>"The main purpose of an accessibility event is to expose enough information for an AccessibilityService to provide meaningful feedback to the user." In cases, such as yours:</p> <blockquote> <p>an accessibility service may need more contextual information then the one in the event pay-load. In such cases the service can obtain the event source which is an AccessibilityNodeInfo (snapshot of a View state) which can be used for exploring the window content. <em>Note that the privilege for accessing an event's source, thus the window content, has to be explicitly requested.</em> (See <a href="http://developer.android.com/reference/android/view/accessibility/AccessibilityEvent.html">AccessibilityEvent</a>)</p> </blockquote> <p>We can request this privilege explicitly by setting meta data for the service in your <em>android manifest file</em>:</p> <pre><code>&lt;meta-data android:name="android.accessibilityservice" android:resource="@xml/accessibilityservice" /&gt; </code></pre> <p>Where your xml file could look like:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;accessibility-service android:accessibilityEventTypes="typeNotificationStateChanged" android:canRetrieveWindowContent="true" /&gt; </code></pre> <p>We explicitly request the privilige for accessing an event's source (the window content) and we specify (using <code>accessibilityEventTypes</code>) the event types this service would like to receive (in your case only <code>typeNotificationStateChanged</code>). See <a href="http://developer.android.com/reference/android/R.styleable.html#AccessibilityService">AccessibilityService</a> for more options which you can set in the xml file.</p> <p><em>Normally</em> (see below why not in this case), it should be possible to call <code>event.getSource()</code> and obtain a <code>AccessibilityNodeInfo</code> and traverse through the window content, since "the accessibility event is sent by the topmost view in the view tree".</p> <p>While, it seems possible to get it working now, further reading in the <a href="http://developer.android.com/reference/android/view/accessibility/AccessibilityEvent.html">AccessibilityEvent</a> documentation tells us:</p> <blockquote> <p>If an accessibility service has not requested to retrieve the window content the event will not contain reference to its source. <strong>Also for events of type TYPE_NOTIFICATION_STATE_CHANGED the source is <em>never</em> available.</strong></p> </blockquote> <p>Apparently, this is because of security purposes...</p> <hr> <p>To hook onto how to extract the notifcation's message either from notification or notification.contentView / notification.contentIntent. I do not think you can. </p> <p>The contentView is a <a href="http://developer.android.com/reference/android/widget/RemoteViews.html">RemoteView</a> and does not provide any getters to obtain information about the notification. </p> <p>Similarly the contentIntent is a <a href="http://developer.android.com/reference/android/app/PendingIntent.html">PendingIntent</a>, which does not provide any getters to obtain information about the intent that will be launched when the notification is clicked. (i.e. you cannot obtain the extras from the intent for instance).</p> <p>Furthermore, since you have not provided any information on why you would like to obtain the description of the notification and what you would like to do with it, I cannot really supply you with a solution to solve this.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload