I have created this blog to help programmers who have just started their career thats why I have written all the tutorials from practical approach rather then theoretical. If anyone has any query related to programming don't hesitate to ask. My contact information is in my profile. Also I would like to thank all the websites/Individual(s) from whom I gathered the material.
Showing posts with label activity. Show all posts
Showing posts with label activity. Show all posts
Saturday, October 15, 2011
Pass data from activity to service
Posted by
Zeeshan Ahmed Khan
at
10/15/2011 06:38:00 PM
Labels:
activity,
android,
pass data,
service
How to Update the UI in an Android Activity Using Data from a Background Service
http://www.websmithing.com/2011/02/01/how-to-update-the-ui-in-an-android-activity-using-data-from-a-background-service/
Posted by
Zeeshan Ahmed Khan
at
10/15/2011 06:37:00 PM
Labels:
activity,
android,
background,
service,
UI
Wednesday, September 21, 2011
Android - Accessing Your Preference From Hardware Menu Button
1) Create New XML File By Clicking "File->New->Other->Android XML File.
2) In Newly Open Dialog Box:
a) File = Name of Your Preference File Name
b) "In What type Of Resource would you like to create?" Select "PREFERENCE"
c) Don't Change The Folder Path
d) "In Select the root element for XML File" Select "PREFERENCESCREEN"
e) Click Finish.
3) Select The Type of Preference You want to add. All with very good exmaples are shown here
http://www.kaloer.com/android-preferences
4) In "AndroidManifest.xml" add the following segment
<activity
android:name=".Name_of_your_preference_file">
</activity>
5) Add New Activity which extends from PreferenceAcivity
*To know how to add new activity take a look here
http://codersapprentice.blogspot.com/2011/09/android-easiest-way-to-add-new-activity.html
6) In OnCreate function of the newly created Activity Add the following lines
addPreferencesFromResource(R.xml.mypeference);//Your Preference XML Resource
PreferenceManager.setDefaultValues(ApplicationPreference.this, R.xml.mypeference, false);//To Set Default Values
7) To Call Preference Screen From Hardware Menu Button Add the following code on the activity from which you want to call the preference:
@Override
public boolean onKeyDown(int keycode, KeyEvent event)
{
if(keycode == KeyEvent.KEYCODE_MENU)
{
Intent settingsActivity = new Intent(getApplicationContext(),ApplicationPreference.class);
startActivity(settingsActivity);
}
return super.onKeyDown(keycode,event);
}
Posted by
Zeeshan Ahmed Khan
at
9/21/2011 11:42:00 PM
Labels:
activity,
add preference,
android,
hardware,
intent,
menu button,
preference
Android - Easiest Way to Add New Activity
you can create the activity via the manifest editor like this:
- Double click on AndroidManifest.xml in the package explorer.
- Click on the "Application" tab of the manifest editor
- Click on "Add.." under the "Application Nodes" heading (bottom left of the screen)
- Choose Activity from the list in the dialog that pops up (if you have the option, you want to create a new top-level element)
- Click on the "Name*" link under the "Attributes for" header (bottom right of the window) to create a class for the new activity.
When you click Finish from the new class dialog, it'll take you to your new activity class so you can start coding.
Posted by
Zeeshan Ahmed Khan
at
9/21/2011 12:15:00 AM
Labels:
activity,
android,
designer window,
new,
UI
Subscribe to:
Posts (Atom)