android - The method getinstance(Context) is undefined for the type AccessibilityManager -


i'm trying create own imagepreference use in app preferences in order pick picture user chooses represent himself.

i'm not sure i'm doing, i'm mimicking other preference classes. far i'm having trouble method:

public class imagepreference extends preference { ...     void sendaccessibilityevent(view view) {         // since view still not attached create, populate,         // , send event directly since not know when         // attached , posting commands not clean.         accessibilitymanager accessibilitymanager = accessibilitymanager.getinstance(getcontext());         if (msendclickaccessibilityevent && accessibilitymanager.isenabled()) {             accessibilityevent event = accessibilityevent.obtain();             event.seteventtype(accessibilityevent.type_view_clicked);             view.oninitializeaccessibilityevent(event);             view.dispatchpopulateaccessibilityevent(event);             accessibilitymanager.sendaccessibilityevent(event);         }         msendclickaccessibilityevent = false;     } 

i have copied code twostatepreference class. i'm not sure need method @ all, compiler complains saying accessibilitymanager class not contain getinstance method.

i thought problem imports, i'm importing same classes twostatepreference does, i.e.:

import android.view.accessibility.accessibilitymanager; 

i have lost several hours problem. idea of why compiler complaining?

thanks!

indeed, accessibilitymanager class has no method called getinstance(). from docs:

to obtain handle accessibility manager following:

accessibilitymanager accessibilitymanager =     (accessibilitymanager) context.getsystemservice(context.accessibility_service); 

so need context. lucky, you've got view, context, , holds references it's parent contexts.


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -