Read all messages android

Read sms messages programatically in Android

by Anu S Pillai · Published March 4, 2017 · Updated March 20, 2017

Read SMS

In this tutorial we will see how to listen and read SMS programatically in Android. This feature is widely used in Apps to read OTPs and Secret Codes automatically without the need of the user to look and type the OTP manually.

Permissions

First lets add all the necessary permissions in Android Manifest which is required to listen to incoming SMS and read it. Copy – Paste the below code in your Manifest.

Register Broadcast Receiver in Manifest

Now lets register the broadcast receiver in the Android Manifest. Add below code inside the tag. We will create the SmsReceiver.java class shortly.

SmsListener Interface

Now lets create an Interface file SmsListener.java with the below code. This interface will help us notify the activity whenever a new SMS is received by the Broadcast receiver.

Broadcast Receiver

Now lets move on to create our Broadcast receiver which will listen to incoming sms. We have already registered the receiver in Manifest above. Create a Java file SmsReceiver.java and copy paste the below code in it.

Getting the Message in Activity

Lets create our MainActivity.java class in which we will receive the text and do some actions as per our requirements.

Please let me know your Suggestions / Queries in comments.

Follow GadgetSaint on Facebook / Twitter for updates.

Wanna start your blog or site in 5 mins? Check out Official WordPress recommended web hosting Bluehost.

The Admin at GadgetSaint.com

  • Next story Update : Fetch calories and steps using Google Fit API for any date
  • Previous story Create a Splash Screen with Video in Android

Set Custom Fonts for TextView and EditText in Android

by Anu S Pillai · Published March 24, 2017 · Last modified October 29, 2019

January 21, 2017

by Anu S Pillai · Published January 21, 2017 · Last modified April 17, 2017

Fetch daily steps and calorie using Google Fit API

December 5, 2016

by Anu S Pillai · Published December 5, 2016 · Last modified March 31, 2017

9 Responses

I have tried to follow your example. However, I get the following errors:
Error:(7, 34) error: cannot find symbol class BroadcastReceiver
Error:(13, 27) error: cannot find symbol class Context
Error:(13, 44) error: cannot find symbol class Intent
Error:(12, 5) error: method does not override or implement a method from a supertype
Error:(14, 9) error: cannot find symbol class Bundle
Error:(19, 13) error: cannot find symbol class SmsMessage
Error:(19, 37) error: cannot find symbol variable SmsMessage

Any advice would be appreciated.

Hover @ the names and you will get the suggestions to import the files .
hope it will help you . 🙂

Nice Blog,but please give some more explanation of code to get understand

Источник

Read Incoming Message in Android

Jul 9, 2017 · 3 min read

Todays, Almost all application use text SMS for authentication purpose like OTP verification, Login via mobile etc. In this feature server send a text in any format and need to validate by the user that’s it. Using this modern feature user can save more time.

In this article, we are going to learn how to implement this feature in android app development. Create new project in android studio (You can choose any IDE).

Let’s do code implmentation here

  1. Add a MessageReceiver.java (You can choose class name) for entry point when new sms received.

Let’s discuss what’ s the code behind. First of all create MessageReceiver.java class and extends BroadcastReceiver class and override onReceive() method which has two argument first one is context, and second one is intent. The intent contains the PDU (Protocol Data Unit) object which is a protocol for transferring message. From this protocol get all object and SmsMessage object using SmsMessage. createFromPdu() method which take one argument of raw PDU. After creating message object we can get all information from this object and send back to UI(Any where you want) for sending this information I am using listener called ( MessageListener.java) interface.

Читайте также:  Андроид для лексус 470

2. Now the time to create listener (MessageListener.java) interface. Code is here just use this.

3. Now implement this listener where you want to receive your sms body and register this listener. As we getting sms data back to my MainActivity.java . So my code is here

In this MainActivity.java file only register listener and override messageReceived() method which has only one argument called message. Here you can authenticate your OTP or do any thing with this message as per your requirements.

