Accessing message contents of an android phone using Python - android

Here's what I want to do.
I have a Samsung galaxy phone whose message box is full. I want to download all the SMS messages from the mobile phone to my computer the Pythonic way. Before I decided to pose this question, I did a quick research on the internet, SO for possible answers.
I hit this lead and this lead here on the internet. These tutorials are quite extensive but do not provide the basic information of accessing the device and display its contents on a screen on my computer.
I read up a little more on using Twilio and other websites, but then that requires connecting to the internet and exposing my phone for the websites.
For now, I just want to access the SMS messages and display them as, perhaps, lists may be. Not the complicated stuff of automating, etc. There sure must be a simple method of doing this?

To access messages on an Android phone directly, you'll need to read the "mmssms.db" file. This is located at data/data/com.android.providers.telephony/databases/mmssms.db, and is an SQLite database. However, this requires root to read. If you have root, use the SMS-tools library here.
If you don't have root access to your phone, you can likely use a built-in Android backup tool to save your SMS messages to your Gmail account. You'd then be able to scrape the messages, or potentially use the Gmail API to retrieve them.

You can use "SMS Backup & Restore" app from Google Play and then manipulate generated backup file with Python. No need to write Python app for Android
Also, you can't backup sms in Google account, like the other answer says

I haven't experimented, but have a look at this page: https://groups.google.com/g/kivy-users/c/3ToGSpc0_1w.
It looks pretty promising for accessing the sms history.

Related

Website shows data from Android App - Like WhatsApp Web

Does anyone know how WhatsApp Web have done this?
They show the messages/data from the Android phone connected to the Internet.
So it seems there is no database on the server site. They get all messages directly from the mobile app and sends also the changes directly.
How can this be done?
With Firebase or any other Library?
WhatsApp created an API which is used both for mobile and web end to communicate to each other and to the main database where all the messages and user information are stored.
The fact that your phone needs to be turned on and have internet connection still doesn't really show that the website pulls the information out of the phone itself.
What it is happening, more likely, is that the web extension communicates with the mobile phone linked to it to make sure that the account is still active on the mobile device and then proceeds to pull messages and information out of the database using the API.
I'm not excluding that the web extension retrieves some information form the device but it probably constantly keeps in sync with it to make sure the account is still active and there is no ambiguity between the account on the web extension and the account currently logged in to the mobile device.
Hope this clarifies a bit but there's no public documentation that I could find online so I'm going by what I believe is the most likely scenario.
:)
P.S. You can have a look here if you haven't already tried:
WhatApp website FAQ

Android SMS content provider

I have a client who want an app that would run "perfectly".
He asks me if there is any way of pulling off the entire list of SMSs for a certain contact in order to send it over to a webserver.
I know that the SMS content provider is not part of the official SDK but I don't understand what does this exactly mean.
Can anyone explain me the issues with the SMS CP and what are the risks of using it in my app?
Will the app still be able to run without issues, as my detail-oriented client wishes?
P.S. Do not close this question. I do not ask for personal opinions, I ask for technical explanations.
Thanks.
It won't run perfectly, the SMS not being part of the public API's means its not guaranteed to be standard across the board, for example you may get your app working on standard Android on a Nexus device but HTC/Samsung and all other brands will have slightly different content providers depending on their needs and designs meaning your app will break on these content providers.

Get WhatsApp messages

Is it possible to create a listener to get a message from whatsApp in android?
I mean like you have a broadcastReceiver to listen to incoming SMS in android...
Is any API is needed for that thing, or is it legal thing to do or I need to get any permission from whatsApp?
Whatsapp did not publish any official APIs.
There's this open source API for communicating with whatsapp, it's not official and might stop working if Whatsapp update their protocols.
https://github.com/venomous0x/WhatsAPI
Regarding the legality of using this or other non-official API, it depends on the service agreement that you agreed to with Whatsapp. Read it and see if they frown upon using their communication protocols with clients other than theirs. My guess would be they do not allow it.
UPDATE: This GitHub repository seems to have been taken offline due to legal threats.
It is possible, an example of an Android app that does this is Snowball - basic notification manager that can access WhatsApp message content. I'm not quite sure on how that works, but research Snowball to get more information on how it works.
It is also possible without Android, the source repository on GitHub has been taken down and put back up a few times due to legal threats.
If you do, however, manage to connect to WhatsApp's servers to access incoming and outgoing messages with a desktop app and you don't hide it well, your account will be blocked. WhatsApp notices accounts that send messages faster than it would take for a normal person to send - easy to notice because a human takes time to type, try delaying messages by a random number of seconds to try and hide this. Also note that WhatsApp's terms of service state that you may not run any automated system using the service, i.e. any external app. You may not use the service to advertise or spam (raises red flags pretty fast and gets your account blocked).
There is also another library written in Python which you can use write custom application.
It also has terminal client and you run it in interactive mode and also supports group messaging.
There are lots of issues to fix.However you should not be abusive with whatsapp service.Don't use it to spam users.This is reverse engineered library and therefore unofficial.
Here the link:-yowsup

