Pages

Showing posts with label episode. Show all posts
Showing posts with label episode. Show all posts

Friday, May 13, 2016

Android Developers Backstage Episode 9 Design

Tor and Chet make a startling break with ancient tradition and talk to a real, live designer in this episode: Christian Robertson from the Android User Experience team. Tune in to hear about the Roboto font that Christian created and about font design in general, plus design tips for layout, visual rhythm, and other Android designities.

Design: Its the new Develop.

Relevant links:
Android Design: https://developer.android.com/design/index.html
Android Style Guide: http://developer.android.com/design/style/index.html
Android Asset Studio: http://romannurik.github.io/AndroidAssetStudio/
Roboto: http://www.google.com/fonts/specimen/Roboto

Christian: https://plus.google.com/110879635926653430880/posts
Tor: google.com/+TorNorbye
Chet: google.com/+ChetHaase

Subscribe to the podcast in your favorite player or at http://feeds.feedburner.com/blogspot/AndroidDevelopersBackstage
Or just download the mp3 directly: http://storage.googleapis.com/androiddevelopers/android_developers_backstage/Android%20Developers%20Backstage%20Ep9%20Design.mp3
Read More..

Simple ListView Android Developer Tutorial Part 16

From exploring the various concepts related to fundamentals and to locations and maps, I would like to look at a few UI elements.


One of the simple views is a List View. In this post, I will explore a very simple list view using all the defaults provided by Android SDK and introduce you to a customized list view in the next blog article.

A List View, by name means being able to display a list of items in an order one below the other. For creating such a view, the first thing we have to do is extend the ‘ListActivity’ (android.app.ListActivity) instead of the normal Activity class.

So, here is how the class declaration should look:

public class MyListView extends ListActivity {
The ListActivity class provides a way of binding a source of data (an array or a cursor) to a ListView object through a ListAdapter.

In android, we all know that views are defined declaratively in XML files. It is the same here too. So, if we were to create our own custom ListView, we would have a declaration of this type:

<ListView android_id="@id/android:list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#000fff"
android:layout_weight="2"
android:drawSelectorOnTop="false">
</ListView>

However, if no ListView is declared, the ListActivity picks up a default ListView which fills the screen. So, in our example we will not declare any list view.

There is one more thing we need to define and that is how each row in the list should show up. This again, there are some defaults available which have names such as simple_list_item_1, simple_list_item_2, and two_line_list_item. So, in our example, I do not declare the layout for the rows but I will be using one of the defaults provided. So, in effect, I have not declared any layout – I am using the default screen layout and row layout.

Now, that we have the layouts out of our way, what else do we need for a List View. Of course, the list of data that needs to be displayed. Just to keep it simple, I will use an array of data for the same. So, here it is:

static final String[] PENS = new String[]{
"MONT Blanc",
"Gucci",
"Parker",
"Sailor",
"Porsche Design",
"Rotring",
"Sheaffer",
"Waterman"
};

Now, how do I bind this data to the default views described earlier? This is aided by a ListAdapter interface hosted by the ListActivity class that we have extended.

We need to use the setListAdapter(..) method of the ListActivity class to bid the two (data and view). Android provides many implementations of the ListAdapter. We will use the simple ArrayAdapter.

What does the ArrayAdapter expect?

It expects the context object, the row layout and the data in an array.

So here it is:

setListAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, PENS));
With this we are done in creating the ListView.

I have added a small piece of code to show we can handle events on selecting an item in the list, by overriding the protected method shown below:

protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
Object o = this.getListAdapter().getItem(position);
String pen = o.toString();
Toast.makeText(this, "You have chosen the pen: " + " " + pen, Toast.LENGTH_LONG).show();
}

This toasts a message with the item selected.

The complete code is downloadable here.

Read More..

Tuesday, May 10, 2016

Android Developers Backstage Episode 11 ART pART 2 Trash Talk

In this continuation of the previous gripping and suspenseful episode known as Episode 10, Tor and Chet hear more from Anwar Ghuloum from the Android Runtime team. This time is all trash-talk. Tune in to hear more about garbage collection and how allocation and collection performance is much faster with ART (and, more interestingly, why its faster).

Subscribe to the podcast feed or download the audio file directly.

ARTicles:
Introducing ART: http://source.android.com/devices/tech/dalvik/art.html
Verifying App Behavior: http://developer.android.com/guide/practices/verifying-apps-art.html

