I'm trying to implement accessibility feature in my app. I'm confused about how it actually works. I've a simple imageView in different package from where I send events as:
public final void onClick(final android.view.View v) {
android.util.Log.v(CLASSNAME,"onClick tag:"+v.getTag());
v.sendAccessibilityEvent(android.view.accessibility.AccessibilityEvent.TYPE_VIEW_CLICKED);
I've implmented Accessibility class as follows:
import android.content.Context;
public final class Accessibility extends android.view.View {
public Accessibility(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
public static android.view.accessibility.AccessibilityManager manager = (android.view.accessibility.AccessibilityManager)getSystemService(android.content.Context.ACCESSIBILITY_SERVICE);
public static android.view.accessibility.AccessibilityEvent event = android.view.accessibility.AccessibilityEvent.obtain();
public static Accessibility accessibility;
public static boolean isEenabled()
{
if(manager.isEnabled())
return true;
else
return false;
}
@Override
public boolean dispatchPopulateAccessibilityEvent(android.view.accessibility.AccessibilityEvent event)
{
super.dispatchPopulateAccessibilityEvent(event);
android.util.Log.e(CLASSNAME, "Came here");
{
event.getText().add("Click here!!");
event.setEnabled(true);
return true;
}
I read the Developer docs and I have to override the method in View class (that's the reason I extended my class to View). I realized this method also exists in Activity class (i.e. extends Activity) which calls this method without even sending any events.
I know I'm doing something silly, but not able to find where exactly.
P.S.: I did set a breakpoint on v.sendAccessibilityEvent - It goes to View.java and somehow it fails at condition "AccessibilityManager.getInstance(mContext)!= null"