Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as Java by hieu ( 6 years ago )
package com.fossil.smart_battery_collector;

import android.app.Service;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.IBinder;
import android.util.Log;

public class BatteryCollectorService extends Service {
    private static final BatteryInfoReceiver mBatteryReceiver = new BatteryInfoReceiver();

    public BatteryCollectorService() {
    }

    @Override
    public void onCreate() {
//        android.os.Debug.waitForDebugger();
        Log.i("onCreate (Service)","service is created!!");
        registerReceiver(this.mBatteryReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        Log.i("onStartCommand","START_STICKYYYYYYY");
//        registerReceiver(this.mBatteryReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
        return START_REDELIVER_INTENT;
    }

    @Override
    public void onDestroy() {
//        super.onDestroy();
        Log.d("CollectorService","Destroyyyyyyyyyyyyyyy");
        unregisterReceiver(this.mBatteryReceiver);
//        startService(new Intent(getBaseContext(), getClass()));
//        registerReceiver(this.mBatteryReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
    }

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

 

Revise this Paste

Your Name: Code Language: