If i have a timer task inlined in a Service Class and the Service class has a public method.. how can i call the public method in my service class from the TimerTask?
class uiCheckTask extends TimerTask {
Boolean secDialog = false;
NavOverrideService myService;
public void run() {
try {
ActivityManager am = (ActivityManager) getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE);
List<ActivityManager.RunningAppProcessInfo> processList = am.getRunningAppProcesses();
String cProcess = processList.get(0).processName;
if (!cProcess.equals("com.example.services_test") && !secDialog) {
// myService.launchSecurity(); /// HELP HERE!
} else {
}
} catch(Exception ex) {
}
}
}
launchSecuity:
public void launchSecurity(){
Log.v("LAUNCHING", "((((((((((((((((((((SECURITY)))))))))))))))))");
Intent intent = new Intent(this, SecurityService.class);
startService(intent);
}
If the
uiCheckTaskis an inner class of yourService, then you can call the public method viaPlease note that
MyServiceis the class name of your service, not an instance or local variable.