本文整理汇总了Java中android.app.Service.START_STICKY属性的典型用法代码示例。如果您正苦于以下问题:Java Service.START_STICKY属性的具体用法?Java Service.START_STICKY怎么用?Java Service.START_STICKY使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.app.Service
的用法示例。
在下文中一共展示了Service.START_STICKY属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onStartCommand
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Log.d(TAG, "Service is started");
if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)
return Service.START_NOT_STICKY;
if (android.os.Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP_MR1)
return Service.START_NOT_STICKY;
IntentFilter filter = new IntentFilter();
filter.addAction(ACTION_SET_STATE);
registerReceiver(settingsReceiver, filter);
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addApi(Wearable.API)
.build();
mGoogleApiClient.connect();
int interruptionFilter = getCurrentInterruptionFilter();
SettingsService.sendState(mGoogleApiClient, interruptionFilter, mStateTime);
return Service.START_STICKY;
}
示例2: onStartCommand
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
if (!_isInitialized) {
_logger = new SmartMirrorLogger(TAG);
_isInitialized = true;
_context = this;
_systemController = new AndroidSystemController(_context);
_checkServicesHandler = new Handler();
_checkServices.run();
}
_logger.Debug("onStartCommand");
return Service.START_STICKY;
}
示例3: onStartCommand
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Bundle extras = intent.getExtras();
if (extras != null) {
apkName = extras.getString("name");
downloadUrl = extras.getString("downloadurl");
Logger.i("DownLoadService: %s", apkName + "\r\n" + downloadUrl);
// downloadUrl = "http://pro-app-qn.fir.im/f63088ce552e398521ce5840de798c803b29dd2c.apk?attname=appcloud-v1.0.0-huawei-release.apk_V1.0.0.apk&e=1513073607&token=LOvmia8oXF4xnLh0IdH05XMYpH6ENHNpARlmPc-T:zlbPNpvxSrX779NlvRQW0kTjPr0=";
apkName = apkName + "_" + Long.toString(System.currentTimeMillis() / 1000) + ".apk";
Log.i(TAG, "apkName: " + apkName);
}
//如果路径下apk文件存在,就删除
File file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), apkName);
if (file.exists()) {
file.delete();
}
//创建广播对象并注册广播,用于监听下载完成后自动安装APK
mReceiver = new DownloadCompleteReceiver();
registerReceiver(mReceiver, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));
//下载需要写SD卡权限, targetSdkVersion>=23 需要动态申请权限
applyPermissions();
return Service.START_STICKY;
}
示例4: onStartCommand
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
updater.checkForUpdate(new ChromiumUpdater.ReturnCallback<Boolean>() {
@Override
public void onReturn(Boolean returnValue) {
if(returnValue == null) {
showUpdateFailure();
} else if(returnValue) {
showUpdateNotification();
}
stopSelf();
}
});
Log.d(TAG, "notify update");
return Service.START_STICKY;
}
示例5: onStartCommand
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
LOGD(TAG, "onStartCommand");
if (intent != null) {
String action = intent.getAction();
if (ACTION_VISIBILITY.equals(action)) {
mVisible = intent.getBooleanExtra(NOTIFICATION_VISIBILITY, false);
LOGD(TAG, "onStartCommand(): Action: ACTION_VISIBILITY " + mVisible);
onRemoteMediaPlayerStatusUpdated(mCastManager.getPlaybackStatus());
if (mNotification == null) {
try {
setUpNotification(mCastManager.getRemoteMediaInformation());
} catch (TransientNetworkDisconnectionException | NoConnectionException e) {
LOGE(TAG, "onStartCommand() failed to get media", e);
}
}
if (mVisible && mNotification != null) {
startForeground(NOTIFICATION_ID, mNotification);
} else {
stopForeground(true);
}
}
}
return Service.START_STICKY;
}
示例6: onStartCommand
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
ApplicationPasswordModel applicationPasswordModel = (ApplicationPasswordModel) intent.getSerializableExtra(Bundles.APPLICATION_PASSWORD_MODEL);
if (applicationPasswordModel != null) {
_databaseController.Initialize(
this,
applicationPasswordModel.GetPassword(),
applicationPasswordModel.GetCreationDate(),
applicationPasswordModel.GetCreationTime());
return Service.START_STICKY;
}
return START_NOT_STICKY;
}
示例7: onStartCommand
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
startDownload();
// 注册广播接收者,监听下载状态
registerReceiver(receiver, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));
return Service.START_STICKY;
}
示例8: onStartCommand
@Override
public int onStartCommand(final Intent paramIntent, int p1, int p2) {
mThread = new Thread(new Runnable() {
public void run() {
try {
dnsModel = paramIntent.getParcelableExtra(DNS_MODEL);
String modelJSON = gson.toJson(dnsModel);
preferences.edit().putString("dnsModel", modelJSON).apply();
setFileDescriptor(builder.setSession(DNSService.this.getText(R.string.app_name).toString()).
addAddress("192.168.0.1", 24).addDnsServer(dnsModel.getFirstDns()).addDnsServer(dnsModel.getSecondDns()).establish());
setTunnel(DatagramChannel.open());
tunnel.connect(new InetSocketAddress("127.0.0.1", 8087));
protect(tunnel.socket());
while (shouldRun)
Thread.sleep(100L);
} catch (Exception exception) {
Timber.e(exception);
} finally {
if (fileDescriptor != null) {
try {
fileDescriptor.close();
setFileDescriptor(null);
} catch (IOException e) {
Timber.d(e);
}
}
}
}
}
, "DNS Changer");
mThread.start();
rxBus.sendEvent(new StartEvent());
preferences.edit().putBoolean("isStarted", true).apply();
return Service.START_STICKY;
}
示例9: onStartCommand
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
if (!_isInitialized) {
_isInitialized = true;
_context = this;
_androidSystemController = new AndroidSystemController(_context);
_checkServicesHandler = new Handler();
_checkServices.run();
}
return Service.START_STICKY;
}
示例10: onStartCommand
/**
* Called when service initially started and for every other call there after. Used for adjusting the time for games updates as changed in the setting.
*/
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Log.i(TAG, "Service Starting");
if (intent != null && intent.hasExtra(FETCH_TIME_CHANGE)) {
reloadTimer();
}
return Service.START_STICKY;
}
示例11: onStartCommand
@SuppressLint("LongLogTag")
@Override
public int onStartCommand(final Intent intent, final int flags, final int startId) {
Log.e(TAG, "onStartCommand: Service started");
return Service.START_STICKY;
}
示例12: onStartCommandService
public static int onStartCommandService(Service service, Intent intent, int flags, int startId) {
createService(service, intent);
if (mRealServices.containsKey(service)) {
Map<String, Service> serviceMap = mRealServices.get(service);
String key = ApkComponentModifier.getKey(intent);
if (serviceMap.containsKey(key)) {
return serviceMap.get(key).onStartCommand(intent, flags, startId);
}
}
return Service.START_STICKY;
}
示例13: onStartCommand
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
MLog.d(TAG, "onStartCommand");
if (intent != null) {
AndroidUtils.debugIntent(TAG, intent);
if (intent.getAction() == SERVICE_CLOSE) stopSelf();
}
return Service.START_STICKY;
}
示例14: onStartCommand
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
if (_isInitialized) {
if (_batterySocketController != null) {
_batterySocketController.Start();
}
if (_birthdayUpdater != null) {
_birthdayUpdater.Start();
}
if (_calendarViewUpdater != null) {
_calendarViewUpdater.Start(Timeouts.CALENDAR_UPDATE);
}
if (_currentWeatherUpdater != null) {
_currentWeatherUpdater.Start();
}
if (_dateViewUpdater != null) {
_dateViewUpdater.Start();
}
if (_forecastWeatherUpdater != null) {
_forecastWeatherUpdater.Start();
}
if (_ipAddressViewUpdater != null) {
_ipAddressViewUpdater.Start(Timeouts.CHECK_FOR_UPDATE);
}
if (_menuListUpdater != null) {
_menuListUpdater.Start();
}
if (_rssViewUpdater != null) {
_rssViewUpdater.Start(Timeouts.RSS_UPDATE);
}
if (_shoppingListUpdater != null) {
_shoppingListUpdater.Start(Timeouts.SHOPPING_LIST_UPDATE);
}
if (_temperatureUpdater != null) {
_temperatureUpdater.Start();
}
if (_wirelessSocketUpdater != null) {
_wirelessSocketUpdater.Start();
}
if (_wirelessSwitchUpdater != null) {
_wirelessSwitchUpdater.Start();
}
if (_broadcastController != null) {
CenterModel centerModel = new CenterModel(
false, "",
true, YoutubeId.THE_GOOD_LIFE_STREAM,
false, "",
false, RadioStreams.BAYERN_3,
false, "");
_broadcastController.SendSerializableBroadcast(
Broadcasts.SHOW_CENTER_MODEL,
Bundles.CENTER_MODEL,
centerModel);
_broadcastController.SendSerializableBroadcast(
Broadcasts.SHOW_RSS_DATA_MODEL,
Bundles.RSS_DATA_MODEL,
new RSSModel(RSSFeed.DEFAULT, true));
}
setLocks();
}
return Service.START_STICKY;
}
示例15: onStartCommand
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
return Service.START_STICKY;
}