Java Code Examples for android.app.Service#getClass()

The following examples show how to use android.app.Service#getClass() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ServiceManager.java    From BigApp_Discuz_Android with Apache License 2.0 6 votes vote down vote up
public void startService(final Context context, final Service... services) {

        Thread serviceThread = new Thread(new Runnable() {
            @Override
            public void run() {
                for (Service s : services) {

                    if (!ServiceUtils.isServiceRunning(context, s.getClass()
                            .getName())) {

                        Intent i = new Intent(context, s.getClass());
                        context.startService(i);

                        ZogUtils.printLog(ServiceManager.class,
                                "start service " + s.getClass().getName());
                    }

                }
            }
        });
        serviceThread.start();
    }
 
Example 2
Source File: PluginServiceClient.java    From springreplugin with Apache License 2.0 5 votes vote down vote up
/**
 * 在插件服务中停止服务。近似于Service.stopSelf
 * 注意:此方法应在插件服务中被调用
 *
 * @param s 要停止的插件服务
 * @see android.app.Service#stopSelf()
 */
public static void stopSelf(Service s) {
    Intent intent = new Intent(s, s.getClass());
    try {
        PluginMgrFacade.stopService(intent);
    } catch (Throwable e) {
        if (LOGR) {
            LogRelease.e(PLUGIN_TAG, "pss.ss: pf f", e);
        }
    }
}
 
Example 3
Source File: ServiceManager.java    From BigApp_Discuz_Android with Apache License 2.0 5 votes vote down vote up
public void stopService(final Context context, final Service... services) {
    for (Service s : services) {
        Intent service = new Intent(context, s.getClass());
        context.stopService(service);
    }

}
 
Example 4
Source File: ServiceManager.java    From BigApp_Discuz_Android with Apache License 2.0 5 votes vote down vote up
public void restartService(final Context context, final Service... services) {
    System.out.println("ServiceManager restartService");
    stopService(context, services);

    for (Service s : services) {
        Intent service = new Intent(context, s.getClass());
        context.startService(service);
    }

}
 
Example 5
Source File: WatchFaceStyle.java    From AndroidWear-OpenWear with MIT License 4 votes vote down vote up
public Builder(Service service) {
    this(new ComponentName(service, service.getClass()));
}