Android Banner

Read SMS on Android with screen damaged (solution only for devs)

I came across a very interesting problem, the screen of my old Android phone got damaged and I badly wanted to read SMS on my phone. That had an old SIM card with the bigger size 🙁 So what to do?

 As is clear from the title that the solution is for developers, what I did was I used Android Android development skills and using that I logged all SMS from the device on to the screen of my laptop and how did I do that?

I did that using Android Studio and Android Debugger Bridge (ADB). So basically the solution is only for the developers the common man cannot do it if you really want to do it, then go and hire an Android developer and he or she can do it for you probably.

 So coming to the solution, what I did was it created an Android app in using Android studio and I created an Activity and inside that Activity, I called a method would read all the SMS of that phone.

Prerequisites

Before jumping deep into the solution you need to consider:

  1. You need to have USB Debugging and Developer options turned on the phone.
  2. And because I was programming using that phone even before the screen got damaged, so I got lucky that I already had turned on USB Debugging on that phone.
  3. If you are not a developer then it might be a problem for you. Go ahead and hire an Andriod developer. Game Over!!
  4. What is the Android version of the phone? You need to accommodate that in the build.gradle file. Suppose your Android API Level is 8, then minSdkVersion in your build.gradle should be less than or equal to this number.
  5. If your phone is old, then for dependencies, you need to make sure that there is no reference to latest libraries like Android.

The Code

Step 1

Create a New Android App using Android Studio.

Step 2

Set minSdkVersion less than or equal corresponding SDK version of your phone. Remove all dependencies, especially the new ones like androidx which are not compatible with old appcompat libs.

Notice the dependencies section.

Step 3

Add the permission to read SMS in AndroidManifest.xml. Notice the uses-permission tag. Check my full file.

Step 4

Modify the default MainActivity. First, we need to update the XML layout file, so as to make sure it is not using any advance Views or ViewGroups which are not part of older Android SDK versions (e.g. ConstraintLayout, etc).

Contents don’t matter but you just need to make it compatible with the SDK version of your phone. I hope you get the point.

Check my activity_main.xml.

 

Step 5

Add the function to read SMS in your MainActivity.java and call that method in onCreate() method.

It simply reads the SMS Inbox Content Resolver with URI content://sms/inbox and logs the desired entries to Logcat using Log.x method.

Here is my full MainActivity.java

Step 6

Connect your phone to your system using USB Debugging and run the App.

Here is the result.

Results of SMS Reader / Logger on Logcat
Results of SMS Reader / Logger on Logcat

That’s it. I hope you find this solution helpful. Write your doubts or questions in the comments section.

Leave a Comment

Read SMS on Android with screen damaged (solution only for devs)

by Mohit Sehgal time to read: 2 min
0