red orange yellow green blue

Medal of Honor Stats App

Today is the day, and this app has now gone live!

If you play Medal of Honor 2010 and are interested in your stats on the go, then this app is definitely for you. Simply type your name into the editbox and click update. Your stats will be retrieved using and can be saved to use on a widget.

I’ve read Friday is the best day for updates and publishing to the Android Market because traffic is higher so hopefully I get some hits today.

What did I learn in doing this? Well, I learned that JSON is an interesting thing and that it is frustrating and confusing at first. It was a good case of trial and error and error and trial until I worked through it enough to be able to understand how the data was stored. However, once I figured that out, it was pretty smooth sailing with retrieving all of the information needed for my app.

// get the content of our entity
InputStream is = entity.getContent();

// convert our stream to a readable string
String result = ConvertStreamToString(is);

// make a JSON object out of our string
StatsObj = new JSONObject(result);

// get the array from our names of the JSON object
StatsNameArray = StatsObj.names();

// get the values from our arrays
StatsValArray = StatsObj.toJSONArray(StatsNameArray);

// i need only a specific array from
JSONArray array1 = StatsValArray.getJSONArray(3);

// i only want the first object (the player information)
JSONObject new1 = array1.getJSONObject(0);

// from here on information gathering!
// specific strings are needed to get correct information
String ClanTag = new1.getString("clantag");

What else did I learn? Java and XML is a lot different than C++ and XML. You have to use data factories to get the necessary objects to be able to read and write data. It was an interesting time looking around to find out how to do this in Java and also helper functions are great for doing this as well.

    public void XMLoutSerialize(XmlSerializer ser, String namespace, String tag, String text)
    				throws IllegalArgumentException, IllegalStateException, IOException
    	// simple function for one line tag, text, endtag functionality
    	ser.startTag(namespace, tag);
    	ser.endTag(namespace, tag);

Comments are closed.