Get Contact Details Android

العربية: Android logo
Get Contact Details (ID, Name, Phone, Photo)

res/layout/main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:orientation="vertical"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent" >
    <Button android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Select a Contact"
            android:onClick="onClickSelectContact" />
    <ImageView android:id="@+id/img_contact"
               android:layout_height="wrap_content"
               android:layout_width="match_parent"
               android:adjustViewBounds="true"
               android:contentDescription="Contacts Image"
                />
</LinearLayout>

Read More »

Android Voice Recognition

You may have heard about the “ Google Now project” where you give the voice command and Android fetches result for you. It recognizes your voice and converts it into the text or takes the appropriate action. Have you ever thought how is it done? If your answer is voice recognition API, then you are absolutly right. Recently while playing with Android voice recognition APIs, I found some interesting stuffs. APIs are really easy to use with application. Given below is a small tutorial on voice/speech recognition API. The final application will look similar to that of application shown below. The application may not work on the Android Emulator because it doesn’t support voice recognition. But the same can work on the phone.

Read More »

 

Printing in Android Application

My this post is based on “How to Integrate printer in android app”. the best way of doing that Google cloud printing. Google provide us Print Dialog code, we can use it in our application. 1)Login with your gamil-id in your desktop and add your printers in your browser. 2)Create a demo app and put below code. 3)Add Internet permissions…

combine

Read More »

Setup Google Play services SDK in Eclipse

google-play-logo11

The Google Play services SDK is an extension to the Android SDK and is available as a downloadable package from the SDK Manager. The download includes the client library and code samples. To develop using the Google Play services APIs, you must download the Google Play services SDK. Google Play services is not supported on the Android emulator, a physical…

Read More »

How to Install Android OS on your PC


Google’s Android is an operating system and software stack for mobile devices. Under the hood, it uses a customized version of the Linux kernel. Android is currently the fastest growing mobile operating system and is generating quite the buzz. If you are curious about it, you can give it a try without having to buy an Android smartphone. Let me tell how to do it.
LiveAndroid is a project that provides a LiveCD for Android running on x86 platforms. With a Live CD (or Live Distribution) you are able to test an operating system without altering the already installed OS or any files existing on the computer’s storage devices. The user can return his PC to its previous state when he is done with the LiveCD. LiveAndroid does not fully support the Android OS, but the most important stuff are included in the distribution (with more added with each release)………

Read More »

 

Customize Google Maps

Customize Google Maps
Overview The Maps API allows you to Customize Google Maps look and feel of the map. Custom markers will help the user differentiate between different features of the campus (such as classrooms, bathrooms and studentfacilities). A custom legend will communicate these different types of map features, and a custom map style will help make the map overlays stand out….

Read More »

 

Creating a Mobile Event Calendar

Mobile-Calendar_Preview
This tutorial describes how to build an HTML5-based mobile calendar to track conferences and events that run on iOS and Android phones using a mobile version of dhtmlxScheduler (open source, GPL). At the end, users will be able to add and edit events, select the conference location on Google Maps, and see the events in day, month, or list views….

Read More »

 

How to search Google efficiently?

Googling tricks and tips
Tricks for efficient Google search:Every 9 out of 10 people
use Google to Search the content they wish, and according to a recent
survey 80-90% of people face unsuccessful searches. Today the post is on How
to Search Google more efficiently
, forming a good Google query and you

end up getting the exact and relevant search results.Here i am sharing some
extremely helpful goggling skills with my readers.

 

Have you ever imagined how
pleasurable it would be if you get exactly what you were looking for??? the
techniques mentioned below will add value to your query. Using particular operators
along with the search terms in a specific syntax or format will provide you
with accurate and efficient content in no time.
1)     Use Quotes:
Usually, when you type the
search term without quotes then Google will look for the pages containing any
of the word in the search term. Say for example, if i type “anthem of India”
without quotes, then Google will list out all the webpages containing the word
“anthem” or “India”, but it won’t show the desired search results as we want
pages containing the whole term.
Enclosing the search term
inside a pair of double quotes will display search results of only the webpages
containing that exact phrase in the same order.
  Format: “Search term”
  Example: Suppose, you want to search for the
