[GUIDE] Working with Parse | Push notifications | Users | Saving data | More

Search This thread

MaartenXDA

Senior Member
Oct 2, 2012
1,971
1,159
Amsterdam
Hey guys!

I know most of you have never heard of this, but there's a organisation that provides many useful things to use in your app!

It's called "Parse"

Now, I will guide you trough the use of Parse, beginning with Parse Push. Let's get started, shall we?


Section 1:
push_logo.png


Okay, so Parse Push is a "library" or service that makes it A LOT easier to send push notifications to the users of your app. I had searched for months on how to send push notifications, but I just never succeeded (And I can't afford a proper server :p). But that's where Parse Push comes in!

The first thing you'll have to do to setup Parse Push is download and install the Parse SDK. This is how:

Step 1: Make an account at Parse.com and setup the app you want to include Parse in.

Step 2: Download the SDK: https://parse.com/downloads/android/Parse/latest

Step 3: Unzip it into a random folder

Step 4: Copy all the files in your projects "lib" folder. If your project doesn't have one, simply make one in the root of your directory (e.g /MyApp/lib/)

Step 5: Call the "initialize" method in your onCreate method, like this:
Code:
Parse.initialize(this, "Your application ID", "Your client key");
NOTE: You can find you application ID and client key here: https://parse.com/apps/YOUR-APP'S-NAME/edit#app_keys
NOTE: Be sure you also imported these calls:
Code:
import com.parse.Parse;
import com.parse.ParseAnalytics;

Step 6: Your app needs the android.permission.INTERNET and android.permission.ACCESS_NETWORK_STATE permission to work with Parse, so add these lines in your AndroidManifest.xml file, right before the <application> tag:
Code:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

Also, add this between the <application> and </application> tag:
Code:
<service android:name="com.parse.PushService" />
	<receiver android:name="com.parse.ParseBroadcastReceiver">

Step 7: Place this code in your onCreate method to track how many times your app has been opened:
Code:
ParseAnalytics.trackAppOpened(getIntent());

Step 8: It's testing time!
To test if your app has been setup the right way, add this code to your onCreate method:
Code:
ParseObject object = new ParseObject("TestObject");
object.put("name", "testname");
object.saveInBackground();
And run your app!

Step 9: Get your data trough a web browser! Go to this site: https://parse.com/apps/YOUR-APP'S-NAME/collections
Then it should say something like: TestObject (1), with the name testname :)

Step 10: Send a push notification: Goto https://parse.com/apps/YOUR-APP'S-NAME/push_notifications and click on + Send a push

Type in your message, hit Send notification at the bottom and your app will get a push notification!

That's it! You have now setup your app to receive push notifications :D
 

MaartenXDA

Senior Member
Oct 2, 2012
1,971
1,159
Amsterdam
Okay, here we go, the next section :D


Section 2: Parse Users

So, the ParseUser class is a really useful thingy for people who want to have some more control over the people who use their apps.
You can (for example) set a username, and then when the user wants to post something in the app, instead of him having to type his name all over again, the app can just use the ParseUser.getCurrentUser().getUsername() method, and it will automatigally get the user's name for him!

Now I'll show you how to setup a ParseUser:

Step 1: Setup everything in the same way as you did in Section 1

Step 2: First we'll have to make a ParseUser, by signing up. Here's a quick signing up code snippet:
Code:
 ParseUser signup = new ParseUser();
