当前位置: 首页>>代码示例>>Java>>正文


Java Service.START_STICKY属性代码示例

本文整理汇总了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;
}
 
开发者ID:rkkr,项目名称:wear-dnd-sync,代码行数:24,代码来源:LGHackService.java

示例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;
}
 
开发者ID:GuepardoApps,项目名称:LucaHome-MediaServer,代码行数:18,代码来源:ControlServiceStateService.java

示例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;
    }
 
开发者ID:Jusenr,项目名称:AppFirCloud,代码行数:27,代码来源:DownLoadService.java

示例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;
}
 
开发者ID:bamless,项目名称:chromium-swe-updater,代码行数:17,代码来源:CheckUpdateService.java

示例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;
}
 
开发者ID:SebastianRask,项目名称:Pocket-Plays-for-Twitch,代码行数:27,代码来源:VideoCastNotificationService.java

示例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;
}
 
开发者ID:GuepardoApps,项目名称:PasswordSafe-AndroidClient,代码行数:14,代码来源:DataService.java

示例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;
}
 
开发者ID:xiarunhao123,项目名称:Ency,代码行数:7,代码来源:UpdateService.java

示例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;
}
 
开发者ID:msayan,项目名称:star-dns-changer,代码行数:37,代码来源:DNSService.java

示例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;
}
 
开发者ID:GuepardoApps,项目名称:LucaHome-AndroidApplication,代码行数:11,代码来源:ControlServiceStateService.java

示例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;
}
 
开发者ID:riteshakya037,项目名称:Android-Scrapper,代码行数:12,代码来源:ScrapperService.java

示例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;
}
 
开发者ID:shashi2459,项目名称:notify-me,代码行数:7,代码来源:MyService.java

示例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;
}
 
开发者ID:LiangMaYong,项目名称:android-apkbox,代码行数:11,代码来源:HookService_Manager.java

示例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;
}
 
开发者ID:victordiaz,项目名称:phonk,代码行数:11,代码来源:PhonkServerService.java

示例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;
}
 
开发者ID:GuepardoApps,项目名称:LucaHome-AndroidApplication,代码行数:79,代码来源:MainService.java

示例15: onStartCommand

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    return Service.START_STICKY;
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:4,代码来源:NLService.java


注:本文中的android.app.Service.START_STICKY属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。