term techofundas4u, then your query
must be:
use quotes
2)      Also search for similar
terms:
Putting
a Tild(~) symbol right before the search term will  perform a search for the synonyms of the term
as well. Hence the results will contain webpages having  words similar to the term.
Format:
~search term
Example:
Suppose, if you wish to search the word jail, your query looks like:

Find synonyms

 

3)      Use wildcard:
The *(asterisk)symbol is
called wildcard, that can be placed in the search term where we are not sure
about the word. You can replace * with any word in your search term whether it
is the name of a book, a movie, the song lyrics, and likewise.
                  Format:
search * term
                  Example:
Suppose i forgot the name “tom and jerry”, one of my favourite cartoons them I
will write whatever words I remember and will place * where I forgot the word.
My query is:

use wildcard

 

4)      Check and correct spellings:
              spell:
operator will check the term for spelling mistakes and perform search for the
correct word automatically.
Format: spell: Search term
                       Example:
Suppose if I don’t know the correct spelling of the word I will write the
incorrect spelling “enginering” proceeded by spell: operator, now Google will
perform search for the correct word “engineering”. The query must be:

Using spell: operaror

 

5)      specific file type:
Sometimes you may want the
particular file type related to the search
term. If you want only the file with .PDF, .DOCX or .XLS extension then
place the filetype: operator prior to the extension and then write the
search term.
Format: filetype:    file-extension   Search term
Example: Suppose you are
looking for a presentation on the search term “3G technology” then your query
looks like:
Seach by filetype
6)      search word definitions:
Sometimes it may happen that
you want only the definition of the term and nothing else. Then simply place
the define: operator prior to the search term, it will serve your purpose
providing quick definitions from the webpages. And more importantly this
operator also shows an audio button, clicking on that will give the exact
pronunciation this is the most useful feature.
Format: define: Search term
Example: Suppose you want the
definition of the term “Nanotechnology” then you can simply append the term to
the define: operator. Your query must be:
search Word definitions
7)      Search for music:
The “music” operator
gives search results related to music only. Using this operator prior to the song
lyrics, or album name will show links to that song to watch and download the
song.
Format: music “song
lyrics/album name/ movie name”
Example: Suppose if you want
only the song “Chahu mein ya na”and not the lyrics, or reviews then you may
simply append this lyrics to the music operator. Your query is supposed to be:
search music only
8)      Find pages containing search
term in their URL:
allinurl: operator will
search the webpages containing exactly the particular search term in their URL.
There is another operator
inurl that does the same function as allinurl but the only difference
is that inurl will look only for the URLs containing the first word of the
search term, and the remaining words will be searched in the page.
Format: allinurl: search term
Example: Suppose if the search
term is “booking event” then it will display results in whose URL “booking
event” will appear. The query looks like:
using allinurl: operartor
9)      Find pages containing search
term in their title:
allintitle: operator will
search the webpages containing exactly the particular search term in their page
title.
     There is another operator intitle that
does the same function as allintitle but the only difference is that
intitle will look only for the pages with titles containing the first word
of the search term, and the remaining words will be searched in the page.
   Format: allintitle: Search term
  Example: Suppose I want to find the pages
