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.
Related
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'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!!!
I implemented a small application which will list all the SMS from INBOX and displays both the Contact number and Name.
I have to use two URIs, one is to get the SMS and the other is to get the Contact information related to that SMS.
This approach is having lot of performance issue while listing all the SMS with the Contact Name. It is taking quiet a long time in my 600MHz Android Phone.
But my native SMS application is launching within fraction of seconds. I really don't know how to achieve this.
One way I am thinking of using JOIN conditions on two URIs because I don't know how to use rawQuery on Content://SMS/inbox and the Contacts Data.
Any help would be appreciated. Thanks in Advance..
But my native SMS application is launching within fraction of seconds. I really don't know how to achieve this.
They can access their own database directly, and therefore can use JOINs directly. You cannot express a JOIN across ContentProviders.
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 pretty sure it's not viable to do what I'd like to based on some initial research, but I figured it couldn't hurt to ask the community of experts here in case someone knows a way.
I'd like to create a custom field for contacts that the user is able to edit from the main Contacts app; however, the user should only be allowed to select from a list of four specific values. A short list of string values would be ideal, but an int with a min/max range would suffice.
I'm interested in knowing if it's possible either way, but also wondering if it make sense to go this route performance wise. More specifically, would it be better to look up a contact (based on a phone number) each time a call or SMS message is received or better to store my own set of data (consisting of name, numbers, and the custom field) and just syncing contact info in a thread every so often? Or syncing contacts the first time the app is run and then registering for changes using ContentObserver?
Here is a similar question with an answer that explains how to add a custom field to a contact.
Thanks in advance.
I don't see the purpose to have your own set of data against contacts stored in your separate database, as you obviously will run into sync issues. You can use the mimetype and store whatever you want against the contact, in the manner you linked.
Whenever you want to looup contacts you can do that by using your custom mimetype. You get the contact id (from ContactsContract.Data.CONTENT_URI), and then you run another query to get the contact details (from ContactsContract.Contacts.CONTENT_URI). Please note these are different tables.
I'd like to create a custom field for contacts that the user is able to edit from the main Contacts app
I don't see that possible, editable from the main app, when you use your custom mimetypes, and you don't have much options here. The main contact app will display only the fields that are in SDK. You can store details against contacts but they won't show up in the inbuilt edit contact screen.