android - How can I turn On and Off Accessibility Service programmably? -


manually can done going through settings menu ,but there api android exposes change setting through function call?

what want achieve disable talkback when app runs. more precise want disable explore touch feature of talkback.

so of these do

a)disable accessiblity service or
b)disable talkback or
c)disable talkback feature explore touch

a little late on one, perhaps someone.

in main class used intent accessibility service class. had on off switch pass boolean on whether or not wanted access

public class mainactivity extends appcompatactivity {  switch onoffswitch; intent serviceintent;  public void onoff(view view){     if(onoffswitch.ischecked()){         log.i("main switch", "turn on please");         serviceintent.putextra("onoffservice", true);     }     else{         log.i("main switch", "turn off please");         serviceintent.putextra("onoffservice", false);     }      this.startservice(serviceintent); } @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_main);      onoffswitch = (switch) findviewbyid(r.id.onoffswitch);     serviceintent= new intent(this, myservice.class);  } } 

then in myservice class receive intent onstartcommand. seemed work fine me.

@override public int onstartcommand(intent intent, int flags, int startid) {     onoffservice = intent.getbooleanextra("onoffservice", true);     return super.onstartcommand(intent, flags, startid); } 

i use boolean inside functions determine whether or not wanted service active. hope helps!


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -