SMSfirsAJ - Sample of how to intercept a SMS with BroadcastReceiver

Related tags

App SMSfirsAJ
Overview

SMS Received

Sample of how to intercept a SMS with BroadcastReceiver

Simples steps:

1 - Declare in your manifest: AndroidManifest.xml

<uses-permission android:name="android.permission.RECEIVE_SMS" />

<application[...]<receiver android:name="br.com.helpdev.kycform.receiver.SMSReceiver"
android:exported="true" android:permission="android.permission.BROADCAST_SMS">
<intent-filter android:priority="1000">
    <action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver></application>

2 - Give the permission in your app MainActivity.kt

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        requestSmsPermission()
    }

    private fun requestSmsPermission() {
        val permission = Manifest.permission.RECEIVE_SMS
        val grant = ContextCompat.checkSelfPermission(this, permission)
        if (grant != PackageManager.PERMISSION_GRANTED) {
            ActivityCompat.requestPermissions(this, arrayOf(permission), REQUEST_CODE_SMS_PERMISSION)
        }
    }

3 - Implement your receiver: SMSReceiver.kt

class SMSReceiver : BroadcastReceiver() {
    companion object {
        private val TAG by lazy { SMSReceiver::class.java.simpleName }
    }

    override fun onReceive(context: Context?, intent: Intent?) {
        if (!intent?.action.equals(Telephony.Sms.Intents.SMS_RECEIVED_ACTION)) return
        val extractMessages = Telephony.Sms.Intents.getMessagesFromIntent(intent)
        extractMessages.forEach { smsMessage -> Log.v(TAG, smsMessage.displayMessageBody) }
        //TODO
    }
}
You might also like...
Sample application demonstrating Android design and animation
Sample application demonstrating Android design and animation

android-movies-demo This is a sample application showing off some interesting design/development interactions for a talk given at Droidcon 2013. As it

This project is focused on the sample using the API's new preview version of Android-L, use of transitions, shadows etc...

Android L preview example Description This project is focused on the sample using the API's new preview version of Android-L, use of transitions, shad

A simple sample showing the different types of notifications on Andoid

Notification example Simple notification. Expandable notification Progress notification Action button notification Notifications: MainActivity: Refs h

Sample material transition animations for Android
Sample material transition animations for Android

See ListOfThings for a newer implementation. Android Material Transitions This Android project samples some Material Design-ish transitions for list i

How to apply meaningful and delightful motion in a sample Android app
How to apply meaningful and delightful motion in a sample Android app

Applying meaningful motion on Android How to apply meaningful and delightful motion in a sample Android app Read the complete post at https://medium.c

Chat is a sample project that presents a modern, 2021 approach to Android application development.
Chat is a sample project that presents a modern, 2021 approach to Android application development.

Chat for Android Chat is a sample project that presents a modern, 2021 approach to Android application development. Screenshots 📷

Sample news app using Kotlin, Hilt, Coroutines, Coil, Room, Retrofit

Tech stack & News App libraries Navigation component - navigation graph for navigating and replacing screens/fragments DataBinding - allows to more ea

This is a sample Rive app for Android.
This is a sample Rive app for Android.

rive_piggy This is a sample Rive app for Android. The RiveAnimationView view is great for simple use cases, but in this example we want to shows how t

Sample app demonstrating interop between Jetpack Compose and the Android UI toolkit, including SurfaceView
Sample app demonstrating interop between Jetpack Compose and the Android UI toolkit, including SurfaceView

Wake Me Up Wake Me Up is a sample app showcased in the Google I/O 2021 Developer Keynote that demonstrates interoperability between Jetpack Compose an

Owner
null
Library to read incoming SMS in Android for Expo (React Native)

react-native-expo-read-sms Maintainers maniac-tech Active maintainer Installation Install this in your managed Expo project by running this command: $

Abhishek Jain 15 Jan 2, 2023
an android app to send private secret SMS while terrorist Islamic republic of Iran banned internet access in Iran.

Mahsa An android application which is designed to deliver safe and encrypted messages using SMS while Islamic republic of Iran banned Iranian people a

null 3 Sep 22, 2022
Scans all the SMS of an Android device for any known domain that is related with the spyware Predator by Cytrox / Intellexa.

Συχνές ερωτήσεις και απαντήσεις Τι είναι το Predator; Ποιο είναι το ρίσκο μου να έχω δεχθεί επίθεση με το Predator; Πώς δουλεύει η εφαρμογή SMS Predat

Andronikos Koutroumpelis 14 Dec 6, 2022
FoldingNavigationDrawer-Android This is a sample project present how to use Folding-Android to add Folding Efect to Navigation Drawer.

FoldingNavigationDrawer-Android Sample (Play Store Demo) This is a sample project present how to use Folding-Android to add Folding Efect to Navigatio

null 242 Nov 25, 2022
❤️ A sample Marvel heroes application based on MVVM (ViewModel, Coroutines, LiveData, Room, Repository, Koin) architecture.

MarvelHeroes MarvelHeroes is a demo application based on modern Android application tech-stacks and MVVM architecture. Fetching data from the network

Jaewoong Eum 1.2k Dec 19, 2022
📚 Sample Android Components Architecture on a modular word focused on the scalability, testability and maintainability written in Kotlin, following best practices using Jetpack.

Android Components Architecture in a Modular Word Android Components Architecture in a Modular Word is a sample project that presents modern, 2020 app

Madalin Valceleanu 2.3k Jan 3, 2023
Shreyas Patil 2.1k Dec 30, 2022
Sample Project for Android Support Library 23.2

SnapShot: Contains features Vector Drawable Animated Vector Drawable AppCompat DayNight theme Bottom Sheets Using BottomSheetDialog in day-night mode.

Huqiu Liao 779 Nov 24, 2022
A sample Android app which showcases advanced usage of Dagger among other open source libraries.

U+2020 A sample Android app which showcases advanced usage of Dagger among other open source libraries. Watch the corresponding talk or view the slide

Jake Wharton 5.7k Dec 27, 2022
Sample to show how to implement blur graphical tricks

BlurEffectForAndroidDesign Sample to show how to implement blur graphical tricks All the explanations could be found here: http://nicolaspomepuy.fr/?p

Nicolas POMEPUY 2k Dec 28, 2022