Video:
The ART Runtime: https://www.youtube.com/watch?v=EBlTzQsUoOw

Other Resources:
Systrace: http://developer.android.com/tools/help/systrace.html

Tor: google.com/+TorNorbye
Chet: google.com/+ChetHaase
Read More..

Monday, April 25, 2016

Android Developers Backstage Episode 13 Support Library


In this superstitiously numbered episode 13, Tor and Chet talk with Adam Powell of the UI Toolkit team about the Android support library, AppCompat, ListView, RecyclerView, and all sorts of other toolkit-related niceties.

Subscribe to the podcast feed or download the audio file directly.

Relevant Links:
Android Support Library: http://developer.android.com/tools/support-library/index.html
ActionBarSherlock: http://actionbarsherlock.com/

Adam: google.com/+AdamWPowell
Tor: google.com/+TorNorbye
Chet: google.com/+ChetHaase

Read More..

Saturday, April 16, 2016

Episode 30 Android Design Library

This time, Tor and Chet are joined by Chris Banes (again!) to talk about the new Android Design Library, which was released at Google I/O 2015. Listen in to find out all about CoordinatorLayout, FAB, Snackbar, and more, more, more!

Subscribe to the podcast feed or download the audio file directly.

Relevant Links:
Chriss blog
Android Design Library Demo
Android Design Support Library (Android Developers Blog)

Chris: google.com/+ChrisBanes
Tor: google.com/+TorNorbye
Chet: google.com/+ChetHaase

Read More..

Android Developers Backstage Episode 8 Volley



In this episode, the second in a bizarrely and completely unplanned series on Play Store technology, Tor Norbye and Chet Haase are joined by Ficus Kirkpatrick from the Play Store team (and from many other Android projects from the early days). Listen in to hear what Volley is for and how you can use it to simplify your network requests and bitmap download/caching code.

Relevant links:
Volley: https://android.googlesource.com/platform/frameworks/volley/
Volley email list: https://groups.google.com/forum/#!forum/volley-users
Gson adapter for Volley: https://gist.github.com/ficusk/5474673

Subscribe to the podcast at http://feeds.feedburner.com/blogspot/AndroidDevelopersBackstage?.
Or download directly at http://storage.googleapis.com/androiddevelopers/android_developers_backstage/Android%20Developers%20Backstage%20Ep%208%20Volley.mp3
Read More..

Friday, April 1, 2016

Android Developers Backstage Episode 5 RenderScript

Chet Haase and Tor Norbye are joined by Tim Murray from the RenderScript team.

In this episode, we dive into RenderScript and talk about compute, parallel processing, GPUs, and architecture-independent, high-performance pixel processing. Its intrinsically interesting.

To download the podcast click here.
Read More..

Wednesday, March 30, 2016

Android Developers Backstage Episode 10 ART pART 1

Tor and Chet may not know ART, but they know what they like. In this episode, the first in a two-pART series, they talk with Anwar Ghuloum from the ART, or Android Runtime team. ART is the new runtime for Android, which came online in the KitKat release as an alternative to Dalvik. Now ART is not only enabled by default: it’s the only runtime. We’ll talk about what it is, how it works, why it’s better, and the future and very meaning of ART in modern society.

Subscribe to the podcast feed or download the audio file directly.

ARTicles:
Introducing ART: http://source.android.com/devices/tech/dalvik/art.html
Verifying App Behavior: http://developer.android.com/guide/practices/verifying-apps-art.html

Google I/O 2014 Session:
The ART Runtime: https://www.youtube.com/watch?v=EBlTzQsUoOw

Other Resources:
Systrace: http://developer.android.com/tools/help/systrace.html

Tor: google.com/+TorNorbye
Chet: google.com/+ChetHaase
Read More..

Sunday, March 20, 2016

Simulate Location Change in Android Emulator

Start the Emulator
Start a command prompt
Start telnet
Then, type, o localhost 5554
This connects the telnet client to the android emulator (assuming emulator is running locally listening on port 5554. Else this connection fails)
Now type
geo fix 79.000000 13.000000 (or your latitude and longitude)
This sends the location change signal to the emulator.
NOTE: This is useful for applications built using Location APIs in Android and need to work with changes in location
Read More..

Friday, March 18, 2016

