All Downloads are FREE. Search and download functionalities are using the official Maven repository.

src.android.os.SomeService Maven / Gradle / Ivy

Go to download

A library jar that provides APIs for Applications written for the Google Android Platform.

There is a newer version: 15-robolectric-12650502
Show newest version
package android.os;

import android.app.Service;
import android.content.Intent;
import java.io.File;
import java.io.IOException;

/** Service in separate process available for calling over binder. */
public class SomeService extends Service {

    private File mTempFile;

    @Override
    public void onCreate() {
        super.onCreate();
        try {
            mTempFile = File.createTempFile("foo", "bar");
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    private final ISomeService.Stub mBinder =
            new ISomeService.Stub() {
                public void readDisk(int times) {
                    for (int i = 0; i < times; i++) {
                        mTempFile.exists();
                    }
                }
            };

    @Override
    public IBinder onBind(Intent intent) {
        return mBinder;
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        mTempFile.delete();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy