Android: Updating You App – New Version

September 27, 2012

Now that the first version of my application is in the Play Store, i have started thinking on how i can improve on it and what i will need to have in Version 2.0

One of the things that bothered me with version 1 was that the data of my app was stored in the app and that made the app static

I decided to store the app data in the cloud and make my app dynamic

  • Created a Data Model for my application and mapped it to “Class” / “Table” in Parse
  • I stored data in the parse cloud – created CSV files with the data and use the CSV File Import in Parse
  • Updated the application to use the Parse Android API to do queries and retrieve the data from Parse. Check my blog entry on Android and Parse / First Parse Application to get more details. I am including a code snippet here that shows the usage of the Parse API

ParseQuery query = new ParseQuery(“VrChildrenContent”);
query.whereEqualTo(“ContentGroupName”, cartoonName);

try {
contentList = query.find();

} catch (ParseException e) {

}

I am not yet ready to deploy the second version, i may have some more enhancements to do. Once i am ready – I will also describe the process of changing the manifest to specify the new version no: etc.

BTW – Before I started changing code in my app, i created a copy of the app in eclipse and renamed it to VrChildren_v10, so i can go back to the deployed v1.0 at at anytime.

Advertisements

First Parse Application

September 16, 2012

Now you know what is Parse, how to get it and you have also initialized data in the Parse cloud that is going to be used by your Android application

You have also initialized Parse in your Android application using the initialize Parse code snippet

Now building the application is simple

  • Parse requires a call to the data on the cloud and therefore as we learnt earlier, we have to make this call asynchronously – you need a AsyncTask. Look at the private class RemoteDataTask  that extends AsyncTask
  • Learn to use the query language – it is simple : https://parse.com/docs/android_guide#queries
  • the rest of the steps are the same as you would do in a typical application – you have access to the data dynamically, build the adapter and associate the adapter to the view, do all this in in onPostExecute method
  • Enable internet access on your AndroidManifest file – <uses-permission android:name=”android.permission.INTERNET” />

public class MainActivity extends Activity {

private ListView categoryListView;
private ArrayAdapter<String> categoryListAdapter;
private List<ParseObject> categories;
private ArrayList<String> categoryList = new ArrayList<String>();

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initializeParse();
new RemoteDataTask().execute();

}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}

private void initializeParse() {
Parse.initialize(this, “NDUawcm7DwXAkkSnuLMMiG6waq7l2RgOOu6YOpZB”,
“z3OdV85A5Dvr3tj49M06nZ1GdvQFa4nJLzxxW6Ct”);
ParseUser.enableAutomaticUser();
ParseACL defaultACL = new ParseACL();
ParseACL.setDefaultACL(defaultACL, true);
}

private class RemoteDataTask extends
android.os.AsyncTask<Void, Void, Void> {
// Override this method to do custom remote calls
protected Void doInBackground(Void… params) {
// Gets the current list of Categories in sorted order
ParseQuery query = new ParseQuery(“Categories”);
query.orderByDescending(“_created_at”);

try {
categories = query.find();
Log.i(“MainActivity:RemoteDataTask:doInBackground:Categories:”,categories.toString());
} catch (ParseException e) {
Log.e(“MainActivity:RemoteDataTask:doInBackground:Exception Retrieving Categories:”,
e.getMessage());

}
return null;
}

protected void onPostExecute(Void result) {
// Put the list of categories into the list view
for (ParseObject category : categories) {
categoryList.add((String) category.get(“Name”));
}
categoryListView = (ListView) findViewById(R.id.categoryListView);
categoryListAdapter = new ArrayAdapter<String>(MainActivity.this,
R.layout.activity_main, R.id.categoryTextView, categoryList);
categoryListView.setAdapter(categoryListAdapter);
}

}

}


Getting Started with Parse

September 16, 2012
  • Register and get started with the basic plan
  • Create an application – just requires the name
  • Go to the Data Browser, choose the application and create a Class – this is equivalent to the Table in the DB
  • There are standard fields that come with every class and add additional columns you need – i just created a Name column
  • Start creating rows and add data to them – all the default columns will be auto filled, add values to the custom columns

Creating Table and Data in Parse

  • Copy the Application Id and Client Key from the Overview Page – you will need these to initialize in your android application java code

Keys required for Parse Application

  • In your main activity for the application that uses parse call the following initializeParse method from your onCreate method

              onCreate()

                    public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initializeParse();
}

initializeParse()

private void initializeParse() {
Parse.initialize(this, “NDUawcm7DwXAkkSnuLMMiG6waq7l2RgOOu6YOpZB”,
“z3OdV85A5Dvr3tj49M06nZ1GdvQFa4nJLzxxW6Ct”);
ParseUser.enableAutomaticUser();
ParseACL defaultACL = new ParseACL();
ParseACL.setDefaultACL(defaultACL, true);
}


Android and Parse

September 16, 2012

Parse: https://parse.com/ is a mobile app platform that allows you to store your applications data in the cloud. It has a full sdk that handles storage of basic data types, locations, photos, and query across them in just a few lines of code. It also comes with a data browser that lets you manage all your objects in an intuitive spreadsheet-like interface.

I plan to use parse in Android and will start with a basic plan [https://parse.com/plans]. In the next set of posts, i will provide examples of using Parse with Android