4. The last and very important things is open your AndroidMenifest.xml file and get permission and also entry Receiver. Here are complete code for manifest file is.

5. Now Run you code and enjoy. Happy coding.

Источник

Как программно читать СМС-сообщения с устройства в Android?

Я хочу получить SMS-сообщения с устройства и отобразить их?

Используйте Content Resolver ( «content: // sms / inbox» ) для чтения SMS, которые находятся в папке «Входящие».

Пожалуйста, добавьте разрешение READ_SMS .

Я надеюсь, что это помогает 🙂

Установить приложение в качестве приложения SMS по умолчанию

Функция для получения SMS

Не забудьте определить разрешение в вашем AndroidManifest.xml

Это тривиальный процесс. Хороший пример вы можете увидеть в исходном коде SMSPopup.

Изучите следующие методы:

это метод для чтения:

Начиная с API 19 для этого вы можете использовать класс телефонии; Так как жестко заданные значения не будут получать сообщения на всех устройствах, потому что поставщик контента Uri меняется от устройств и производителей.

Этот пост немного устарел, но вот еще одно простое решение для получения данных, связанных с SMS поставщиком контента в Android:

Получить все SMS :

В каждом SMS-сообщении есть все поля, поэтому вы можете получить любую нужную вам информацию:
адрес, тело, receiveDate, тип (INBOX, SENT, DRAFT, ..), threadId, .

Гель все Thread :

Гель все Conversation :

Он работает с List или, Cursor и есть пример приложения, чтобы увидеть, как это выглядит и работает.

На самом деле, есть поддержка всех поставщиков контента Android, таких как: Контакты, Журналы вызовов, Календарь, . Полный документ со всеми опциями: https://github.com/EverythingMe/easy-content-providers/wiki/Android- провайдеры

Надеюсь, это также помогло 🙂

Шаг 1: сначала мы должны добавить разрешения в файл манифеста, как

Шаг 2: затем добавьте сервисный класс получателя смс для получения смс

Шаг 3: Добавить разрешение во время выполнения

Шаг 4. Добавьте эти классы в ваше приложение и протестируйте интерфейсный класс.

SmsReceiver.java

Есть много уже доступных ответов, но я думаю, что все они упускают важную часть этого вопроса. Прежде чем читать данные из внутренней базы данных или ее таблицы, мы должны понять, как в ней хранятся данные, а затем найти решение вышеуказанного вопроса:

Как программно читать СМС-сообщения с устройства в Android?

Итак, в андроид смс таблица выглядит так

Знайте, мы можем выбрать все, что мы хотим из базы данных. В нашем случае нам нужно только

В случае чтения СМС:

1. Спросите разрешения

2. Теперь ваш код выглядит так

Я надеюсь, что это будет полезно. Спасибо.

Сервисы Google Play имеют два API, которые вы можете использовать для упрощения процесса проверки на основе SMS

Предоставляет полностью автоматизированный пользовательский интерфейс, не требуя от пользователя ручного ввода кодов проверки и не требуя каких-либо дополнительных разрешений приложения, и должен использоваться по возможности. Однако он требует, чтобы вы поместили пользовательский хеш-код в тело сообщения, поэтому вы должны также контролировать серверную часть .

  • Требования к сообщениям — 11-значный хэш-код, который однозначно идентифицирует ваше приложение
  • Требования к отправителю — Нет
  • Взаимодействие с пользователем — нет

Не требует настраиваемого хеш-кода, однако требует, чтобы пользователь одобрил запрос вашего приложения на доступ к сообщению, содержащему проверочный код. Чтобы свести к минимуму вероятность появления неправильного сообщения для пользователя, SMS User Consent будет отфильтровываться сообщения от отправителей в списке контактов пользователя.

  • Требования к сообщению — 4-10-значный буквенно-цифровой код, содержащий не менее одного номера
  • Требования к отправителю — отправитель не может быть в списке контактов пользователя
  • Взаимодействие с пользователем — одно нажатие для подтверждения

The SMS User Consent API является частью Сервисов Google Play. Для его использования вам понадобится как минимум версия 17.0.0 этих библиотек:

Шаг 1: Начните слушать SMS-сообщения

SMS User Consent будет прослушивать входящие SMS-сообщения, содержащие одноразовый код, до пяти минут. Он не будет проверять сообщения, отправленные до его запуска. Если вам известен номер телефона, на который будет отправляться одноразовый код, вы можете указать senderPhoneNumber , или, если вы не null соответствуете ни одному номеру.

Читайте также:  Как принимать ммс андроид

Шаг 2: Запрос согласия на чтение сообщения

Как только ваше приложение получит сообщение, содержащее одноразовый код, оно будет уведомлено о трансляции. На данный момент у вас нет согласия на чтение сообщения — вместо этого вы получаете Intent что вы можете начать запрашивать согласие пользователя. Внутри вашего BroadcastReceiver , вы показываете подсказку, используя Intent в extras . Когда вы запускаете это намерение, он запрашивает у пользователя разрешение на чтение одного сообщения. Им будет показан весь текст, которым они поделятся с вашим приложением.

Шаг 3: Разбор одноразового кода и полное подтверждение SMS

Когда пользователь нажимает “Allow” — самое время прочитать сообщение! Внутри onActivityResult вы можете получить полный текст SMS-сообщения из данных:

Затем вы анализируете SMS-сообщение и передаете одноразовый код своему бэкэнду!

Источник

How to View Text Messages on Computer for Android Phone Users? (Solved)

Where are the text messages saved on an Android phone?

How to view text messages on computer from Android phone? Differ from the media files like videos, music and photos which are saved on the SD memory card on an Android phone and can be transferred or viewed on computer directly, text messages database are saved on mobile phone’s internal flash memory, which can not be read on computer directly. If you want to view text messages on computer (PC or Mac) with Android device, we need to draw support from professional third-party software that can help to extract text messages from Android mobile phone and save as readable file format on computer.

Here in this article, we share different 3 ways to help you read text messages of Android phone on computer, either a Windows PC or Mac computer.

Tip: If you want to know more details about the Android text message folder location, check this article: Where Are Texts Stored on Android Phone >>

Way 1: How to View Android Text Messages on Computer with Android Assistant

Coolmuster offers its powerful software — Coolmuster Android Assistant (for Windows 10/8/7/Vista/XP) or Coolmuster Android Assistant for Mac (Mac OS X 10.7 or later), which can help to export text messages from Android device to computer and save as .xml, .csv, .html, . bak or .txt files easily. To read or print Android messages, you are suggested to save Android SMS as readable TEXT, CSV, or XML format. Using this Android SMS Viewer, you can view messages from Android on computer in 2 ways: checking Android SMS on computer when Android phone is connected to computer, or viewing Android text messages on computer offline after exporting Android SMS to desktop.

As one of the best Android SMS manager apps, Coollmuster Android Assistant also allows users to send and receive SMS via computer directly, copy/restore/delete/backup/forward messages for Android, and add, delete or edit contacts on computer. It supports almost all Android brands, such as Samsung, Xiaomi, Huawei, Sony, HTC, Motorola, LG and so on, and it works with the latest Android phones as well, such as Samsung Galaxy S20/S10/S10+/S10e, HTC U11+/U11, Xiaomi 9/9 SE/8, HUAWEI Mate X/Mate 20/Mate 10 Pro, etc.

Let’s take a look at its detailed user guide together. First of all, take a trial version of this SMS Reader for Android with below buttons.

Below is the step-by-step guide showing you how to use Coolmuster Android Assistant to export and view text messages on computer. The following pictures are captured from Windows version. If you are running a Mac computer, you can also refer to the guide as below because the operations are almost the same on both Mac machine and Windows PC.

Steps to Read Text Messages from Android on Computer with Coolmuster Android Assistant:

Step 1. Connect Your Android Phone to Computer

Connect your Android phone to the computer via a USB cord or Wi-Fi. Then, you will see the connected phone is detected by this program automatically. If it is the first time to run this software, you may be asked to follow steps to enable USB debugging on your phone at first. If your device can be detected by the program, you can directly skip to the next step.

Step 2: Enter the SMS window

From the left side menu, you can see all the files in your cell phone will be displayed in categories. Click the «SMS» icon and you will enter the SMS managing window. All the text messages in your phone will show in list on the right. Mark the SMS you want to read on your computer and click the button of «Export«.

Читайте также:  Facebook для android планшетов

Step 3. Start to export SMS at once

There will be a «Path» dialog appears after your click the «Export» button. Just choose an output location for saving the exported text messages and then click the «Ok» button to begin the transfer process.

After a few while, all the selected text messages will be exported to your computer successfully. You will see all the text messages are saved in readable format and you can read them on the computer without any hassle. For example, you can save Android SMS in readable HTML, when you open it, you might see the Android messages as below, including the sent messages, received messages and even failed messages.

For more fantastic functions of the program, you can get it installed on your computer and try it out by yourself!

Video Tutorial

Way 2: Read Android Text Message on Computer with Lab.Fone for Android

Another way to check Android phone’s text messages on computer is using the Coolmuster Lab.Fone for Android (for all Windows versions) or Coolmuster Lab.Fone for Android (Mac). It is specially designed for Android users to recover lost and deleted text messages, as well as contacts, photos, videos, music, call logs and more from Android mobile phone and tablet with just several mouse clicks. However, you can also back up and export both of the existing and deleted text messages from Android device to computer so that you can use it to read SMS messages of Android on computer in readable HTML or XML format.

Both lost and existing messages can be detected by the program, so you can only choose the existing ones for exporting. And it is compatible with almost all Android phones (from Andorid 2.0 to 9.0 or up) as well.

How to View Text Messages on Computer with Android Phone:

1. Download, install and launch the Coolmuster Lab.Fone for Android on your computer;

2. Use a USB cable to connect your Android phone to the computer;

3. All detectable file types are displayed on the left, just click to open the «Messages» category to view all contained text messages, as well as the deleted ones;

4. Preview and select the deleted text messages you want back and click the «Recover» button to save as HTML or XML file.

After recovering the messages from Android to computer, you can read that text messages from Android on computer as follows now.

Video Tutorial

Way 3: How to Check My Text Messages from Android on Computer via Android Messages

«How to view/read my text messages of Android on computer?» asked by some users. Actually, if you want to read messages from Android using computer, Google’s default SMS app for Android phone — Android Messages for web might help you out with this. The Messages for web can also help you to send messages when you connect your phone to computer. Even so, you still need to pay for the fees of sending messages as you do on the mobile phone.

It is worth mentioning that the QR code for Messages for web is unique to your computer and pairs the mobile app with that computer. Even though you can pair your messaging accounts on multiple devices, only one of them can be activated at a time. That is to say, when you open Web-based Messages on your computer, the conversation on any other computer or browser tab becomes inactive.

Now, let’s see how to view text messages on computer from Android device below.

Step 1. Turn on Wi-Fi on your Android phone, then install the latest version of Messages onto your Android phone and launch it. Your Android phone should be running Android 5.0 or above.

Step 2. Start your computer and launch Messages for web with a web browser, such as Chrome, Mozilla Firefox, Safari, or Microsoft Edge (Internet Explorer is not supported).

Step 3. After opening Messages app on your phone, please tap «More» > «Messages for web«, then tap «Scan QR code» button to scan the QR code on the web page.

Step 4. On your computer, you might now click «More» > «Settings» button, and turn on «Enable dark theme» or «High contrast mode«. Now you can read text messages of Android on computer freely.

Источник

Оцените статью