In this example creating a tab layout to show different screen for each tab.
Creating three tabs and setting different images and screens for each tab.
- To Create Tab and Tab change listner Extend TabActivity and implements OnTabChangeListener.
- Create tabhost object to create tabs.
- Create three tabs name FOOD , GAME , SPORT and set background images.
- Create three activities add these tabs.
- Add Tabs to tabhost.
In This example creating Notification Alerts with the use of NotificationManager.
Some times we have requirement to show alert user from background services or from broadcast reciever then best way to notify user by Notification Alert
In This example calling restful webservice to get json data and parse that json data.
1. Call php file (php) from server and create JSON data in php.
2. Consume JSON data by android and show on activity.
3. Parse JSON data and Show parsed data on screen(activity).
In This example calling dot net webservice to get/send data to server. Using ksoap2-android-assembly-2.4-jar-with-dependencies.jar to make soap call.
Accessing a live web service ConvertWeight from http://www.webserviceX.NET/ which convert weight from one unit to another.
1. Add jar ksoap2-android-assembly-2.4-jar-with-dependencies.jar in your project.
2. Creating class WebserviceCall.java and define webservice namespace and url and make soap call. Accessing a live web service ConvertWeight from http://www.webserviceX.NET/ which convert weight from one unit to another.
3. Call WebserviceCall.java object to call getConvertedWeight method.
4. Showing response in a toast(alert) and on screen.
In this example we will see how to check internet connectivity.
When we have requirement to call file on server or call webservice then first check internet connctivity.
If internet connection is showing connected then we will call file on server or call webservice.
Required ACCESS_NETWORK_STATE permission in mainfest.xml file.
First Time User Please check previous example for normal file upload by server script( php | java | .net | coldfusion )
Upload File To Server - Android Example ( http://androidexample.com/Upload_File_To_Server_-_Android_Example/index.php?view=article_discription&aid=83&aaid=106 )
In this example uploading file on server by ftp client ( with the use of ftp4j-1.6.jar ).
1. Using ftp4j-1.6.jar from sauronsoftware repository. Download and Add ftp4j-1.6.jar as library.
2. Must be required a Server Dedicated IP for FTP File upload.
In This example taking a image from sdcard and skew / bind image with the use of matrix.
In This example creating a Swipe screen example .Swipe screen left / right / top / bottom , an alert will show.
In This project creating a incomming outgoing call log with call duration.
Created three broadcast reciever.
a. Broadcast Reciever for Incomming call (IncomingCall.java).
b. Broadcast Reciever for Outgoing call (OutgoingCall.java).
c. Broadcast Reciever for Call duration (CallDurationReceiver.java).
Created controller file Controller.java
Created a list to show what type of call log want to show. created three files
a. CallList.java to show call list options.
b. CallListData.java to create each row data in list.
c. CallListValues.java Model to store each row data for list.
DBAdapter.java to store call data in sqlite database.
CallDetailServer.java to store sqlite data to server and show call data to activity.
In This example creating a simple repeating alarm system with the use of AlarmManager. Alarm will start after each 2 mins.
1. Using AlarmManager class to repeating and called a PendingIntent after each 2 min.
2. Call a media file on PendingIntent and start media file.
3. So after each 2 min AlarmManager will call PendingIntent a media file start.
In this example broadcasting screen wake / sleep event with a service.
Some times we have requirement to make less battery consumption then you can stop your services when phone is going to sleep mode and again start your services when phone is going to wake.
1. Create a service inside main activity to get screen wake / sleep broadcast events.
2. Create a broadcast receiver inside service to get screen wake / sleep events.
3. Send screen wake/sleep value from broadcast receiver to Service.
In this example scaning for number of available wifi connections , Creating a broadcast receiver which will called when number of wifi connections changed.
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