Android Open Source - passwords-by-harry Nonstop Bound Service






From Project

Back to project page passwords-by-harry.

License

The source code is released under:

Apache License

If you think the Android project passwords-by-harry listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/*
 * Copyright (c) 2013. Harry Henry Gebel
 */*from  ww  w . j a va2s.  c  o m*/
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.github.harryfrommarydelde.passwordsbyharry;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;

/**
 * A bound service which does not stop when users unbind
 */
public abstract class NonstopBoundService extends Service {
    private int serviceSticky;

    /**
     * @param sticky Determines whether service will be restarted
     *               after being killed
     */
    public NonstopBoundService(int sticky) {
        super();
        serviceSticky = sticky;
    }

    @Override
    public final IBinder onBind(Intent intent) {
        // make sure service is started
        startService(new Intent(this, this.getClass()));
        return onNonstopBind(intent);
    }

    public abstract IBinder onNonstopBind(Intent intent);

    // doesn't do anything, just starts the service
    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        // Just start service, don't actually do anything
        return serviceSticky;
    }

}




Java Source Code List

com.github.harryfrommarydelde.passwordsbyharry.AccountListActivity.java
com.github.harryfrommarydelde.passwordsbyharry.ChangeMasterPasswordActivity.java
com.github.harryfrommarydelde.passwordsbyharry.DataServiceConnectedActivity.java
com.github.harryfrommarydelde.passwordsbyharry.DataService.java
com.github.harryfrommarydelde.passwordsbyharry.LoginActivity.java
com.github.harryfrommarydelde.passwordsbyharry.NonstopBoundService.java
com.github.harryfrommarydelde.passwordsbyharry.SettingsActivity.java
com.github.harryfrommarydelde.pbhsupport.DropboxSupport.java