In this example creating some UI elements on screen on run time. Creating textview , buttons dynamically and creating onclick listener for buttons. After click on button show index(id).
In this example defining variable in application context and you can use this variable as a Global variable. You can set value in this variable and get value on any activity / broadcast reci\\eiver / service in application context(environment).
In Further examples you will see good use of this way to follow SINGALTON pattern and MVC pattern in android.
Splash screen is an activity that will show for set time when your app is starting and after set time period redirect to application main scre
Lets splash screen show set time is 15 sec then in mean time when splash screen showing you can do these tasks...
1. You can download resources(images) from webserver to your phone.
2. You can make server call and get data from server.
3. Get data from network and save in database.
4. Show something about your app/company/brand on Splash screen.
In this example downloading images from web to a listview. Using lazy loading to download images in a listview. Using custom adapter to create lisview rows and using ImageLoader class to lazy load images from web and show in listview row.Click on listview showing image url in alert.
MainActivity.java : Initialize static image url in string array and create listview.
LazyImageLoadAdapter.java : Used to create each list row. Inflate tabitem.xml file for each row and call ImageLoader.java to download image from url and resize downloaded image cache on sdcard.
ImageLoader.java : Used to download image from url and resize downloaded image and make file cache on sdcard. Lazy load images for listview rows.
FileCache.java : Used to create folder at sdcard and create map to store downloaded image information.
MemoryCache.java : Used to set cache folder size limit ( How much mb/kb downloaded image cache folder will store ) and also used to clear cache files from sdcard.
Utils.java : Used to Create Cache image for images downloaded from web.
In this example detecting current running activity from top of the activity stack. In this way we can find out current running application and task.
1. Suppose you have a task like , when user opens message/phone call/any application screen then your app performs an action like start a music or vibration etc....
In this example getting registered email Accounts in android phone.
Getting primary(google) mail account and all registered acconts. Showing accounts on screen.
This android example will work in real device.
In this example detecting Accelerometer Motion, when Accelerometer force value cross thersold showing an alert for motion detected.
1. You can use this example in games based on Accelerometer Motion (Phone Tilt).
2. You can use this example for battary consumption when using GPS Calls. Combine Screen Wake Sleep Example with this example to consume less battary when calling GPS calls.Later We will give combined example to consume less battery.
Check this example in real device.
In this example detecting noice and setting a noise thersold , when this noise/sound frequency cross thersold ,example will show an alert.
When sound frequency threshold crossed you can send help SMS, Make new call etc..
In this example creating a custom Expandable ListView with parent and child rows. parent rows contains texts,images and a checkbox. child rows contains texts,images. Creating custom adapter to create Expandable ListView rows .
1. Create Model classes for parent rows(Parent.java) and for child rows(Child.java). These classes will use to store parent rows and child rows data.
2. Create xml files for parent rows(grouprow.xml) and for child rows(childrow.xml). These classes will use to create GUI for parent rows and child rows.
3. Create dummy data in parent and child model objects and Store objects in an ArrayList.
4. Create custom Adapter MyExpandableListAdapter class and inflate grouprow.xml file for parent rows() and childrow.xml for child rows. Use Models Parent.java and Child.java to create data for rows.
In this example reading Phone Contacts and showing these contacts name as Auto suggestions for TextView. After AutoComplete value selection showing selected contact phone number in alert.
AutoCompleteTextView is an editable text view that shows suggestions automatically while the user is entering characters. The list of suggestions is displayed from which the user can choose an item.
In this example taking array of strings and showing these strings as Auto suggestions for TextView. After AutoComplete value selection showing selected value in alert.
AutoCompleteTextView is an editable text view that shows suggestions automatically while the user is entering characters. The list of suggestions is displayed from which the user can choose an item.
In this example showing frame by frame animation (2D Animation).
Draw 18 images after some time frame by frame .
Founder of Android Example.com, love Java and open source stuff. Follow him on Twitter, or befriend him on Facebook.
Email: info@androidexample.com
Sign up our newsletter and get exclusive deals you will not find anywhere else straight to your inbox!
© 2024 AndroidExample All Rights Reserved.
This website uses cookies to ensure you get the best experience on our website. For more information Learn about cookies