Android Open Source - YourConsole Logcat Recording Service






From Project

Back to project page YourConsole.

License

The source code is released under:

MIT License

If you think the Android project YourConsole 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

package com.akisute.yourconsole.app;
//from   w ww. j av  a  2s  . co m
import android.content.Context;
import android.content.Intent;
import android.os.IBinder;

import com.akisute.yourconsole.app.dagger.DaggeredService;
import com.akisute.yourconsole.app.intent.Intents;
import com.akisute.yourconsole.app.model.LogcatRecordingManager;
import com.akisute.yourconsole.app.util.GlobalEventBus;
import com.squareup.otto.Subscribe;

import javax.inject.Inject;

public class LogcatRecordingService extends DaggeredService {

    @Inject
    GlobalEventBus mGlobalEventBus;
    @Inject
    LogcatRecordingManager mLogcatRecordingManager;

    public static void startLogcatRecording(Context context) {
        Intent intent = new Intent(context, LogcatRecordingService.class);
        intent.setAction(Intents.ACTION_START_LOGCAT_RECORDING);
        context.startService(intent);
    }

    public static void stopLogcatRecording(Context context) {
        Intent intent = new Intent(context, LogcatRecordingService.class);
        context.stopService(intent);
    }

    @Override
    public void onCreate() {
        super.onCreate();
    }

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

    @Override
    public IBinder onBind(Intent intent) {
        throw new UnsupportedOperationException("Binding to this service is not yet supported.");
    }

    @Override
    public boolean onUnbind(Intent intent) {
        throw new UnsupportedOperationException("Binding to this service is not yet supported.");
    }

    @Override
    public void onRebind(Intent intent) {
        throw new UnsupportedOperationException("Binding to this service is not yet supported.");
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        if (intent != null) {
            final String action = intent.getAction();
            if (Intents.ACTION_START_LOGCAT_RECORDING.equals(action)) {
                handleStartLogcatRecording();
                return START_STICKY;
            }
        }

        stopSelfResult(startId);
        return START_NOT_STICKY;
    }

    private void handleStartLogcatRecording() {
        com.akisute.yourconsole.app.Application application = (Application) getApplication();
        mLogcatRecordingManager.start();
        mGlobalEventBus.register(this);
    }

    private void handleStopLogcatRecording() {
        mGlobalEventBus.unregister(this);
        mLogcatRecordingManager.stop();
    }

    @Subscribe
    public void onNewLogcatLineEvent(LogcatRecordingManager.OnNewLogcatLineEvent event) {
        SaveIntentService.startActionSave(this, event.getLogcatLineList());
    }
}




Java Source Code List

com.akisute.yourconsole.app.AppModule.java
com.akisute.yourconsole.app.Application.java
com.akisute.yourconsole.app.ConsoleViewerFragment.java
com.akisute.yourconsole.app.LogcatRecordingService.java
com.akisute.yourconsole.app.MainActivity.java
com.akisute.yourconsole.app.SaveIntentService.java
com.akisute.yourconsole.app.dagger.DaggeredActivity.java
com.akisute.yourconsole.app.dagger.DaggeredApplicationModule.java
com.akisute.yourconsole.app.dagger.DaggeredApplication.java
com.akisute.yourconsole.app.dagger.DaggeredFragment.java
com.akisute.yourconsole.app.dagger.DaggeredIntentService.java
com.akisute.yourconsole.app.dagger.DaggeredService.java
com.akisute.yourconsole.app.dagger.ForApplication.java
com.akisute.yourconsole.app.dagger.ForInjecting.java
com.akisute.yourconsole.app.helper.LogcatHelper.java
com.akisute.yourconsole.app.helper.RuntimeHelper.java
com.akisute.yourconsole.app.intent.Intents.java
com.akisute.yourconsole.app.model.ConsoleListAdapter.java
com.akisute.yourconsole.app.model.LogcatLine.java
com.akisute.yourconsole.app.model.LogcatRecordingManager.java
com.akisute.yourconsole.app.model.MText.java
com.akisute.yourconsole.app.reader.LogcatReader.java
com.akisute.yourconsole.app.reader.SingleLogcatReader.java
com.akisute.yourconsole.app.util.GlobalEventBus.java
com.akisute.yourconsole.app.util.GlobalPreference.java