Android Examples With Source Code

Android Examples with Source Code and Description

Here you can download verities of Android Examples with Source Code. To help you understand some fundamental Android APIs and coding practices, a variety of examples and source code are available along with the Android SDK Manager. Each version of the Android platform available with the SDK Manager offers its own set of sample codes for verities of android applications. Also You can download examples with source code for Android Applications from here. Below is the screen shot from the API Demos application. Once you will click on each category, we will find and run related android apps listed below.

You can find the source code for all samples at this location in your local PC, where you downloaded/extracted “Android SDK”:

<sdk>/samples/android-<version>/

The <version> number corresponds to the platform’s API level.

Example: ~\android-sdk-windows\samples\android-8\

In my PC, I have extracted android DK in my E:\ Drive. So sample codes location in my PC is :

“E:\Android\android-sdk-windows\samples\android-8\”

You can easily create new Android projects with the downloaded samples, modify them if you’d like, and then run them on an emulator or device.

Note: If you did not install sample codes before with Android SKD, then also you can install now. Follow below steps.

To Download Samples from Web:

  1. Launch the Android SDK Manager.
    • On Windows, double-click the SDK Manager.exe file at the root of the Android SDK directory.
    • On Mac or Linux, open a terminal to the tools/ directory in the Android SDK, then execute android sdk.
  2. Expand the list of packages for the latest Android platform.
  3. Select and download Samples for SDK.

Note: While trying the above steps, you might face some issues. You can go through my article Some Common Android Development Errors and Solutions.

Download More than 100 Android Examples with Sample Code in a Single Project

If you are not able to download or find default android sample codes from internet, then don’t worry. You can download all android API sample codes from here. I have uploaded more than 100 android examples with source code inside a single project, Once you download the project from here, then you can find the below list of android Sample codes and examples from that project. You can run each example on Android Emulator or Real Device. Some samples codes might not work in Emulator as they are hardware dependent. But you can run those in real device. You will find below List of Examples with Source Code once you download the project from here. I have sub categorized all sample examples like below. All the below android examples has been build and tested on Android Version 2.2 with SDK Min API Version 8. You can Run on higher Android OS as well.

Before Start downloading all Android Examples with Source Code from here, Please read this post carefully.

Note: All examples has been packaged as different categories in the code. Each package having verities of examples similar to that package as i have explained below. Have a look into below image for better understanding. When you open the project, you will find these packages in the source code.

android-example-source-code-demo  android-api-demos-examples

Download the APIDemos_apk.zip from here . Then unzip the downloaded file (APIDemos_apk.zip) and run on your Emulator/Device. Then check if your required android example is available in this project.

1. App Examples In Android

  • Action Bar Example in Android

  • Activity Example in Android

  • Alram Example in Android

  • Device Admin Example in Android

  • Dialog Example in Android

  • Intents Example in Android

  • Launcher Shortcuts Example in Android

  • Menus Example in Android

  • Notification Example in Android

  • Preferences Example in Android

  • Search Example in Android

  • Services Example in Android

  • Text-To-Speech Example in Android

  • Voice Recognition Example in Android

android-app-examples

2. Content  Examples In Android

  • Assets Examples in Android

  • Clipboard Example in Android

  • Provider Example in Android

  • Resources Examples in Android

  • Storage Example in Android

android-content-examples

3. Media

  • AudioFx

  • Media Player Example in Android

  • VideoView Example in Android

android-media-example

4. OS Examples in Android

  • Morse Code (Vibration) Example in Android

  • Rotation Vector Example in Android

  • Sensors Example in Android

  • SMS Messaging Example in Android

android-os-examples

5. Text Examples in Android

  • Linkify Example in Android

  • LogTextBox Example in Android

  • Marquee Example in Android

android-text-examples

6. Views Examples in Android

  • Amination Example in Android

  • Auto Complete Example in Android

  • Buttons Example in Android

  • Chronometer Example in Android

  • Controls Example in Android

  • Custom Example in Android

  • Date Widgets Example in Android

  • Expandable Lists Example in Android

  • Focus Example in Android

  • Gallery Example in Android

  • Grid Example in Android

  • ImageButton Example in Android

  • ImageSwitcher Example in Android

  • ImageView Example in Android

  • Layout Animation Example in Android

  • Layouts Example in Android

  • Progress Bar Example in Android

  • Radio Bar Example in Android

  • Rating Bar Example in Android

  • ScrollBars Example in Android

  • Seek Bar Example in Android

  • Spinner Example in Android

  • Tabs Example in Android

  • TextSwitcher Example in Android

  • Visibility Example in Android

  • WebView Example in Android

