I making an application in which my requirement is to get the Recently Added or Edited or Deleted Contact in Phonebook. So is there is way to achieve this. Any help will be appreciated.
You need to show what you tried, so that we can write our answers based on your try.
First, make sure you have this:
<uses-permission android:name="android.permission.READ_CONTACTS" />
According to the android docs, you can easily read contacts, and, to get specific selections (which is exactly what you want) you can:
Define a search text expression that retrieves rows for a specific
contact's LOOKUP_KEY and the Data.MIMETYPE of the details you want.
Enclose the MIMETYPE value in single quotes by concatenating a "'"
(single-quote) character to the start and end of the constant;
otherwise, the provider interprets the constant as a variable name
rather than as a string value. You don't need to use a placeholder for
this value, because you're using a constant rather than a
user-supplied value.
Take a look at the different ways to get specific selection keys on contacts, so that you can get exactly what you want.
http://developer.android.com/training/contacts-provider/retrieve-details.html
Related
I am getting a kmz-file from a webservice, which I use for geofencing.
The app is responsible to check whether the gps-location of the phone is within the geofence, or not.
I don't really know how the kmz-file will be structured (I am not creating it), but I think the coordinates might look like this:
<coordinates>
-112.2550785337791,36.07954952145647,2357
-112.2549277039738,36.08117083492122,2357
-112.2552505069063,36.08260761307279,2357
-112.2564540158376,36.08395660588506,2357
-112.2644963846444,36.08627897945274,2357
-112.2656969554589,36.08649599090644,2357
</coordinates>
How can I check if the gps-coordinates of my phone are within the geofence (the example above is only a line, it should be a closed area, for example a rectangle)? Right now I can't really think of how to do that.
And what library should be used to access the kmz-files?
First, for geofencing, download the sample from here and read the documentation. And I don;t know about kmz file. But if you can get the string from it(using file reading) and know its structure, then you can easily parse it. If the format is like you mentioned, then you can get the values by following method:
Split the string on coordinates (including <>). You will get a string array. Take the string at index 1.
Split this string on /coordinates (including <>). You will get another string array. Take the string at index 0.
Now split this string on ",". You will get an array of strings again! Now at indexes 0,3,6... are latitudes and at indexes 1,4,7... are longitudes and at indexes 2,5,8... are the third number in the data you mentioned.
i am new to android development,so dint get me wrong. I am developing an application in which a text is generated.which is normally a word. The word is checked in a database for is corresponding value pair. Here the word is the key and its corresponding value is the value .
Since the text is auto generated it sometimes goes wrong(mis spelled). How do i perform a check of auto generated word to match with the mostly matched letters in the database of key word.
example: auto-generated word(key) - value
americ:
america : a country
Here the auto generatd word is americ(key) is not matched since it only contains america in its pair set.it need to be corrected as america.
You are probably using SQLite. Your best bet is soundex, which is desribed here.
Soundex has many shortcomings, but it might get you started. If you want a real measure, then go with Levenshtein distance, which is not built into the database (as far as I know).
I am creating an app and i get an Address from geocoder.So I am getting a string that contains the address.My problem is that I want to put the name in a Textview the number in an Edittext(so the client can edit the number) and the city with the postcode to an other Textview.Any ideas?Thanks.
If there is a particular pattern in the Address you get, you can use String.split() method of Java to extract tokens which can then be used individually to fill particular information. See this example for understanding its working.
The best approach would be to write a Regular expression and group corresponding pieces of information and then getting them back using Matcher class.
This example explains how to get Regular expression's to work.
I have implemented search dialog and online search suggestion. But I want when user click on suggestion to copy string from suggestion list to search dialog and when user click on search button to start searching. Now when user click on suggestion searching is automatic start.
Take a look at http://developer.android.com/guide/topics/search/adding-custom-suggestions.html#RewritingQueryText which lists 3 different approaches to do this as per below:
1) Add the android:searchMode attribute to your searchable configuration with the "queryRewriteFromText" value. In this case, the content from the suggestion's SUGGEST_COLUMN_TEXT_1 column is used to rewrite the query text.
2) Add the android:searchMode attribute to your searchable configuration with the "queryRewriteFromData" value. In this case, the content from the suggestion's SUGGEST_COLUMN_INTENT_DATA column is used to rewrite the query text. This should only be used with URI's or other data formats that are intended to be user-visible, such as HTTP URLs. Internal URI schemes should not be used to rewrite the query in this way.
3) Provide a unique query text string in the SUGGEST_COLUMN_QUERY column of your suggestions table. If this column is present and contains a value for the current suggestion, it is used to rewrite the query text (and override either of the previous implementations).
I have very basic understanding problem of Content types.
I went through lot of examples and text explaining the above term, but still have some basic understanding problem. Can some clarify me please.
In the android notepad example, and many others, it is mentioned vnd.android.cursor.dir/ resolves to a list of items in a directory and vnd.android.cursor.item/ refers to specific item in a directory.
Is this vnd.android.cursor.dir some standard constant defined by android. Where did this come from?, or can i change it like
vn.com.android.myexample.dir/
How is this even resolved and what is its purpose, why not use the full CONTENT_URI?
Sorry, i'm totally lost, and don't understand this.
Documentation: https://developer.android.com/guide/topics/providers/content-provider-basics#MIMETypeReference
The MIME types returned by ContentProvider.getType have two distinct parts:
type/subType
The type portion indicates the well known type that is returned for a given URI by the ContentProvider, as the query methods can only return Cursors the type should always be:
vnd.android.cursor.dir for when you expect the Cursor to contain
0 through infinity items
or
vnd.android.cursor.item for when you expect the Cursor to contain
1 item
The subType portion can be either a well known subtype or something unique to your application.
So when using a ContentProvider you can customize the second subType portion of the MIME type, but not the first portion. e.g a valid MIME type for your apps ContentProvider could be:
vnd.android.cursor.dir/vnd.myexample.whatever
The MIME type returned from a ContentProvider can be used by an Intent to determine which activity to launch to handle the data retrieved from a given URI.
Where did this come from?, or can I change it like vn.com.android.myexample.dir/
No, because "vnd" stands for vendor in MIME Registration trees, android in this case.