I wrote a very simple accessibilityService and i am trying to have the description of the service show up in Settings/accessibility/my app. Below is all my code which should set the description to "Hello!" but the settings still shows "no description available"
my service:
public class IdleService extends AccessibilityService{
int interval = 100;
int maxIdleTime = 20000;
int idleTime = 0;
Handler mHandler;
String cProcess;
@Override
public void onServiceConnected(){
mHandler = new Handler();
AccessibilityServiceInfo info = new AccessibilityServiceInfo();
// we are interested in all types of accessibility events
info.describeContents();
info.eventTypes = AccessibilityEvent.TYPES_ALL_MASK;
info.feedbackType = AccessibilityServiceInfo.FEEDBACK_GENERIC;
// we want to receive events in a certain interval
info.notificationTimeout = interval;
setServiceInfo(info);
Log.e("IdleService", " idle service connected!");
statusChecker.run();
}
@Override
public void onAccessibilityEvent(AccessibilityEvent arg0)
{
// TODO Auto-generated method stub
Log.v("IdleService", "reseting idle time");
idleTime = 0;
}
@Override
public void onInterrupt()
{
// TODO Auto-generated method stub
Log.v("IdleService", "INTERUPTED");
}
public void setMaxIdleTimeInSeconds(int time)
{
maxIdleTime = time *1000;
}
Runnable statusChecker = new Runnable()
{
@Override
public void run() {
// TODO Auto-generated method stub
ActivityManager am = (ActivityManager) getApplicationContext()
.getSystemService(Context.ACTIVITY_SERVICE);
List<ActivityManager.RunningTaskInfo> processList = am
.getRunningTasks(5);
cProcess = processList.get(0).baseActivity.getPackageName();
Log.v("IdleService", "Current PackageName:"+cProcess);
cProcess = processList.get(0).baseActivity.getClassName();
Log.v("IdleService", "Current ClassName:"+cProcess);
idleTime +=100;
Log.v("IdleService", "TICK TOCK, user Idle for:"+idleTime);
if(idleTime>=maxIdleTime)
{
Log.v("IdleService", "we timed out do to inactivity");
//mHandler.postDelayed(statusChecker, interval);
//stopSelf();
}else{
}
mHandler.postDelayed(statusChecker, interval);
}
};
}
in my manifest i have this for the service:
<service android:name="com.myPackage.IdleService"
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE">
<meta-data
android:name="android.accessibilityservice"
android:resource="@xml/accessibility_service_config" />
<intent-filter>
<action android:name="android.accessibilityservice.AccessibilityService" />
</intent-filter>
</service>
and in my res/xml i have an accessibility_service_config.xml file:
<accessibility-service xmlns:android="http://schemas.android.com/apk/res/android"
android:description="@string/accessibility_service_description"
android:settingsActivity="com.example.android.accessibility.ServiceSettingsActivity"
/>
and finally in my res/values/ i have strings.xml which looks like this:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="accessibility_service_description">Hello!</string>
</resources>