signup.setUsername("testuser");
signup.setPassword("testpassword");
signup.signUpInBackground(new SignUpCallback() {
			  public void done(ParseException e) {
			    if (e == null) {
			      // Hooray! Let them use the app now.
                              // The user also is logged in now :)
			    	
			    } else {
			      // Sign up didn't succeed. Look at the ParseException
			      // to figure out what went wrong
			      // Mostly the problem is that the username is already taken
                             	
			    }

But, ofcourse the user wants to choose his own username and password. For that you can use an EditText:

Code:
EditText username = (EditText) findViewById(R.id.USERNAMEEDITTEXTiD);
EditText password = (EditText) findViewById(R.id.PASSWORDEDITTEXTiD);

 ParseUser signup = new ParseUser();
signup.setUsername(username.getText().toString());
signup.setPassword(password.getText().toString());
signup.signUpInBackground(new SignUpCallback() {
			  public void done(ParseException e) {
			    if (e == null) {
			      // Hooray! Let them use the app now.
                              // The user also is logged in now :)
			    	
			    } else {
			      // Sign up didn't succeed. Look at the ParseException
			      // to figure out what went wrong
			      // Mostly the problem is that the username is already taken
                             	
			    }

But, if the user didn't type in anything, signin up throws a IllegalArgumentException. You can avoid that by using try and catch claws, like in this example:
Code:
EditText username = (EditText) findViewById(R.id.USERNAMEEDITTEXTiD);
EditText password = (EditText) findViewById(R.id.PASSWORDEDITTEXTiD);

try {

 ParseUser signup = new ParseUser();
signup.setUsername(username.getText().toString());
signup.setPassword(password.getText().toString());
signup.signUpInBackground(new SignUpCallback() {
			  public void done(ParseException e) {
			    if (e == null) {
			      // Hooray! Let them use the app now.
                              // The user also is logged in now :)
			    	
			    } else {
			      // Sign up didn't succeed. Look at the ParseException
			      // to figure out what went wrong
			      // Mostly the problem is that the username is already taken
                             	
			    }
} catch (IllegalArgumentException IO {
// The user didn't type in anything, I suggest using a Toast to notify him

}

Now, if a user wants to post something using his account name, you can get his username using this:
Code:
ParseUser currentUser = ParseUser.getCurrentUser();
currentUser.getUsername();

If your user wants to login, you can use this:
Code:
EditText username = (EditText) findViewById(R.id.USERNAMEEDITTEXT);
EditText password = (EditText) findViewById(R.id.PASSWORDEDITTEXT);

ParseUser.logInInBackground(username.getText().toString(), password .getText().toString(), new LogInCallback() {
			  public void done(ParseUser user, ParseException e) {
			    if (user != null) {
			      // Hooray! The user is logged in.
			    	
			    	
			    	
			    } else {
			      // Signup failed. Look at the ParseException to see what happened.
			      // The main cause is that the user didn't type in a correct username or password
			    	
			    }
			  }
			});

And if you want to log the user out, you can do it very simply by calling:
Code:
ParseUser.logOut();

And that's it! You just learned how to signup a user, log him in, get his username and log him out!

Now it's time for the next section!
 
Last edited:

MaartenXDA

Senior Member
Oct 2, 2012
1,971
1,159
Amsterdam
Time for section 3!

Section 3: Parse Data

Huh, what is Parse Data? Well, that's a good question sir! :)P) Parse Data will let you save ParseObjects into the Parse Cloud. That will allow you to store all of your data, and if you want you can read it back too! This could be useful for games with highscores, forum apps and more! Another great part of Parse!

Let's start with saving a ParseObject to the cloud, shall we?

Step 1: Setup your app the same way you did in Section 1

Step 2: We'll start with a really simple ParseObject, for now it's going to be called "testObject"
Here's a quick example for a ParseObject that will save to the cloud:
Code:
ParseObject testObject= new ParseObject("testObject");
		
		testObject.put("name", "TestObject's name");
                testObject.put("random",true);
                testObject.put("someint", 1337);
                testObject.saveInBackground();

As you can see, we can put everything we want in it (e.g. testObject.put("ASDASDASDA", "ASDASDASD");)
They don't always have to be strings, they can be booleans, ints, strings, JSON objects, java.util.Date, byte[] or ParseObjects(That's right, you can save a ParseObject inside a ParseObject :eek:)

You can also wait for the user untill he has an internet connection, and when he finally has, save the object:
Code:
ParseObject testObject= new ParseObject("testObject");
		
		testObject.put("name", "TestObject's name");
                testObject.put("random",true);
                testObject.put("someint", 1337);
                testObject.saveEventually();

For retreiving the object, you can do something like this:
Code:
ParseQuery<ParseObject> query = ParseQuery.getQuery("testObject");
query.getInBackground("YOUROBJECTID", new GetCallback<ParseObject>() {
  public void done(ParseObject object, ParseException e) {
    if (e == null) {
      // everything went okay :D
    } else {
      // something went wrong D:
    }
  }
})

Updating a ParseObject is really simple, just use the same as you did before, but with new data in the testObject.put("somedata", "the data"); section

Deleting it is farely simple as well, just use this:
Code:
testObject.deleteInBackground();

You can also delete just one field:
Code:
testObject.remove("name");
testObject.saveInBackground();

And that's it for now!
 
Last edited:

nikwen

Senior Member
Feb 1, 2013
3,142
1,597
Berlin, Germany
www.nikwen.de
Wow! Great. :good:

Thanks. :)

How much is the 1 GB per month which you get for free?
EDIT: Saw that this is the storage. You get 1,000,000 notifications for free.
 
Last edited:

nikwen

Senior Member
Feb 1, 2013
3,142
1,597
Berlin, Germany
www.nikwen.de
Ok. Just saw that you get 1,000,000 messages for free.
That is great for small apps but if you go beyond that, it will be very expensive. However, I cannot compare it to the price of a server.

Any experiences?
 
  • Like
Reactions: dukedusty

MaartenXDA

Senior Member
Oct 2, 2012
1,971
1,159
Amsterdam
Ok. Just saw that you get 1,000,000 messages for free.
That is great for small apps but if you go beyond that, it will be very expensive. However, I cannot compare it to the price of a server.

Any experiences?
Yeah, well, the internet keeps getting more and more expensive. I don't like it either, but my app isn't that big so I can live with it


ParseData section updated!
 
  • Like
Reactions: nikwen

xpirt

Recognized Developer / Inactive RC
Feb 19, 2013
5,070
21,223
Good job Maarten! So this is your method..! xD :D
Keep it up! ;)

xpirt
 

Sandy||Striker

Senior Member
Aug 5, 2011
108
24
faridabad
help needed

Code:
public void onClick(View arg0) {
		// TODO Auto-generated method stub
		switch (arg0.getId()){
		case R.id.bgo2:
			
			try{
				
				username=et1.getText().toString();
				password=et2.getText().toString();
			ParseUser signup = new ParseUser();
			signup.setUsername(username);
			signup.setPassword(password);
			signup.signUpInBackground(new SignUpCallback() {
			  public void done(ParseException e) {
			    if (e == null) {
			      // Hooray! Let them use the app now.
			    	Intent i = new Intent(MainActivity.this,Slider.class);
					startActivity(i);
			    } else {
			      // Sign up didn't succeed. Look at the ParseException
			      // to figure out what went wrong
			    	Toast.makeText(MainActivity.this, "something wrong" , Toast.LENGTH_SHORT).show();
			    }
			  }
			});
			} catch (IllegalArgumentException IO) {
				// The user didn't type in anything, I suggest using a Toast to notify him
				Toast.makeText(MainActivity.this, "Please type something" , Toast.LENGTH_SHORT).show();
				}

this is my code for signup on click of a button. everything is setup. but nothing happens when i click on sighn up button. and when i click on sigh in.. the app exits with an error. logcat says:-

Code:
06-03 11:55:41.761: E/SpannableStringBuilder(15340): SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
06-03 11:55:41.761: E/SpannableStringBuilder(15340): SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
06-03 11:55:42.178: E/NativeCrypto(15340): ssl=0x52f7c578 cert_verify_callback x509_store_ctx=0x52112a80 arg=0x0
06-03 11:55:42.178: E/NativeCrypto(15340): ssl=0x52f7c578 cert_verify_callback calling verifyCertificateChain authMethod=RSA
06-03 11:55:50.001: E/AndroidRuntime(15340): FATAL EXCEPTION: main
06-03 11:55:50.001: E/AndroidRuntime(15340): java.lang.IllegalArgumentException: Must specify a username for the user to log in with
06-03 11:55:50.001: E/AndroidRuntime(15340): 	at com.parse.ParseUser.logInAsync(ParseUser.java:655)
06-03 11:55:50.001: E/AndroidRuntime(15340): 	at com.parse.ParseUser.logInInBackground(ParseUser.java:715)
06-03 11:55:50.001: E/AndroidRuntime(15340): 	at com.sandy.letsfixthat.MainActivity.onClick(MainActivity.java:98)
06-03 11:55:50.001: E/AndroidRuntime(15340): 	at android.view.View.performClick(View.java:4091)
06-03 11:55:50.001: E/AndroidRuntime(15340): 	at android.view.View$PerformClick.run(View.java:17072)
06-03 11:55:50.001: E/AndroidRuntime(15340): 	at android.os.Handler.handleCallback(Handler.java:615)
06-03 11:55:50.001: E/AndroidRuntime(15340): 	at android.os.Handler.dispatchMessage(Handler.java:92)
06-03 11:55:50.001: E/AndroidRuntime(15340): 	at android.os.Looper.loop(Looper.java:153)
06-03 11:55:50.001: E/AndroidRuntime(15340): 	at android.app.ActivityThread.main(ActivityThread.java:5086)
06-03 11:55:50.001: E/AndroidRuntime(15340): 	at java.lang.reflect.Method.invokeNative(Native Method)
06-03 11:55:50.001: E/AndroidRuntime(15340): 	at java.lang.reflect.Method.invoke(Method.java:511)
06-03 11:55:50.001: E/AndroidRuntime(15340): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:821)
06-03 11:55:50.001: E/AndroidRuntime(15340): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
06-03 11:55:50.001: E/AndroidRuntime(15340): 	at dalvik.system.NativeStart.main(Native Method)
06-03 11:55:56.435: E/Trace(15377): error opening trace file: No such file or directory (2)
06-03 11:55:56.452: E/com.parse.PushService(15377): The Parse push service cannot start because Parse.initialize has not yet been called. 
													If you call Parse.initialize from an Activity's onCreate, that call should instead be in the Application.onCreate. 
													Be sure your Application class is registered in your AndroidManifest.xml with the android:name property of your <application> tag.
push notification working fine for me.
 

nikwen

Senior Member
Feb 1, 2013
3,142
1,597
Berlin, Germany
www.nikwen.de
Code:
public void onClick(View arg0) {
		// TODO Auto-generated method stub
		switch (arg0.getId()){
		case R.id.bgo2:
			
			try{
				
				username=et1.getText().toString();
				password=et2.getText().toString();
			ParseUser signup = new ParseUser();
			signup.setUsername(username);
			signup.setPassword(password);
			signup.signUpInBackground(new SignUpCallback() {
			  public void done(ParseException e) {
			    if (e == null) {
			      // Hooray! Let them use the app now.
			    	Intent i = new Intent(MainActivity.this,Slider.class);
					startActivity(i);
			    } else {
			      // Sign up didn't succeed. Look at the ParseException
			      // to figure out what went wrong
			    	Toast.makeText(MainActivity.this, "something wrong" , Toast.LENGTH_SHORT).show();
			    }
			  }
			});
			} catch (IllegalArgumentException IO) {
				// The user didn't type in anything, I suggest using a Toast to notify him
				Toast.makeText(MainActivity.this, "Please type something" , Toast.LENGTH_SHORT).show();
				}

this is my code for signup on click of a button. everything is setup. but nothing happens when i click on sighn up button. and when i click on sigh in.. the app exits with an error. logcat says:-

Code:
06-03 11:55:41.761: E/SpannableStringBuilder(15340): SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
06-03 11:55:41.761: E/SpannableStringBuilder(15340): SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
06-03 11:55:42.178: E/NativeCrypto(15340): ssl=0x52f7c578 cert_verify_callback x509_store_ctx=0x52112a80 arg=0x0
06-03 11:55:42.178: E/NativeCrypto(15340): ssl=0x52f7c578 cert_verify_callback calling verifyCertificateChain authMethod=RSA
06-03 11:55:50.001: E/AndroidRuntime(15340): FATAL EXCEPTION: main
06-03 11:55:50.001: E/AndroidRuntime(15340): java.lang.IllegalArgumentException: Must specify a username for the user to log in with
06-03 11:55:50.001: E/AndroidRuntime(15340): 	at com.parse.ParseUser.logInAsync(ParseUser.java:655)
06-03 11:55:50.001: E/AndroidRuntime(15340): 	at com.parse.ParseUser.logInInBackground(ParseUser.java:715)
06-03 11:55:50.001: E/AndroidRuntime(15340): 	at com.sandy.letsfixthat.MainActivity.onClick(MainActivity.java:98)
06-03 11:55:50.001: E/AndroidRuntime(15340): 	at android.view.View.performClick(View.java:4091)
06-03 11:55:50.001: E/AndroidRuntime(15340): 	at android.view.View$PerformClick.run(View.java:17072)
06-03 11:55:50.001: E/AndroidRuntime(15340): 	at android.os.Handler.handleCallback(Handler.java:615)
06-03 11:55:50.001: E/AndroidRuntime(15340): 	at android.os.Handler.dispatchMessage(Handler.java:92)
06-03 11:55:50.001: E/AndroidRuntime(15340): 	at android.os.Looper.loop(Looper.java:153)
06-03 11:55:50.001: E/AndroidRuntime(15340): 	at android.app.ActivityThread.main(ActivityThread.java:5086)
06-03 11:55:50.001: E/AndroidRuntime(15340): 	at java.lang.reflect.Method.invokeNative(Native Method)
06-03 11:55:50.001: E/AndroidRuntime(15340): 	at java.lang.reflect.Method.invoke(Method.java:511)
06-03 11:55:50.001: E/AndroidRuntime(15340): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:821)
06-03 11:55:50.001: E/AndroidRuntime(15340): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
06-03 11:55:50.001: E/AndroidRuntime(15340): 	at dalvik.system.NativeStart.main(Native Method)
06-03 11:55:56.435: E/Trace(15377): error opening trace file: No such file or directory (2)
06-03 11:55:56.452: E/com.parse.PushService(15377): The Parse push service cannot start because Parse.initialize has not yet been called. 
													If you call Parse.initialize from an Activity's onCreate, that call should instead be in the Application.onCreate. 
													Be sure your Application class is registered in your AndroidManifest.xml with the android:name property of your <application> tag.
push notification working fine for me.

I think that the EditText for the username is empty.

Quote from second post:

But, if the user didn't type in anything, signin up throws a IllegalArgumentException.
 

nikwen

Senior Member
Feb 1, 2013
3,142
1,597
Berlin, Germany
www.nikwen.de
no its not empty.. i tried with a few entries.. it is not signing up users??
the above code is for signing the new users

Just checked the logs again. They contain instructions to get it working:

The Parse push service cannot start because Parse.initialize has not yet been called.
If you call Parse.initialize from an Activity's onCreate, that call should instead be in the Application.onCreate.
Be sure your Application class is registered in your AndroidManifest.xml with the android:name property of your <application> tag.
 

Sandy||Striker

Senior Member
Aug 5, 2011
108
24
faridabad
@nikwen
this is the error now
i am getting this on clicking signup button
Code:
06-03 12:12:51.893: E/SpannableStringBuilder(22529): SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
06-03 12:12:51.893: E/SpannableStringBuilder(22529): SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
06-03 12:12:59.150: E/AndroidRuntime(22529): FATAL EXCEPTION: main
06-03 12:12:59.150: E/AndroidRuntime(22529): java.lang.NullPointerException
06-03 12:12:59.150: E/AndroidRuntime(22529): 	at com.sandy.letsfixthat.MainActivity.onClick(MainActivity.java:55)
06-03 12:12:59.150: E/AndroidRuntime(22529): 	at android.view.View.performClick(View.java:4091)
06-03 12:12:59.150: E/AndroidRuntime(22529): 	at android.view.View$PerformClick.run(View.java:17072)
06-03 12:12:59.150: E/AndroidRuntime(22529): 	at android.os.Handler.handleCallback(Handler.java:615)
06-03 12:12:59.150: E/AndroidRuntime(22529): 	at android.os.Handler.dispatchMessage(Handler.java:92)
06-03 12:12:59.150: E/AndroidRuntime(22529): 	at android.os.Looper.loop(Looper.java:153)
06-03 12:12:59.150: E/AndroidRuntime(22529): 	at android.app.ActivityThread.main(ActivityThread.java:5086)
06-03 12:12:59.150: E/AndroidRuntime(22529): 	at java.lang.reflect.Method.invokeNative(Native Method)
06-03 12:12:59.150: E/AndroidRuntime(22529): 	at java.lang.reflect.Method.invoke(Method.java:511)
06-03 12:12:59.150: E/AndroidRuntime(22529): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:821)
06-03 12:12:59.150: E/AndroidRuntime(22529): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
06-03 12:12:59.150: E/AndroidRuntime(22529): 	at dalvik.system.NativeStart.main(Native Method)
 
Last edited:

nikwen

Senior Member
Feb 1, 2013
3,142
1,597
Berlin, Germany
www.nikwen.de
@nikwen
this is the error now
i am getting this on clicking signup button
Code:
06-03 12:12:51.893: E/SpannableStringBuilder(22529): SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
06-03 12:12:51.893: E/SpannableStringBuilder(22529): SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
06-03 12:12:59.150: E/AndroidRuntime(22529): FATAL EXCEPTION: main
06-03 12:12:59.150: E/AndroidRuntime(22529): java.lang.NullPointerException
06-03 12:12:59.150: E/AndroidRuntime(22529): 	at com.sandy.letsfixthat.MainActivity.onClick(MainActivity.java:55)
06-03 12:12:59.150: E/AndroidRuntime(22529): 	at android.view.View.performClick(View.java:4091)
06-03 12:12:59.150: E/AndroidRuntime(22529): 	at android.view.View$PerformClick.run(View.java:17072)
06-03 12:12:59.150: E/AndroidRuntime(22529): 	at android.os.Handler.handleCallback(Handler.java:615)
06-03 12:12:59.150: E/AndroidRuntime(22529): 	at android.os.Handler.dispatchMessage(Handler.java:92)
06-03 12:12:59.150: E/AndroidRuntime(22529): 	at android.os.Looper.loop(Looper.java:153)
06-03 12:12:59.150: E/AndroidRuntime(22529): 	at android.app.ActivityThread.main(ActivityThread.java:5086)
06-03 12:12:59.150: E/AndroidRuntime(22529): 	at java.lang.reflect.Method.invokeNative(Native Method)
06-03 12:12:59.150: E/AndroidRuntime(22529): 	at java.lang.reflect.Method.invoke(Method.java:511)
06-03 12:12:59.150: E/AndroidRuntime(22529): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:821)
06-03 12:12:59.150: E/AndroidRuntime(22529): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
06-03 12:12:59.150: E/AndroidRuntime(22529): 	at dalvik.system.NativeStart.main(Native Method)

The error is in line 55 in MainActivity.java.

Could you please highlight this line?
 

Top Liked Posts

  • There are no posts matching your filters.
  • 9
    Hey guys!

    I know most of you have never heard of this, but there's a organisation that provides many useful things to use in your app!

    It's called "Parse"

    Now, I will guide you trough the use of Parse, beginning with Parse Push. Let's get started, shall we?


    Section 1:
    push_logo.png


    Okay, so Parse Push is a "library" or service that makes it A LOT easier to send push notifications to the users of your app. I had searched for months on how to send push notifications, but I just never succeeded (And I can't afford a proper server :p). But that's where Parse Push comes in!

    The first thing you'll have to do to setup Parse Push is download and install the Parse SDK. This is how:

    Step 1: Make an account at Parse.com and setup the app you want to include Parse in.

    Step 2: Download the SDK: https://parse.com/downloads/android/Parse/latest

    Step 3: Unzip it into a random folder

    Step 4: Copy all the files in your projects "lib" folder. If your project doesn't have one, simply make one in the root of your directory (e.g /MyApp/lib/)

    Step 5: Call the "initialize" method in your onCreate method, like this:
    Code:
    Parse.initialize(this, "Your application ID", "Your client key");
    NOTE: You can find you application ID and client key here: https://parse.com/apps/YOUR-APP'S-NAME/edit#app_keys
    NOTE: Be sure you also imported these calls:
    Code:
    import com.parse.Parse;
    import com.parse.ParseAnalytics;

    Step 6: Your app needs the android.permission.INTERNET and android.permission.ACCESS_NETWORK_STATE permission to work with Parse, so add these lines in your AndroidManifest.xml file, right before the <application> tag:
    Code:
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

    Also, add this between the <application> and </application> tag:
    Code:
    <service android:name="com.parse.PushService" />
    	<receiver android:name="com.parse.ParseBroadcastReceiver">

    Step 7: Place this code in your onCreate method to track how many times your app has been opened:
    Code:
    ParseAnalytics.trackAppOpened(getIntent());

    Step 8: It's testing time!
    To test if your app has been setup the right way, add this code to your onCreate method:
    Code:
    ParseObject object = new ParseObject("TestObject");
    object.put("name", "testname");
    object.saveInBackground();
    And run your app!

    Step 9: Get your data trough a web browser! Go to this site: https://parse.com/apps/YOUR-APP'S-NAME/collections
    Then it should say something like: TestObject (1), with the name testname :)

    Step 10: Send a push notification: Goto https://parse.com/apps/YOUR-APP'S-NAME/push_notifications and click on + Send a push

    Type in your message, hit Send notification at the bottom and your app will get a push notification!

    That's it! You have now setup your app to receive push notifications :D
    3
    Okay, here we go, the next section :D


    Section 2: Parse Users

    So, the ParseUser class is a really useful thingy for people who want to have some more control over the people who use their apps.
    You can (for example) set a username, and then when the user wants to post something in the app, instead of him having to type his name all over again, the app can just use the ParseUser.getCurrentUser().getUsername() method, and it will automatigally get the user's name for him!

    Now I'll show you how to setup a ParseUser:

    Step 1: Setup everything in the same way as you did in Section 1

    Step 2: First we'll have to make a ParseUser, by signing up. Here's a quick signing up code snippet:
    Code:
     ParseUser signup = new ParseUser();
    signup.setUsername("testuser");
    signup.setPassword("testpassword");
    signup.signUpInBackground(new SignUpCallback() {
    			  public void done(ParseException e) {
    			    if (e == null) {
    			      // Hooray! Let them use the app now.
                                  // The user also is logged in now :)
    			    	
    			    } else {
    			      // Sign up didn't succeed. Look at the ParseException
    			      // to figure out what went wrong
    			      // Mostly the problem is that the username is already taken
                                 	
    			    }

    But, ofcourse the user wants to choose his own username and password. For that you can use an EditText:

    Code:
    EditText username = (EditText) findViewById(R.id.USERNAMEEDITTEXTiD);
    EditText password = (EditText) findViewById(R.id.PASSWORDEDITTEXTiD);
    
     ParseUser signup = new ParseUser();
    signup.setUsername(username.getText().toString());
    signup.setPassword(password.getText().toString());
    signup.signUpInBackground(new SignUpCallback() {
    			  public void done(ParseException e) {
    			    if (e == null) {
    			      // Hooray! Let them use the app now.
                                  // The user also is logged in now :)
    			    	
    			    } else {
    			      // Sign up didn't succeed. Look at the ParseException
    			      // to figure out what went wrong
    			      // Mostly the problem is that the username is already taken
                                 	
    			    }

    But, if the user didn't type in anything, signin up throws a IllegalArgumentException. You can avoid that by using try and catch claws, like in this example:
    Code:
    EditText username = (EditText) findViewById(R.id.USERNAMEEDITTEXTiD);
    EditText password = (EditText) findViewById(R.id.PASSWORDEDITTEXTiD);
    
    try {
    
     ParseUser signup = new ParseUser();
    signup.setUsername(username.getText().toString());
    signup.setPassword(password.getText().toString());
    signup.signUpInBackground(new SignUpCallback() {
    			  public void done(ParseException e) {
    			    if (e == null) {
    			      // Hooray! Let them use the app now.
                                  // The user also is logged in now :)
    			    	
    			    } else {
    			      // Sign up didn't succeed. Look at the ParseException
    			      // to figure out what went wrong
    			      // Mostly the problem is that the username is already taken
                                 	
    			    }
    } catch (IllegalArgumentException IO {
    // The user didn't type in anything, I suggest using a Toast to notify him
    
    }

    Now, if a user wants to post something using his account name, you can get his username using this:
    Code:
    ParseUser currentUser = ParseUser.getCurrentUser();
    currentUser.getUsername();

    If your user wants to login, you can use this:
    Code:
    EditText username = (EditText) findViewById(R.id.USERNAMEEDITTEXT);
    EditText password = (EditText) findViewById(R.id.PASSWORDEDITTEXT);
    
    ParseUser.logInInBackground(username.getText().toString(), password .getText().toString(), new LogInCallback() {
    			  public void done(ParseUser user, ParseException e) {
    			    if (user != null) {
    			      // Hooray! The user is logged in.
    			    	
    			    	
    			    	
    			    } else {
    			      // Signup failed. Look at the ParseException to see what happened.
    			      // The main cause is that the user didn't type in a correct username or password
    			    	
    			    }
    			  }
    			});

    And if you want to log the user out, you can do it very simply by calling:
    Code:
    ParseUser.logOut();

    And that's it! You just learned how to signup a user, log him in, get his username and log him out!

    Now it's time for the next section!
    3
    Time for section 3!

    Section 3: Parse Data

    Huh, what is Parse Data? Well, that's a good question sir! :)P) Parse Data will let you save ParseObjects into the Parse Cloud. That will allow you to store all of your data, and if you want you can read it back too! This could be useful for games with highscores, forum apps and more! Another great part of Parse!

    Let's start with saving a ParseObject to the cloud, shall we?

    Step 1: Setup your app the same way you did in Section 1

    Step 2: We'll start with a really simple ParseObject, for now it's going to be called "testObject"
    Here's a quick example for a ParseObject that will save to the cloud:
    Code:
    ParseObject testObject= new ParseObject("testObject");
    		
    		testObject.put("name", "TestObject's name");
                    testObject.put("random",true);
                    testObject.put("someint", 1337);
                    testObject.saveInBackground();

    As you can see, we can put everything we want in it (e.g. testObject.put("ASDASDASDA", "ASDASDASD");)
    They don't always have to be strings, they can be booleans, ints, strings, JSON objects, java.util.Date, byte[] or ParseObjects(That's right, you can save a ParseObject inside a ParseObject :eek:)

    You can also wait for the user untill he has an internet connection, and when he finally has, save the object:
    Code:
    ParseObject testObject= new ParseObject("testObject");
    		
    		testObject.put("name", "TestObject's name");
                    testObject.put("random",true);
                    testObject.put("someint", 1337);
                    testObject.saveEventually();

    For retreiving the object, you can do something like this:
    Code:
    ParseQuery<ParseObject> query = ParseQuery.getQuery("testObject");
    query.getInBackground("YOUROBJECTID", new GetCallback<ParseObject>() {
      public void done(ParseObject object, ParseException e) {
        if (e == null) {
          // everything went okay :D
        } else {
          // something went wrong D:
        }
      }
    })

    Updating a ParseObject is really simple, just use the same as you did before, but with new data in the testObject.put("somedata", "the data"); section

    Deleting it is farely simple as well, just use this:
    Code:
    testObject.deleteInBackground();

    You can also delete just one field:
    Code:
    testObject.remove("name");
    testObject.saveInBackground();

    And that's it for now!
    1
    And again, mine :D