如果我在服务类中有一个内联的计时器任务,并且服务类有一个公共方法。我如何从 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) {
}
}
}
启动安全:
public void launchSecurity(){
Log.v("LAUNCHING", "((((((((((((((((((((SECURITY)))))))))))))))))");
Intent intent = new Intent(this, SecurityService.class);
startService(intent);
}