Send text to app (not specific phone number)

I don't know if this is even possible, couldn't find anything usefull on the internet.
I wanted to make an app, that me and some of my friends could send a message trough "my app" and that everyone who has that app, receive the message, without using a phone number.
So basically, same as WhatsApp GroupConversation, but then without using a phone number.
Is this even possible?
If it is possible, could you put me on the right track to start with.
Hope I am clear enough, if not, tell me :)
Edit:
This just pops up in my head (didn't look on internet yet), but what I want, is a kind of a shoutbox.
This is possible, in fact WhatsApp does not use your phone number for this at all.
You simply provide your phone number to asure a unique ID and proof that you are indeed in possession of this phone with the validation SMS.
From there on, your phone number isn't even used anymore.
You can go 2 ways with this;
Create a simple webservice with a database on which you just save and request messages. Maybe make a little difference between get all or get latest message. Anyone, hooking into the group, can just fetch the same data. With the use of GCM push notifications, you can make this pretty instant.
Use XMPP, which is a chat protocol kinda all the chats use. Whatsapp, Google talk, FB messenger... This will provide you with instant messaging just like any other chat app or program you know.
Option 2 is by far the best in final functionality, but be warned that XMPP is quite complex and error prone.
You can look into the asmack and asmackx libraries for Android, which will give you the basic functionality with ease. Going a bit deeper, you'll have to dig into the protocol and really get to know it though.
ps. For both you'll need your own server, however with asmack(x) you are also allowed to use Google's Talk servers for free. Communication will go through your Gmail account. Basically with this you just make your own version of Google Talk.
It is possible by implementing server-client architecture. Your app will use a common database for all the users. whenever an user install your app, he will achieve an unique user ID. if anyone uninstall it, his id will be destroyed. You can track the users from those ID in database. You don't need phone numbers.

Identifying an Android device / an installation (without physical ID)

The problem:
In one of my Android apps, users should be allowed to make changes to text data on my server (via HTTP request) without being required to login or sign up.
In order to prevent spam and abuse of this function, I would like to identify a single installation of my app so that I can "ban" this installation. Of course, the user who is abusing my service could uninstall the app and download it again or something like that. But this is truly an obstacle and makes abusing the app more difficult.
So I have to find a way to identify an Android device or at least a single installation.
As one can read here or here the physical device ID of an Android phone is not a good solution. So what else could I do to achieve this?
My idea:
When the app is started for the first time, create an (almost) unique hash (maybe SHA-512) of the current timestamp and a huge random number. Then save this value on internal storage and always use it to identify this device or installation later (on HTTP requests).
What do you think of that solution? Are there any better approaches?
This is almost what the Android Developers Blog suggest, right? But are they really writing to the internal storage? They don't use openFileOutput() as suggested here.
And, at last, a question that is probably a bit stupid:
How can I use the code shown on the Android Developers Blog? Can I add that public class to my main activity .java file?
Thank you very much in advance! :)
In my current Android project, I use the Bluetooth mac id as the identifier because of what I read about the physical device ID not being reliable. Of course, my app is very specialized and REQUIRES bluetooth AND internet anyway, so this works.
Specifically I have a way of calling my web server from the phone, passing in the Bluetooth mac ID. I can check license status (for trials/expirations), where you might check against a ban method to see if that id is banned.
Since my application requires bluetooth, this worked perfectly for me since [mostly] all bluetooth mac id's should be unique.
Just an idea.

Categories

Resources