本文整理汇总了Java中android.app.Service.onStartCommand方法的典型用法代码示例。如果您正苦于以下问题:Java Service.onStartCommand方法的具体用法?Java Service.onStartCommand怎么用?Java Service.onStartCommand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.app.Service
的用法示例。
在下文中一共展示了Service.onStartCommand方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleOnStartOne
import android.app.Service; //导入方法依赖的package包/类
private void handleOnStartOne(Intent intent, int flags, int startIds) throws Exception {
ServiceInfo info = ApkManager.getInstance().resolveServiceInfo(intent, 0);
if (info != null) {
Service service = (Service) this.mNameService.get(info.name);
if (service != null) {
intent.setExtrasClassLoader(getClassLoader(info.applicationInfo));
Object token = findTokenByService(service);
Integer integer = (Integer) this.mServiceTaskIds.get(token);
if (integer == null) {
integer = Integer.valueOf(-1);
}
int startId = integer.intValue() + 1;
this.mServiceTaskIds.put(token, Integer.valueOf(startId));
int res = service.onStartCommand(intent, flags, startId);
QueuedWorkCompat.waitToFinish();
}
}
}
示例2: handleOnStartOne
import android.app.Service; //导入方法依赖的package包/类
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();
}
}
}
示例3: handleServiceArgs
import android.app.Service; //导入方法依赖的package包/类
private void handleServiceArgs(Intent serviceIntent,IBinder token){
Service service = mActivateServices.get(token);
if(service!=null){
if(serviceIntent!=null) {
serviceIntent.setExtrasClassLoader(service.getClassLoader());
}
service.onStartCommand(serviceIntent,Service.START_FLAG_RETRY,0);
}
}