nbsp;&n"

local,service,android,tutorial,for,beginners,–,part,7
Read More..

Wednesday, March 16, 2016

Android Developers Backstage Episode 1 KitKat

Get an overview of the new features in Android 4.4 KitKat presented by members of the Android team. Chet Haase and Tor Norbye cover many of the new features including Transitions, Storage Access Framework, Immersive Mode, Printing API, and Closed Captioning.

Click here to download the podcast
Read More..

Monday, March 14, 2016

Android Developers Backstage Episode 12 The Jake Show

In a startling and electrifying break with ancient tradition (born of laziness rather than policy), Tor and Chet are joined in this podcast by external developer (i.e., non-Googler) Jake Wharton. Jake has worked on and with many important Android open source libraries. We talk with Jake about these projects and various other aspects of Android development in general.

Subscribe to the podcast feed or download the audio file directly.

Relevant Links:
Retrofit: http://square.github.io/retrofit/
Picasso: http://square.github.io/picasso/
Dagger: http://square.github.io/dagger/
OkHttp: http://square.github.io/okhttp/
Butter Knife: http://jakewharton.github.io/butterknife
Robolectric: http://robolectric.org/
Espresso: https://code.google.com/p/android-test-kit/
AssertJ Android: http://square.github.io/assertj-android

Jake: google.com/+JakeWharton
Tor: google.com/+TorNorbye
Chet: google.com/+ChetHaase

Read More..

Thursday, March 10, 2016

Custom ListView Android Developer Tutorial Part 17

Now, we shall look at creating a custom list view – a custom layout, a custom row layout and how we bind the custom data holder to these layouts. (please see the earlier article on simple list view for the fundamentals of list view).