android-view-example

7. Graphics Examples in Android

  • AlphaBitmap Example in Android

  • AnimateDrawables Example in Android

  • Arcs Example in Android

  • BitmapDecode Example in Android

  • BitmapMesh Example in Android

  • BitmapPixels Example in Android

  • CameraPreview Example in Android

  • Clipping Example in Android

  • ColorMartix Example in Android

  • Compass Example in Android

  • CreateBitmap Example in Android

  • Density Example in Android

  • Drawable Example in Android

  • FingerPaint Example in Android

  • Layers Example in Android

  • MeasureText Example in Android

  • OpenGL ES Example in Android

  • PathEffects Example in Android

  • PathFillTypes Example in Android

  • Patterns Example in Android

  • Pictures Example in Android

  • Points Example in Android

  • PolyTopoly Example in Android

  • PurgeablesBitmaps Example in Android

  • Regions Example in Android

  • RoundRects Example in Android

  • ScaleToFit Example in Android

  • SensorTest Example in Android

  • SurfaceView Overlay Example in Android

  • Sweep Example in Android

  • Text Align Example in Android

  • Touch Paint Example in Android

  • Typefaces Example in Android

  • Unicode Chat Example in Android

  • Vertices Example in Android

  • Xfermodes Example in Android

android-graphics-examples

8. Android Preferences Examples in Android

  • Preferences from XML Example in Android

  • Launching preference Example in Android

  • Preference dependencies Example in Android

  • Default values Example in Android

  • Preference from codes Example in Android

  • Advanced preferences Example in Android

  • Fragment Example in Android

  • Headers Example in Android

android-preference-examples

9. NFC Examples in Android

  • ForegroundDispatch Example in Android

  • ForegroundNdefPush Example in Android

  • TechFilter Example in Android

android-nfc-examples

10. Animation Examples in Android

  • Bouncing Balls Example in Android

  • Cloning  Balls Example in Android

  • Custom Evaluator Example in Android

  • Default Layout Animations Example in Android

  • Events Example in Android

  • Hide-Show Animations Example in Android

  • Layout Animations Example in Android

  • Loading Example in Android

  • Multiple Properties Example in Android

  • Reversing Example in Android

  • Seeking Example in Android

  • View Flip  Example in Android

android-animation-examples

downloadDownload all above Examples with source codes in a single project from Here.

Note: To run all above downloaded sample codes, you need  to build the downloaded project in Eclipse and install the apk (ApiDemoes.apk), then you can see all categorized examples on the first page once you run the application on emulator or device.

Custom Android Examples and Sample Codes

For more custom Android Examples and Sample Codes, please click on the next page or go to the Android Tutorial Home Page. Click below links. You can find verities of custom sample source codes and examples from here.

 

Post By SmrutiRanjan (54 Posts)

Working @ Samsung as a Project Lead for Android Smartphones. I have been blogging since 2008. Previously I was writing articles for other bloggers, but finally I have started my own blog-"Techblogon".I am also an active contributor for the blog-"Gadgets n Gizmos World". Job is my necessity, but blogging is my passion.

Website: → Techblogon

Connect

