Android Open Source - resident-background-service Main Activity






From Project

Back to project page resident-background-service.

License

The source code is released under:

MIT License

If you think the Android project resident-background-service 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) 2015 Yu AOKI//  ww w . j av a  2 s.co m
 *
 * This software may be modified and distributed under the terms
 * of the MIT license. See the LICENSE file for details.
 */

package com.aokyu.service;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class MainActivity extends Activity {

    private Context mContext;
    private Button mStartButton;
    private Button mStopButton;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.screen_main);

        mContext = getApplicationContext();
        mStartButton = (Button) findViewById(R.id.start_button);
        mStartButton.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View view) {
                ResidentService.start(mContext);
            }
        });

        mStopButton = (Button) findViewById(R.id.stop_button);
        mStopButton.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View view) {
                ResidentService.stop(mContext);
            }
        });
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
}




Java Source Code List

com.aokyu.service.ApplicationTest.java
com.aokyu.service.MainActivity.java
com.aokyu.service.ResidentService.java
com.aokyu.service.receiver.BootCompletedReceiver.java
com.aokyu.service.receiver.PackageReplacedReceiver.java
com.aokyu.service.setting.Settings.java