Search in sources :

Example 11 with Service

use of android.app.Service in project DroidPlugin by DroidPluginTeam.

the class ServcesManager method onTaskRemoved.

public void onTaskRemoved(Context context, Intent intent) throws Exception {
    Intent targetIntent = intent.getParcelableExtra(Env.EXTRA_TARGET_INTENT);
    if (targetIntent != null) {
        ServiceInfo info = PluginManager.getInstance().resolveServiceInfo(targetIntent, 0);
        Service service = mNameService.get(info.name);
        if (service == null) {
            handleCreateServiceOne(context, intent, info);
        }
        handleOnTaskRemovedOne(targetIntent);
    }
}
Also used : ServiceInfo(android.content.pm.ServiceInfo) Service(android.app.Service) Intent(android.content.Intent)

Example 12 with Service

use of android.app.Service in project DroidPlugin by DroidPluginTeam.

the class ServcesManager method handleOnBindOne.

private IBinder handleOnBindOne(Intent intent) throws Exception {
    ServiceInfo info = PluginManager.getInstance().resolveServiceInfo(intent, 0);
    if (info != null) {
        Service service = mNameService.get(info.name);
        if (service != null) {
            ClassLoader classLoader = getClassLoader(info.applicationInfo);
            intent.setExtrasClassLoader(classLoader);
            return service.onBind(intent);
        }
    }
    return null;
}
Also used : ServiceInfo(android.content.pm.ServiceInfo) Service(android.app.Service)

Example 13 with Service

use of android.app.Service in project DroidPlugin by DroidPluginTeam.

the class ServcesManager method handleOnRebindOne.

private void handleOnRebindOne(Intent intent) throws Exception {
    ServiceInfo info = PluginManager.getInstance().resolveServiceInfo(intent, 0);
    if (info != null) {
        Service service = mNameService.get(info.name);
        if (service != null) {
            ClassLoader classLoader = getClassLoader(info.applicationInfo);
            intent.setExtrasClassLoader(classLoader);
            service.onRebind(intent);
        }
    }
}
Also used : ServiceInfo(android.content.pm.ServiceInfo) Service(android.app.Service)

Example 14 with Service

use of android.app.Service in project DroidPlugin by DroidPluginTeam.

the class ServcesManager method handleOnStartOne.

private void handleOnStartOne(Intent intent, int flags, int startIds) throws Exception {
    ServiceInfo info = PluginManager.getInstance().resolveServiceInfo(intent, 0);
    if (info != null) {
        Service service = mNameService.get(info.name);
        if (service != null) {
            ClassLoader classLoader = getClassLoader(info.applicationInfo);
            intent.setExtrasClassLoader(classLoader);
            Object token = findTokenByService(service);
            Integer integer = mServiceTaskIds.get(token);
            if (integer == null) {
                integer = -1;
            }
            int startId = integer + 1;
            mServiceTaskIds.put(token, startId);
            int res = service.onStartCommand(intent, flags, startId);
            QueuedWorkCompat.waitToFinish();
        }
    }
}
Also used : ServiceInfo(android.content.pm.ServiceInfo) Service(android.app.Service)

Example 15 with Service

use of android.app.Service in project DroidPlugin by DroidPluginTeam.

the class ServcesManager method handleOnTaskRemovedOne.

private void handleOnTaskRemovedOne(Intent intent) throws Exception {
    if (VERSION.SDK_INT >= VERSION_CODES.ICE_CREAM_SANDWICH) {
        ServiceInfo info = PluginManager.getInstance().resolveServiceInfo(intent, 0);
        if (info != null) {
            Service service = mNameService.get(info.name);
            if (service != null) {
                ClassLoader classLoader = getClassLoader(info.applicationInfo);
                intent.setExtrasClassLoader(classLoader);
                service.onTaskRemoved(intent);
                QueuedWorkCompat.waitToFinish();
            }
            QueuedWorkCompat.waitToFinish();
        }
    }
}
Also used : ServiceInfo(android.content.pm.ServiceInfo) Service(android.app.Service)

Aggregations

Service (android.app.Service)25 ServiceInfo (android.content.pm.ServiceInfo)12 Intent (android.content.Intent)9 Handler (android.os.Handler)4 Context (android.content.Context)3 IBinder (android.os.IBinder)3 EventManager (roboguice.event.EventManager)3 SuppressLint (android.annotation.SuppressLint)2 Activity (android.app.Activity)2 AlarmManager (android.app.AlarmManager)2 Application (android.app.Application)2 IntentService (android.app.IntentService)2 BroadcastReceiver (android.content.BroadcastReceiver)2 IntentFilter (android.content.IntentFilter)2 SharedPreferences (android.content.SharedPreferences)2 Configuration (android.content.res.Configuration)2 Bitmap (android.graphics.Bitmap)2 NonNull (android.support.annotation.NonNull)2 TextUtils (android.text.TextUtils)2 Log (android.util.Log)2