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.
package com.bitgriff.androidcalls; //from w w w .j ava 2 s. c o m import android.app.Activity; 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; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); textViewDetectState = (TextView) findViewById(R.id.textViewDetectState); buttonToggleDetect = (Button) findViewById(R.id.buttonDetectToggle); buttonToggleDetect.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { setDetectEnabled(!detectEnabled); } }); buttonExit = (Button) findViewById(R.id.buttonExit); buttonExit.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { setDetectEnabled(false); MainActivity.this.finish(); } }); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.activity_main, menu); return true; } private void setDetectEnabled(boolean enable) { detectEnabled = enable; Intent intent = new Intent(this, CallDetectService.class); if (enable) { // start detect service startService(intent); buttonToggleDetect.setText("Turn off"); textViewDetectState.setText("Detecting"); } else { // stop detect service stopService(intent); buttonToggleDetect.setText("Turn on"); textViewDetectState.setText("Not detecting"); } } }