I'm in a very big trouble in building a simple custom SMS/MMS content provider wrapper class as long as it doesn't exist an official one for the android platform.
Obviously, to get data, i query on the "content://sms" and "content://mms" content provider using a cursor.
I found it fairly simple with SMS, because the columns names are quite intelligible and contains all data that a typical programmer needs in his application ("person" to get the sms sender/receiver contact id, "address" to get the sender/receiver phone number, "type" to get if the sms is an inbox, outbox, draft, sended sms etc...)
Unfortunately with MMS i've found a lot of trouble. The columns has unintelligible names (ex. "d_tm", "ct_cls", "retr_st", "d_rpt" etc.) and basic informations that i need, such as contact id, phone number, the type of the mms etc... seems to miss.
How can i get this information over the MMS?
I searched over all the 32 columns of the content provider but i didn't found what i need.
Thanks in advance!
P.S.
I know that google advise to avoid this kind of "low-level" operation over content providers that doesn't have a series of official class to access them, but i imagine that software house that operates in sms/mms management such as HandCent or Go Dev team, have built their own content provider using the same approach i'm using too.
Am i right or it exists unofficial libraries to manage SMS/MMS?
Thanks!
I googled a little bit more and finally i found that the correct way to get information like contact_id, phone number, type etc. about MMSs, is to open the content provider to the following
URI: "content://mms/{MmsId}/addr"
({MmsId} is the MMS "_id" column value).
Here i found all information i need.
Hope it helps!!!
Related
I am working on SMS Module.
I need to give searching contact via name, number and SMS via body?
I am able to search SMS body with CursorLoader via
content://mms-sms/search
Contacts separately via
ContactsContract.CommonDataKinds.Phone.CONTENT_FILTER_URI
So is there any separate URI search these two things which i am not aware of or Merge these two under one list With using CursorLoader.
Appreciate any lead.
or is there some way to improve sms search and customize it.
So is there any separate URI search these two things which i am not aware of or Merge these two under one list
No.
Also, bear in mind that not every SMS will be to or from a user's contact.
I want to create a Contact Provider so I can populate it from our database and let our business workforce to have all the customer data. That's the "easy" part.
But what I need is to isolate those contacts and avoid them to be cloned disallowing the people to copy/clone them and loosing track of that information.
Is there a way to do that? I haven't found a way to do that and I think the only way is to show the contacts in a custom Contact app. The problem with that solution is that it wouldn't be possible to know who's calling.
Is there a way to do that?
On an Android device, there will be roughly zero lines of code that knows anything about a custom ContentProvider that you create. If you do not want to share data from that provider, do not offer any UI to allow people to share data from that provider, and do not export the provider to third-party apps.
I haven't found a way to do that and I think the only way is to show the contacts in a custom Contact app
You needed to write that anyway. There are ~2 billion Android devices. None of them will have a Contacts-style app that knows anything about some custom ContentProvider that you create.
The problem with that solution is that it wouldn't be possible to know who's calling.
Correct. After all, the devices' call managers do not know anything about your custom ContentProvider.
Now, it could be that by "create a Contact Provider", you really meant "not create a Contact Provider". In this case, the "it" in "I can populate it from our database and let our business workforce to have all the customer data" might mean the standard Android ContactsContract ContentProvider. In this case, the Contacts app and in-call screens and everything else that works with contacts will work with your contacts. However, this is a system-supplied ContentProvider, exported to third-party apps, with documentation and so on. There are thousands of apps, both pre-installed and available via the Play Store and elsewhere, that can work with ContactsContract. You have no means of stopping that, and you have no means of preventing those apps from doing whatever it is that they want with this data.
IOW, you cannot satisfy "I want the Contacts app to have my contacts" and "I do not want the Contacts app to have my contacts" at the same time.
I want to let my app scan the users contactlist , and display the name of the contacts who also installed the app.
I have no idea where to begin with this . so if someone could help me getting started , that would be apreciated.
grtz
You will need to research ContentResolver because you will have to query the database containing the contacts. To do these queries, you will need the URI and column/header names for contacts db which can be found in the Contacts class.
You will also need users to register that they have your app on your own servers and the registration will need a piece of information about the user that other users would have in their contacts (the users phone number, email address, etc).
You will then need to query a few users at a time from the users contacts for this piece of information (using the ContentResolver and Contacts class), pass it to your server (as text) where it will check if they are registered, then send a message back to initial user (and possibly the match) that you found a match.
That's where you should start, and end :)
Note, you will need these permissions in the Manifest file:
android.permission.INTERNET
android.permission.READ_CONTACTS
First of all, welcome to StackOverflow. StackOverflow is for programming questions. As is such, a post asking for help should always provide a description of what you have already tried. If you haven't tried anything yet, I highly encourage you to try something, and post when you encounter a problem.
As your question stands now, we don't know what the problem is. Are you having problems scanning a contact list? Or are you having problems trying to figure out if another user has installed the app?
That being said, you will have to maintain a database for your app containing a list of people who have installed your app. When your app is launched on one device, do whatever you need to do to register the user in your database. Due to the nature of a "contact," one person's phone may only have their phone number, email address, or even just a name. This is of course something you will have to deal with in your implementation.
I want to find a way specific SMS that contains a specific word and answer back automatically.
I have found a way to answer the SMS but I still can't work on finding the SMS...
Its true that its not documented but people have been using this for years and if an update was to change the way we access the SMS database it would affect hundreds of users applications. So I doubt any time soon they would change this.
Anyway, start by creating a cursor object to the SMS database and just run a query with no conditions in the where clause. Then just run through the database pulling out the values you need. Someone was also nice enough to post the different column names in the database. Here they are: How many database columns associated with a SMS in android?
Below is a code snippet to get the SMS's from the database.
Cursor messages;
Columns message = ColumnsFactory.messages(); //points to structutre
messages = getContentResolver().query(Uri.parse("content://sms/"),
null, null, null, null);
while (messages.moveToNext()) {
//do stuff here.
Have you tried Google App Inventor? It has an example of this very type of app.
App inventor example website
In your broadcast receiver for incoming SMS, check the SMS body. If the SMS body contains that particular word then send a reply to that number. In the same way you can also check for incoming numbers.
Example to check for particular number:
if (smsBody.contentEquals("word to match")) {
// create reply
}
There is an undocumented content provider for SMS: "content://sms/inbox" . But this is not official and can change. There is no proper way of sms access.
I'm new to android programming. just to improve my skills, i started with some project in my mind.
when app starts, it will show a button. on click of it, it will allow me to select a contact from the address book. then i want to retrieve all the sms sent to that contact (if they are stored in sms outbox). Is it possible. Can some one guide me. If there is some tutorial on these topics, can you let me know the URL or source code?
Thanks in Advance.
First, it is not possible. There are many SMS clients for Android, many of whom do not expose an "sms outbox".
Second, even if you limit yourself to the SMS application that ships with "Google Experience" phones, the "sms outbox" is not part of the SDK.
If you wish to create an application that sends SMS messages, there is the SmsManager class you can use.
As folks mentioned, the sms outbox is undocument. If you want to access it, you sholud have some skills first.
trace android source code
learn how to use content provider (learn how to create a content provider is better)
what's the authority
know does the URI matched
how to manipulate the Cursor
write some sample code to test
You can find the SMS/MMS content provider here:
https://android.googlesource.com/platform/packages/providers/TelephonyProvider