with the term “troubleshooting hardware problems” in their titles, the query
must be:
using allintitle: operator
10)  Use OR:
OR operator displays search
results for both the search terms on either side of it. It is best suited if
you want to look for both word but separately in different links, or if both the
words are similar in meaning. You can also use — (double hyphen) or | (Pipe) symbol
instead of OR.
Format: Search term1 OR
Search term2
Example: Suppose if I want to
search for words Pizza and Burger simultaneously, then I’ll place OR operator
between these two words and it will show links of pages having both the words in
their content. The query must be:
Use OR operator
11)  Use NOT:
This operator excludes the
word with – (minus) sign before it from the search term. The pages containing
the excluded word will not be shown. This will strongly specify that you don’t
want that word to appear anywhere in your search results.
Format: search term –term to
be excluded
Example: Suppose I want to
search for the term institutes but I don’t want the word private to appear
anywhere in the search results, then my query will look like:
Use NOT operator
12)  Use Google as Calculator:
Type in the search box the
whole equation you wish to solve and here you go, it is far easier than using
your computer’s calculator because Google will solve the equation and display result
at once, instead of having to do it manually performing 1 operation each time.
This is a very fascinating
feature of Google , as it have an inbuilt Calculator. You just need to type in
the expression.
Format: Mathematical Expression
Example: Suppose I wish to
solve the expression (17*3)/(4*(6-2)-5) then I’ll simply Google it and the
result will be displayed within no time as shown below.
Use google as calculator
13)  Unit Convertor:
Google have another excellent
feature called Unit convertor, that is built into it. You need to write
down which unit and in what quantity, is to be converted into which one, Google
does the necessary unit conversions for you.
Example: Suppose I have to
find out how many Rupees are there in 5.4 US Dollars, then write it in the form
of a fill in the blank question as shown below.
Use Google as unit convertor
14)  Search within a site:
If you are sure that you want
to search a term from a particular website then you can restrict your search
using site: operator. Then you will be shown the search results from that
particular website only.
Format: Search term site:
site URL
Example: Suppose you are
looking for the term “news” in the website Only4bca.com, then your query must
be:
Using site: operator
            Or you may also use site: operator to find all the website having the
same domain names like .com, .org, .edu, .in, .gov and much more.
Use site operator
15)   Look for Area code:
Find area code

If you need to find out from
where you have received the call, then simply enter the 3-digit area code from
the phone number and you will get the location, As shown below:

16)  Find all the pages linked to
a specific URL:
If you want to know which all
webpages are linked to a particular site, then use link: operator. This
query will show you the links af all the webpages that links to that site.
Format: link: URL
Example: Suppose you want to
find that all the webpages that links to the website only4bca.com then the
query must be:
using link: operator

How to Use Gmail as if It Had Folders and Filters

English: Gmail logo
Are you disheartened by Gmail’s lack of folders? Folders into which you can stick your emails; folders reminiscent of

drawers or trusty file systems; folders whither you can move messages, even automatically?

Well, they might not be called “folders”, but Gmail’s labels act a lot like folders do. Using filters, you can even have Gmail sort your incoming mail by sender, subject or other criteria to your custom folders — out of the Inbox.

Use Gmail as if It Had Folders and Filters

To make Gmail route certain mail to particular “folders”, bypassing your Inbox:

  • Click Create a filter.
  • Enter the desired criteria.
    • To filter all mail from somebody, type their email address in the From: field, for example.
  • Click Next Step ».
  • Make sure Skip the Inbox is checked.
  • Also check Apply the label:.
  • Select an existing label (folder) from the Choose label… menu or:
    • Select New label….
    • Type the desired name for the label (folder).
    • Click OK.
  • Optionally, check Also apply filter to conversations below to move existing messages matching your criteria to the folder.
  • Click Create Filter.

New messages matching your rules will arrive in their labels (i.e. folders) only. If you keep the Labels box on it and an eye on it, you’ll see labels with new messages highlighted.

Reference:http://email.about.com/od/gmailtips/qt/et_gmail_folder.htm

 

The android.os.NetworkOnMainThreadException exception

Android invasion, Sydney, Australia

In this article I explain a possible cause of android.os.NetworkOnMainThreadException and how to avoid it.
From the Android site you can read:
NetworkOnMainThreadException
The exception that is thrown when an application attempts to perform a networking operation on its main thread.
This is only thrown for applications targeting the Honeycomb SDK or higher…

