Wednesday, November 18, 2015

Parse.com Android : Common Issues faced

If you have just started in the world of BASS service, you might have chosen Parse.com.
Although it has good tutorial for explaining things, still I think community support is not very good.
I also had hard time to try basic things. So let me share a complete tutorial for extracting some data from Parse.com. It will be more towards covering the known issues.

Step 1: Uploading Data
In Tutorial provided by Parse, they talked how you can create a ParseObject, and upload the data by putting.You can follow the Guide provided by Parse to do that. I instead use Import Data option in Data Browser. So create a Json file and upload it there. If you are facing any issue with uploading, like it should be in that particular format, I will suggest to download any existing Table such as User, and open the JSON file. Similar way you can do it. Remember the first name should be "results" only, otherwise it wont let you upload.

Step 2: Creating a subclass of ParseObject
Although you can use normal ParseObject class do that, I will suggest you to use your own customized subclass of ParseObject.
a) Use @ParseClassName("YOUR_CLASS_NAME")  annotation.
b) Keep the file name, class name and Table Name same.
c) There should be default constructor of your customized sub-class.
d) Create set/get method for your fields in the table.

Step3: Registering the subclass
In your Application class's onCreate() method: add this line before calling Parse.initialize() :
ParseObject.registerSubclass(YOUR_CLASS_NAME.class);

Step4: Query using the subclass
 ParseQuery query = Alert.getQuery();
query.findInBackground(); //see the last link to get the full code.

Step5: Manifest changes
a) Please make sure you have defined the name field in tag in AndroidManifest.xml. Better use the complete path.
b) Add android.permission.INTERNET and android.permission.ACCESS_NETWORK_STATE permission.

I think this covers pretty much all the points.  Let me know if you face any issues with it. Sorry for lousy writing.
Here is link for all code.



No comments: