i am developing a tv launcher i have setup accessibility so that each time the tvlauncher is called my applications is called instead .This works fine But if i unplug then replus the tv the android launcher is launched instead of my app. When i go to the Tv settings it seems that the accessbility settings has been disabled . SO how can i kke it activated even after reboot Here is my code
package com.ansetech.hotel.service;
import android.accessibilityservice.AccessibilityService;
import android.accessibilityservice.AccessibilityServiceInfo;
import android.content.ComponentName;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.view.accessibility.AccessibilityEvent;
import com.ansetech.hotel.activity.HomeActivity;
public class YourAccessibilityService extends AccessibilityService {
@Override
protected void onServiceConnected() {
super.onServiceConnected();
// Configure the service when connected
AccessibilityServiceInfo info = new AccessibilityServiceInfo();
info.eventTypes = AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED;
info.packageNames = new String[]{"com.google.android.tvlauncher"}; // Intercept launcher events
info.feedbackType = AccessibilityServiceInfo.FEEDBACK_GENERIC;
setServiceInfo(info);
}
@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) {
String packageName = String.valueOf(event.getPackageName());
if ("com.google.android.tvlauncher".equals(packageName) || "com.google.android.tungsten.setupwraith".equals(packageName)) {
// Launch your app when either the default launcher or setup wizard is launched
// || "com.mediatek.android.leanbacklauncher.partnercustomizer".equals(packageName)|| "com.mediatek.wwtv.setupwizard".equals(packageName)||"com.vestel.tv.eib".equals(packageName)||"com.vestel.speedup".equals(packageName)||"com.vestel.tvservice".equals(packageName)
Intent intent = new Intent();
intent.setComponent(new ComponentName("com.ansetech.hotel", "com.ansetech.hotel.activity.HomeActivity"));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
}
}
@Override
public void onTaskRemoved(Intent rootIntent) {
super.onTaskRemoved(rootIntent);
// Restart the service
Intent restartServiceIntent = new Intent(getApplicationContext(), this.getClass());
restartServiceIntent.setPackage(getPackageName());
startService(restartServiceIntent);
}
@Override
public void onInterrupt() {
// Called when the service is interrupted
}
}
i have tried to use Bootreceiver it launches the app after 10 seconds on the android interface and since the accessibility is not here if i press the homebutton it goes to the android launcher.
i was trying to use jobIntent but i don t know if i use it the correct way but it launch the app after 10 seconds