Here is a sample developed for Gingerbread, API level 9:

  1. create an Android project called HttpClient
  2. edit the file AndroidManifest.xml
    1 <?xml version="1.0" encoding="utf-8"?>
    2 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    3     package="eu.lucazanini.httpclient"
    4     android:versionCode="1"
    5     android:versionName="1.0" >
    6
    7     <uses-sdk android:minSdkVersion="9" />
    8     <uses-permission android:name="android.permission.INTERNET"/>
    9
    10     <application
    11         android:icon="@drawable/ic_launcher"
    12         android:label="@string/app_name" >
    13         <activity
    14             android:name=".HttpClientActivity"
    15             android:label="@string/app_name" >
    16             <intent-filter>
    17                 <action android:name="android.intent.action.MAIN" />
    18
    19                 <category android:name="android.intent.category.LAUNCHER" />
    20             </intent-filter>
    21         </activity>
    22     </application>
    23
    24 </manifest>

    where <uses-sdk android:minSdkVersion=”9″ /> means an API version earlier to Honeycomb (Gingerbread, API level 9), and <uses-permission android:name=”android.permission.INTERNET”/> authorizes the application to perform an internet connection

  3. edit the file HttpClientActivity.java
    1 package eu.lucazanini.httpclient;
    2
    3 import java.io.IOException;
    4
    5 import org.apache.http.HttpResponse;
    6 import org.apache.http.client.ClientProtocolException;
    7 import org.apache.http.client.methods.HttpGet;
    8 import org.apache.http.impl.client.DefaultHttpClient;
    9
    10 import android.app.Activity;
    11 import android.os.Bundle;
    12 import android.util.Log;
    13
    14 public class HttpClientActivity extends Activity {
    15
    16     @Override
    17     public void onCreate(Bundle savedInstanceState) {
    18         super.onCreate(savedInstanceState);
    19         setContentView(R.layout.main);
    20
    21         connect();
    22
    23     }
    24
    25     private void connect() {
    26         try {
    27             DefaultHttpClient client = new DefaultHttpClient();
    28             HttpGet request = new HttpGet("http://www.google.com");
    29             HttpResponse response = client.execute(request);
    30         } catch (ClientProtocolException e) {
    31             Log.d("HTTPCLIENT", e.getLocalizedMessage());
    32         } catch (IOException e) {
    33             Log.d("HTTPCLIENT", e.getLocalizedMessage());
    34         }
    35     }
    36
    37 }

This app is executed without errors.

If you specify an API level after Honeycomb, such as Ice Cream Sandwich, replacing the line <uses-sdk android:minSdkVersion=”9″ /> with <uses-sdk android:minSdkVersion=”14″ /> and you launch the application, you get the exception android.os.NetworkOnMainThreadException.

An easy way to avoid the exception is to insert the following code (which requires import android.os.StrictMode):

1 StrictMode.ThreadPolicy policy = new
2 StrictMode.ThreadPolicy.Builder()
3 .permitAll().build();
4 StrictMode.setThreadPolicy(policy);

before the row connect() in HttpClientActivity.java
But this method is recommended in development environments only, the recommended method is to use the class AsyncTask.

An example is the following in which the code of the class HttpClientActivity.java is replaced by:

1 package eu.lucazanini.httpclient;
2
3 import java.io.IOException;
4
5 import org.apache.http.HttpResponse;
6 import org.apache.http.client.ClientProtocolException;
7 import org.apache.http.client.methods.HttpGet;
8 import org.apache.http.impl.client.DefaultHttpClient;
9
10 import android.app.Activity;
11 import android.os.AsyncTask;
12 import android.os.Bundle;
13 //import android.os.StrictMode;
14 import android.util.Log;
15
16 public class HttpClientActivity extends Activity {
17     /** Called when the activity is first created. */
18     @Override
19     public void onCreate(Bundle savedInstanceState) {
20         super.onCreate(savedInstanceState);
21         setContentView(R.layout.main);
22
23 //      StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
24 //              .permitAll().build();
25 //      StrictMode.setThreadPolicy(policy);
26
27 //      connect();
28
29         new Connection().execute();
30
31     }
32
33     private class Connection extends AsyncTask {
34
35         @Override
36         protected Object doInBackground(Object... arg0) {
37             connect();
38             return null;
39         }
40
41     }
42
43     private void connect() {
44         try {
45             DefaultHttpClient client = new DefaultHttpClient();
46             HttpGet request = new HttpGet("http://www.google.com");
47             HttpResponse response = client.execute(request);
48         } catch (ClientProtocolException e) {
49             Log.d("HTTPCLIENT", e.getLocalizedMessage());
50         } catch (IOException e) {
51             Log.d("HTTPCLIENT", e.getLocalizedMessage());
52         }
53     }
54
55 }

You can override not only doInBackground but also other methods of the AsyncTask class like OnPreExecute(), OnPostExecute(Result), publishProgress(Progress. ..).