52 Responses to Android Examples With Source Code

  1. Rinoy Varkey says:

    Hi Ranjan ,

    Great website and well done. It is really useful for me. I would be grateful if you could help me use particular features in your sample code in my apps. Some guidlines that I should follow to use your code.

    Thanks
    Rinoy

  2. Dave Tobias says:

    Hi,
    I have downloaded the sample code from google using sdk manager. Now I need to know the exact steps (complete Eclipse newbie) for importing an existing project and running it. I see many people have answered this question some time ago but not for Eclipse 4.2. When they change the menu structure, those old instructions are no longer correct. Can you give me the exact steps, assuming nothing to load one of the sample projects?

    Note: My eventual goal is to run some sample app that teaches me how the pen APIs introduced in ICS work.

    Thanks for your consideration!
    -Dave

    • SmrutiRanjan says:

      it is very simple.
      Open Eclipse: Then Goto the menu File->Import.
      Then Select Android->Existing Android Code into Work Space.
      Then in the Root Directory field, Browse your Android Example Folder (make sure to browse till the folder which contains all files and folders like res, src, etc).
      Then click Finish.
      Thats it.

      • Haur says:

        Sir,

        After i imported the file, there is an error in “com.example.android.apis.os” . What’s the problem? i couldn’t launch any android example because of that error or is there anyway to run a single android example even there is a problem in other android example under the same project?

  3. sustecha says:

    hello, thanks for your rich example but i have a problem on running app, cause when i am starting to run , the package made errors, and stop loading the emulator , need a help , hope to use it :)

    • SmrutiRanjan says:

      Dear Sustecha,
      You might try: First start the emulator and then install your app.
      If then also facing the same issue, then look at your DDMS logs, you can find exactly what is going wrong.

  4. krishn says:

    how can i vibration phone when i call and when call end.

    • SmrutiRanjan says:

      Goto section 4, you will find the vibration code. Download the code and enjoy.
      You need to register a broadcast receiver for call end and call start, then call end. then call vibration API.

      4. OS Examples in Android
      Morse Code (Vibration) Example in Android

      // Vibrate your mobile phone
      Vibrator vib = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
      vib.vibrate(2000);

  5. geogeo says:

    Thanks a lot …. U help me to begin …

  6. Karan says:

    Hello! SmrutiRanjan.
    Nice post. Very useful.
    Can please post an example on Multiple Screen Support.

  7. Ali Atayurt says:

    Hello SmrutiRanjan, I have a problem If you help me , ı am thankful . I have sqlite date base. And 2 tables. Cities and Offices
    Tabel 1 :CitID,CitName
    Table 2 :OffID,CitID,OffName and ı have created db.class and city.xml İn my xml file I have 2 spinner . spinner_1,spinner_2

    I can load to spinner_1 ,Cities and spinner_2 Offices. But ı want , when ı selected spinner1 for ex. select Köln, spinner2 will load officces for ex Office A, Office B . How can I do this ? Can you send example for my problem. Do you have open source code ? Help me , please. Thank you very much for your help.

  8. Lalith says:

    Hi Ranjan

    I am new to Eclipse. can you show me how to install the apk (ApiDemoes.apk)to eclipe.

    Thank you

    Lalith

  9. Kowshik R says:

    Hi sir,
    I need source code for android default browser, so please can you help me.
    Thank you

    • SmrutiRanjan says:

      Default browser means? do you want to open the default browser or want to know the name of the default browser?

      • Kowshik R says:

        Sir,
        i need code for web browser ie(code for bookmarks, code for cookies, and code to save the sessions), pls help me sir, i have to submit my project within may 23rd.
        Thank you.

  10. Zai May says:

    you’re really good Sir..hopefully you will also give some demonstration on making some android programs..

  11. K says:

    the source files (Android-Sample-Codes-with-Examples.zip) provide a lot less samples than the apk does (ApiDemos_apk.zip)

  12. madhavi says:

    hai iam working on sms receved notifications i need to display sms on new screen

    case1:
    if i get one sms i click the notification bar and notification bar launches new scree in that my msg will be displayed

    if i get one message iam able to disply one messge on new screen
    but if i get more than two messages i am displaying only latest messge on new screen ,one message is vanishing(wrong coding).(means iam displaying latestmessge on new screen if i get 2 messges.i lossing to display 2 messegs.
    similary if get 3 ,0r more its happeninh like this

    pls help me thanks in andvance

    i posted my prob in many sites no one is replied the coreect
    how can i resolve my issue

  13. Kowshik R says:

    Sir,
    i need code for web browser ie(code for bookmarks, code for cookies, and code to save the sessions), pls help me sir, i have to submit my project within may 23rd.
    Thank you.

  14. Terry says:

    hi brother
    i want the all sources codes of apidemos.apk because the apidemos_all.zip only contain apidemos.apk .i am a beginner and i am very interesting in Android .thank this page is very useful
    please help me.

  15. Aykudint says:

    Thank you very much for your help and comments…

  16. mouaiyad says:

    error : INSTALL_FAILD_OLDER_SDK :(

  17. kartick mishra says:

    Respected Sir,
    when i am trying to execude this code in emulator,i am getting error in console.

    [2013-05-09 10:27:45 - ApiDemos] Installing ApiDemos.apk…
    [2013-05-09 10:27:51 - ApiDemos] Re-installation failed due to different application signatures.
    [2013-05-09 10:27:51 - ApiDemos] You must perform a full uninstall of the application. WARNING: This will remove the application data!
    [2013-05-09 10:27:51 - ApiDemos] Please execute ‘adb uninstall com.example.android.apis’ in a shell.
    [2013-05-09 10:27:51 - ApiDemos] Launch canceled!

  18. ravi says:

    please give me some sample code for GPS tracking for this layout

  19. ravi says:

    How to store selected spinner value in the SQLITE database like selected country,state etc please give me some example for this sir…………..
    I am searching from last four days for this sir but i didn’t found any where

  20. nani says:

    hi sir,
    how to save number of images into video format(sdcard images into one video file), image to video converting. plz help me.

  21. Partha says:

    Hi,

    I have installed all sdk,eclipse.But when i try to run emulator.exe, nothing is happening and emulator is not launching.

    Can you suggest what is the problem here?

    Thanks
    Partha

    • SmrutiRanjan says:

      It takes some time to launch.
      Goto Taskmanager and see if emulator.exe is there or not. if found emulator.exe, just close the process and start again.
      It will take some time (10-15 max) for first time.

  22. Partha says:

    OK

    Let me try once.

    Thanks

    Partha

  23. raja says:

    hai sir

    I am new to android.
    plz send me some projects with source code…
    That will help me to put a project into resume(am a fresher).

    thank you

  24. Ankush Aggarwal says:

    I downloaded the source code and tried importing it into eclipse. But I get an error on a lot of the files and am therefore not able to install it on my phone

  25. indu says:

    Hi I want to Create a math flash card app using a spinner can you help on it with some samples

  26. Ravikumar S says:

    Hello Sir,
    i am developing an app where image tagging is needed, m confused that how to start. Please help me i want to develop it as same as markers in maps.

  27. Swapnil says:

    Hi SmrutiRanjan sir,

    is there any multi-threaded code is available here..
    actually i am working on a app in which i have to use multi threading. for example one thread is taking care of UI while other thread is taking care of Bluetooth communication.

    if you can give some code to refer then it will be very helpful and i will get the idea how to perform communication between the threads,

    Thanks

  28. Raj Singh says:

    I really appreciate your attempt to help the android developer’s at their beginning level, great useful for student’s,
    It helped me a lot..
    Thank’s
    Please post more on database handling..

  29. Mike Schwarz says:

    Sorry for the massive paste. You can delete if need be.

  30. harish says:

    there is an error in ForgroungService.java
    setForground(true); The method setForeground(boolean) is undefined for the type ForegroundService

  31. Jason says:

    Hi sir,
    Can sir teach me how to develop a Password Manager application in android?
    I am new

  32. Rajeev says:

    Nice dude. .
    Just now i hv downloaded that file, i didn’t check wheather it is working. . but before that i want to thank you, bcoz it will be very useful for me as well as lot of peoples. .
    Great Job. .

  33. Vengateswaran says:

    Thank you so much, i am new to android, when running your sample code i am getting below two errors….
    “The method setForeground(boolean) is undefined for the type ForegroundService” in “ForegroundService.java” and the method is “stopForegroundCompat” and “startForegroundCompat”.

    Can you please give a solution for this

  34. Jalil Irfan says:

    Hi,

    Im in process of making an app where i have four spinners
    1st to select the city
    2nd the restaurant name,
    3rd to display the selected area of that restaurant
    3rd to display foods available

    it will be used from json

    can you kindly help me to get the idea or coding
    for these spinners either with the json or with local values

    Thanks

  35. Anand says:

    Thank you for your useful Api demos…once again thanks dude…

  36. justin says:

    Do you happen to have anything fro add to favorites or bookmarking articles

Leave a Reply

Your email address will not be published. Required fields are marked *


7 − two =

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

Close
Please support the site
By clicking any of these buttons you help our site to get better

Twitter

Facebook

Google+