Android Open Source - Interception Main Activity

From Project

Back to project page Interception.


The source code is released under:

# The Code Project Open License (CPOL) 1.02 ###Preamble This License governs Your use of the Work. This License is intended to allow developers to use the Source Code and Executable Files provided a...

If you think the Android project Interception 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.bitgriff.androidcalls;
//from   w  w  w  .j  ava  2 s.  c  o  m
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

 * Main activity, with button to toggle phone calls detection on and off.
 * @author Moskvichev Andrey V.
public class MainActivity extends Activity {

  private boolean detectEnabled;
  private TextView textViewDetectState;
  private Button buttonToggleDetect;
  private Button buttonExit;

    public void onCreate(Bundle savedInstanceState) {
        textViewDetectState = (TextView) findViewById(;
        buttonToggleDetect = (Button) findViewById(;
        buttonToggleDetect.setOnClickListener(new OnClickListener() {
      public void onClick(View v) {
        buttonExit = (Button) findViewById(;
        buttonExit.setOnClickListener(new OnClickListener() {
      public void onClick(View v) {

    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(, menu);
        return true;
    private void setDetectEnabled(boolean enable) {
      detectEnabled = enable;
        Intent intent = new Intent(this, CallDetectService.class);
      if (enable) {
         // start detect service 
            buttonToggleDetect.setText("Turn off");
      else {
        // stop detect service
        buttonToggleDetect.setText("Turn on");
        textViewDetectState.setText("Not detecting");


Java Source Code List