So, here again, we start with extending ListActivity.
public class MyCustomListView extends ListActivity {

Now let us create the custom list view in an xml file – custom_list_view.xml. This will be set using the setContentView() in onCreate() method:
<ListView android_id="@id/android:list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#000fff"
android:layout_weight="2"
android:drawSelectorOnTop="false">
</ListView>
<TextView android_id="@id/android:empty"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFff00"
android:text="No data"
/>
Note that it must contain a ListView object with android:id="@id/android:list"

I have also declared a TextView which should be whon when the list if empty by declaring with android:id="@id/android:empty"

Now we will declare how each row in this ListView should be displayed by creating a new xml file – custom_row_view.xml

I plan to have 3 items one below the other in each row. So, here is the declaration for the same:
<TextView android_id="@+id/text1"
android:textSize="16sp"
android:textStyle="bold"
android:textColor="#FFFF00"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
<TextView android_id="@+id/text2"
android:textSize="12sp"
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="fill_parent"/>
<TextView android_id="@+id/text3"
android:typeface="sans"
android:textSize="14sp"
android:textStyle="italic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
So, now, how do I tie all of this together? The MyCustomListView class, the listview layout and the row layout. Just like in the earlier example, we need a ListAdpater object. Here I plan to use a SimpleAdpater provided by the SDK.

An adapter expects the context, the layout and the handle to the data that needs to be displayed. So, let us create a list of data in an ArrayList of HashMaps. This way, the HashMap can store any amount of data.

static final ArrayList<HashMap<String,String>> list =

new ArrayList<HashMap<String,String>>();
This is just a declaration of the list object. We need to populate it with data. Our custom row layout expects each row to have 3 prices of data…

This list is populated in a method as shown below with the 3 keys as ‘pen’, ‘price’ and ‘color’:

private void populateList() {
HashMap<String,String> temp = new HashMap<String,String>();
temp.put("pen","MONT Blanc");
temp.put("price", "200.00$");
temp.put("color", "Silver, Grey, Black");
list.add(temp);
HashMap<String,String> temp1 = new HashMap<String,String>();
temp1.put("pen","Gucci");
temp1.put("price", "300.00$");
temp1.put("color", "Gold, Red");
list.add(temp1);
HashMap<String,String> temp2 = new HashMap<String,String>();
temp2.put("pen","Parker");
temp2.put("price", "400.00$");
temp2.put("color", "Gold, Blue");
list.add(temp2);
HashMap<String,String> temp3 = new HashMap<String,String>();
temp3.put("pen","Sailor");
temp3.put("price", "500.00$");
temp3.put("color", "Silver");
list.add(temp3);
HashMap<String,String> temp4 = new HashMap<String,String>();
temp4.put("pen","Porsche Design");
temp4.put("price", "600.00$");
temp4.put("color", "Silver, Grey, Red");
list.add(temp4);
}
So, now how do we tie up the data with the row layout and the listview layout. It is in this simple piece of code in the onCreate() method of MyCustomListView class:
setContentView(R.layout.custom_list_view);
SimpleAdapter adapter = new SimpleAdapter(
this,
list,
R.layout.custom_row_view,
new String[] {"pen","price","color"},
new int[] {R.id.text1,R.id.text2, R.id.text3}

);
populateList();


setListAdapter(adapter);
Here we have set the default view to custom_list_view.
Then, using the SimpleAdapter, we have set the context, the list containing the data for display, the custom_row_view, the keys by which the data has to be fetched from the list, the TextViews into which the corresponding data has to be displayed.

Now execute and you will have a custom list view. Here is what you will get to see:


NOTE: if you do not populate the list with any data, you will see another view – the empty listview that we have defined in the custom_list_view.xml

You can download the complete source code for this example here.

Added later:
Based on a question below, I would like to add that an item can be clicked even in this custom list and the even captured by overriding the onListItemClick() method on the ListActivity class.

Here is the piece of code you can add to my sample, if you haev downlaoded and ti will toast a message on what has been selected:



protected void onListItemClick(ListView l, View v, int position, long id) {

    super.onListItemClick(l, v, position, id);
    Object o = this.getListAdapter().getItem(position);
    String pen = o.toString();
    Toast.makeText(this, "You have chosen the pen: " + " " + pen, Toast.LENGTH_LONG).show();
}

Enjoy....
Read More..

Wednesday, March 2, 2016

Location Manager Android Developer Tutorial Part 15


Location-based service is another key functionality that gets used by mobile applications. IT is often combined with maps to give a good user experience. We have already see how to use the external Google Maps API in tutorial Part 14. Here I will build upon the same to show how changes in location can be displayed on the map.
The location services are provided in the android.location package.


In order to use location services, our activity needs to implement the LocationManager Interface.
What does a LocationManager provide?


It is through this interface that an application can access the system’s location services. These services basically allow the application to obtain periodic updates of the device’s geographical location. It also helps in firing an application specific intent when the device comes within the proximity of a specified location.
Since in my example I want to simulate a location change and make my activity respond to the same, I am implementing this interface.


In order to make it an effective application, I have shown my location (hard-coded) on the google map. Then, I have used the location manager to handle any change in the location. The change in location needs to be simulated on the emulator by connecting through telnet. How to simulate location change is given at the end of this tutorial.


Now, dive into the code.


NOTE: I am adding the LocationManager implementation to the same MapActivity class created in the earlier tutorial (Part 14) and hence will not be explaining anything related to the maps API here.


Step 1: Obtain the LocationManager instance:


LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000L, 500.0f, this);


After getting the location manager, I am setting default GPS provider and asking to be notified if the location changes by more than 500 meters from the current location, the frequency of updation being 1 sec.


Step 2:Override the onLocationChanged() method in order to respond to changes in location.


      public voidonLocationChanged(Location location) {
            if (location != null) {
                  double lat = location.getLatitude();
                  double lng = location.getLongitude();
                  String currentLocation = "The location is changed to Lat: " + lat + " Lng: " + lng;
                  myLoc.setText(currentLocation);
                  geoPoint = new GeoPoint((int) lat * 1000000, (int) lng * 1000000);
                  myMC.animateTo(geoPoint);
            }
      }


This method gets invoked when we change the location through the telnet connection to the emulator as described at the end of the tutorial. Based on the latitude and the longitude settings sent, the GeoPoint is changed to display the new location.


That is it. I have not overridden any of the other methods provided by the locationManager. Complete code is downloadable here.



How to simulate location change in the emulator?
Start the Emulator from eclipse
Start a command prompt
Start telnet
Then, type, o localhost 5554
This connects the telnet client to the android emulator (assuming emulator is running locally listening on port 5554. Else this connection fails)
Now type
geo fix 79.000000 13.000000 (or your latitude and longitude)
This sends the location change signal to the emulator.

Read More..

Threads and Handlers Android Developer Tutorial Part 18

