Android Studio Tutorial – An App to Track Outgoing Calls

Hello friends, welcome again to this new android studio tutorial. In this android studio tutorial we will be creating a simple app to detect outgoing calls. So if you are struggling to create an app that can detect the outgoing calls; you just came to the right place. So without wasting time lets start our android studio tutorial.

[easy_media_download url=”″ text=”Download Source”]

Creating Android Studio Project

  • Open android studio and create a new project. I created DetectOutgoingCalls
  • Now you will get your and activity_main.xml
  • We need a broadcast receiver that will detect the outgoing call

Creating Broadcast Receiver for Detecting Outgoing Calls

  • Right click on your package name. Go to new -> java class and create a new java class.
  • I just created

  • Inside this class we will create a new class for our broadcast receiver

  • We will store the number received using Shared Preferences

  • Now we will create two methods, start and stop.
  • In start we will register our broadcast receiver and in stop we will unregister it
  • Including start stop method our full CallDetector class will be look as follow

  • Now the problem is we cannot make a call without minimizing our app
  • So if we minimize our app for making a call our app will not work
  • So we have to do something so that our app will work on background
  • We can overcome this problem by creating a service
  • Right click on your package -> new -> java class and create a new java class. I just created CallDetectionService
  • This class will extend the Service class, so we need to override some methods as well

  • Inside onStartCommand we will start our broadcast receiver and inside onDestroy we will stop our broadcast receiver
  • So the final code for will be

  • Now we need to add this service to our manifest
  • Add the following code inside application tag in your manifest

  • Inside manifest add the following permission as well

  • Now the last part is to create a User Interface to make our app work.

Designing User Interface for Our Android Application

  • Come to your activity_main.xml. We need to create the following layout
android studio tutorial
User Interface
  • Use the following xml code for creating above layout

  • Now come to your

  • Inside onClick we will toggle the detection

  • Now in onResume method we will fetch the data from shared preferences

  • Thats it now run your project. Click on the button then minimize your app and make a call. Now end the call and open the app you will see the number on the text view.

Check the Video of Tracking Outgoing Calls in Android

This is the video demonstration of the output of this android app.

So thats all for this android studio tutorial friends. Hope you enjoy this android studio tutorial. Thank You 🙂

2 thoughts on “Android Studio Tutorial – An App to Track Outgoing Calls”

  1. I’m already a fan of your work! The code is very simple but very functional. Now, I have a question: Would you know if there is any way for this code to work on Android Oreo API 26 or higher? I’m trying to make an application look like, for Oreo APIs, however that service does not work due to Google’s new restriction policy.


Leave a Comment