Any mobile software development needs to be done with an awareness of the end user experience. This is true in any other domain as well. But special mention here on mobile development as end users are used to responsive apps on the mobile and any small delay is perceived as un-responsiveness or worse – that the application has hung.

One of the basic principles to provide a very responsive application is to handle any time consuming code in a separate thread – not the main thread or the UI thread as it is also known. So, it is very essential to understand about how to spawn new threads (worker or background threads) and how to come back to the parent thread.

How do the 2 threads (parent/UI and the worker threads) communicate? Here comes the Handler. By definition – “A Handler allows you to send and process Message and Runnable objects associated with a threads MessageQueue. Each Handler instance is associated with a single thread and that threads message queue.”

So, let us take the handler from the main thread and see how we can use it to communicate with a child thread.

When a handler is created, it is associated by default with the current thread. So, we have this piece of code in the main activity class:



Now, I spawn a new thread through a method that is called when I click a button. So, let us see the button piece of code first:
private Handler messageHandler = new Handler() {
};
public void handleMessage(Message msg) {
super.handleMessage(msg);
progressDialog.dismiss();
}

start = (Button) findViewById(R.id.Button01);

start.setOnClickListener(new OnClickListener() {});
@Override
public void onClick(View arg0) {
fetchData();
}
Now, on click of the button, the fetchData() method is invoked. Assuming that this is a very time consuming task, I will spawn a thread and do the task and return from that thread as shown in the code below:

protected void fetchData() {


progressDialog = ProgressDialog.show(this, "", "Doing...");


new Thread() {


public void run() {
try {
    Thread.sleep(800);} catch (InterruptedException e) {
}
messageHandler.sendEmptyMessage(0);
}
       }.start();
    }


Since it is time consuming, I am starting a ProgressDialog just to inform the end user that some activity is happening. Then, I start the thread, make it sleep for 800 milliseconds and send back an empty message through the message handler. The messageHandler.sendEmptyMessage(0) is the callback on the parent thread’s messageHandler to inform that the child thread has finished its work. In this example I am sending an empty message. But this can be the means of communication and exchange of data from the child thread to the parent Thread.

Now the control returns to handleMessage() call back method. That method shown in the beginning just dismisses the progressDialog.

In real life cases, within this thread we can do things like calling web-services, calling web-sites to fetch specific data or doing network IO operations and returning actual data that needs to be displayed on the front-end.

I will take up an example of an HTTP call invoked through such a thread in the next tutorial.

Also note that the Android UI toolkit is not thread-safe and must always be manipulated on the UI thread only. So the child thread should return all data and the painting of the UI should be left to the main thread or any UI specific thread.

There is a better way of handling this through the use of AsyncTask, a utility class available from SDK 1.5 onwards. It was available as UserTask earlier.

Here is the complete downloadable code for this tutorial.
Read More..

Tuesday, March 1, 2016

Episode 19 Android TV

Tor and Chet talk with Tim Kilbourn from the Android TV team. Learn about developing apps for this new platform and hear about exciting things in the TV world like "overscan" and "D-pads".

Subscribe to the podcast feed or download the audio file directly.


Relevant Links:

TV Leanback API: https://developer.android.com/reference/android/support/v17/leanback/package-summary.html
Android Style Guide: http://developer.android.com/design/style/index.html
Nexus Player: https://play.google.com/store/devices/details?id=nexus_player
Gamepad for Nexus Player: https://play.google.com/store/devices/details?id=nexus_player_gamepad

Tim: google.com/+TimKilbourn
Tor: google.com/+TorNorbye
Chet: google.com/+ChetHaase

Read More..

Wednesday, February 24, 2016

Android Developers Backstage Episode 6 System UI

In this episode, we delve into the world of the Android System UI, including tangents on notifications new and old, status bar icons, implementing user experience designs, and Android logos.

Click here to download the Podcast directly!
Read More..

Saturday, February 20, 2016

Updating the past tutorials to Android SDK 2 0

Hi Friends,

It has been a couple of weeks since Android SDK 2.0 has been released. Since I have got caught up in many other demanding projects, I have not been able to find any time to update my tutorials sample code uploaded so far to be compatible to 2.0.
It would be wonderful if, as and when you try my tutorials, you can update / post your comments on deprecated APIs or newer APIs that need to be used.

Thanks.

Hi, I have written a few steps about upgrading to SDK 2.1 at http://saigeethamn.blogspot.com/2010/03/basic-steps-for-upgrading-source-code.html
Read More..

Friday, February 19, 2016

Android Simulating an Incoming call on Emulator


On windows XP, open a command console.
Type “telnet”. The telnet client starts.
Then, type, o localhost 5554
This connects the telnet client to the android emulator (assuming emulator is running locally listening on port 5554. Else this connection fails)
Now type
gsm call 123456
The last parameter could be any number.
This simulates a call to the emulator.

Read More..

Thursday, February 18, 2016

Shared Preferences Android Developer Tutorial Part 13


We saw in an earlier tutorial (Part 12) how data can be stored in SQLDB. However, many applications may provide a way to capture user preferences on the settings of a specific application or an activity. For supporting this, Android provides a simple set of APIs.


Preferences are typically name value pairs. They can be stored as “Shared Preferences” across various activities in an application (note currently it cannot be shared across processes). Or it can be something that needs to be stored specific to an activity (which is not discussed here).


The context object lets you retrieve SharedPreferencesthrough the method Context.getSharedPreferences().


In my example, I will set 2 preferences i.e. MyNameand MyWallpaperin one activity i.e ManageSharedPref.java. Retrieve these values in the next activity – ViewSharedPrefs.java. The second activity displays my preferred name in a list view and also resets the android wallpaper to the image that I had set as a preferred wallpaper in the first activity. When you run this application, if you come back to the home, you will see the wall paper is reset.


Here is the code in ManageSharesPrefs:


SharedPreferences myPrefs = this.getSharedPreferences("myPrefs", MODE_WORLD_READABLE);
        SharedPreferences.Editor prefsEditor = myPrefs.edit();
        prefsEditor.putString(MY_NAME, "Sai");
        prefsEditor.putString(MY_WALLPAPER, "f664.PNG");
        prefsEditor.commit();
       
First, I obtain a SharedPreferences object making it readable by all. The first parameter is a name of a file that stores my preferences. This automatically creates the xml file if it does not exist and then stores in the same.


Next, I edit it. That creates an editor object, using which I input my preferences. Here, for the wall paper, I have put an image name. I also need to push the actual image file into the android storage which I do this way.


adb push <local> <remote>


In this case it is


adb push f664.PNG /data/misc/wallpaper/f664.PNG


This command creates a folder called wallpaper in /data/misc and copies the f664.PNG file from my current location to the android storage.


When I click the “View Shared Preferences” button, I am taken to the next activity. Here is the code in ViewSharedPrefs that gets executed:


        SharedPreferences myPrefs = this.getSharedPreferences("myPrefs", MODE_WORLD_READABLE);
        String prefName = myPrefs.getString(MY_NAME, "nothing");
        String wallPaper = myPrefs.getString(MY_WALLPAPER, null);
       
        if(wallPaper != null) {
            try {
                  Bitmap bm = BitmapFactory.decodeFile("/data/misc/wallpaper/"+wallPaper);
                  Log.d(getClass().getSimpleName(),"Wallpaper name is: "+ wallPaper);
                  setWallpaper(bm);
                  Toast.makeText(this, "Wall paper has been changed." +
                              "You may go to the home screen to view the same", Toast.LENGTH_LONG).show();
            } catch (FileNotFoundException fe){
                  Log.e(getClass().getSimpleName(),"File not found");
            } catch (IOException ie) {
                  Log.e(getClass().getSimpleName()," IO Exception");
            }
           
        }
        ArrayList<String> results = new ArrayList<String>();
        results.add("Your Preferred name is: " + prefName);
      this.setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,results));

There are 3 steps to understand here:


1.    Step 1: Retrieve the shared prefs data from the object.


        SharedPreferences myPrefs = this.getSharedPreferences("myPrefs", MODE_WORLD_READABLE);
        String prefName = myPrefs.getString(MY_NAME, "nothing");
        String wallPaper = myPrefs.getString(MY_WALLPAPER, null);

2.    Step 2: Display the name
        ArrayList<String> results = new ArrayList<String>();
        results.add("Your Preferred name is: " + prefName);
      this.setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,results));

3.    Step 3: Reset the wall paper.
        if(wallPaper != null) {
            try {
                  Bitmap bm = BitmapFactory.decodeFile("/data/misc/wallpaper/"+wallPaper);
              
Read More..