Android Programming Press on the image to return to the main documentation page.

Parse

The Parse platform provides a complete backend solution for your mobile application.
On Parse, you create an App for each of your mobile applications.
Each App has its own application id and client key.
Your account on Parse can accommodate multiple Apps.
See the documentation on the Parse.com web site for more information.
https://parse.com/docs/index

This library supports ParseObject, ParseQquery, ParseFile, ParseGeoPoint and Push Notifications.

All the operations which need to access the Parse online service are done asynchronously
and raise events when complete whose parameters include a Success indication.
If an error occurs Success will be False and a ParseException with a message describing the error
will be placed in LastException. If necessary this should be processed in the event code
as there is a possibility that a further error could occur in another asynchronous call that
would overwrite the existing LastException.

Note that these asynchronous operations do not necessarily complete in the order in which they are invoked.
To deal with this possibility a TaskID parameter is provided in each call that can be used, if required,
to identify which of several possible method calls has just completed. This may not always be needed.


Copyright 2013 Anywhere Software

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

List of types:

Parse
ParseFile
ParseGeoPoint
ParseObject
ParsePush
ParseQuery
ParseRelation

Parse

This object has three methods.
Initialize, which is required to Initialize the Parse library.
TrackOpening allows openings of your applications to be recorded.
EnableNotifications lets your application receive push notifications.

Permissions:

android.permission.INTERNET
android.permission.ACCESS_NETWORK_STATE
android.permission.RECEIVE_BOOT_COMPLETED
android.permission.VIBRATE

Events:

None

Members:


  DisableNotifications

  EnableNotifications (ActivityName As Class)

  SetLoggingLevel (LogLevel As Int)

  Subscribe (Channel As String, ActivityName As Class)

  Subscribe2 (Channel As String, ActivityName As Class, Icon As String)

  Subscriptions As String()

  TrackOpening

  Unsubscribe (Channel As String)

  Version As Double [read only]

Members description:

DisableNotifications
Disables receiving pushes sent to everyone
If no channels are subscribed to it should stop the PushService.
EnableNotifications (ActivityName As Class)
Enable push notifications and cause the specified Activity to be opened when one is received.
The push data may be obtained in the Activity from the StartingIntent ExtrasToString method.
To enable push you also need to add the following to the Manifest Editor in the project.

The Activity named will be started for a push sent to everyone registered for push with the Parse application.
The default application icon will be used for the notification.

AddApplicationText(<service android:name="com.parse.PushService" />
<receiver android:name="com.parse.ParseBroadcastReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.USER_PRESENT" />
</intent-filter>
</receiver>)

Object Browser does not show the actual XML text within AddApplicationText above.
The XML is available for cut and paste in the first post of the Parse library forum thread
SetLoggingLevel (LogLevel As Int)
This is included for diagnostic purposes only. You should not use this unless requested to.

Sets the level of logging to display, where each level includes all those below it.
Ensure this is set to Parse.LOG_LEVEL_ERROR or Parse.LOG_LEVEL_NONE before deploying your app
to ensure no sensitive information is logged. The default level is Parse.LOG_LEVEL_ERROR.

The levels are:
LOG_LEVEL_VERBOSE = 2
LOG_LEVEL_DEBUG = 3
LOG_LEVEL_INFO = 4
LOG_LEVEL_WARNING = 5
LOG_LEVEL_ERROR = 6
LOG_LEVEL_NONE = 2147483647;
Subscribe (Channel As String, ActivityName As Class)
Call this function when the user should be subscribed to a new push channel.
The default application icon will be used for the notification.
The Activity named will be started for a push received for the specified channel.
Subscribe2 (Channel As String, ActivityName As Class, Icon As String)
Call this function when the user should be subscribed to a new push channel.
The specified icon file from the application resources will be used for the notification.
The Activity named will be started for a push received for the specified channel.
Subscriptions As String()
Accesses the current set of channels for which the current installation is subscribed.
TrackOpening
Enables tracking of launches of this application.

The following is a technical comment included as a point of record.
trackAppOpened does not work as documented in the Parse API.
It states that a null argument to ParseAnalytics.trackAppOpened will work, but the code checks for null
and does not send the tracking data if the intent is null or if the intent extras are null.
This method creates a new intent with putExtra("Data", "B4a_App") and sends that which seems to work OK.
Unsubscribe (Channel As String)
Call this function when the user should be unsubscribed from a push channel.
Version As Double [read only]
Returns the version of the library.

ParseFile

ParseFile is a local representation of a file that is saved to the Parse cloud.
The workflow is to construct a ParseFile with data and a filename.
Then save it and set it as a field on a ParseObject.
You can also use it to store any binary data (up to 10 megabytes).

Permissions:

android.permission.INTERNET

Events:

DoneGet(Success As Boolean, Data() As Byte, TaskID As Int)
DoneSave(Success As Boolean, TaskID as Int)

Members:


  Get (EventName As String, TaskID As Int)

  Initialize (SaveName As String, Data() As Byte)

  Initialize2 (Path As String, Name As String, SaveName As String)

  IsDataAvailable As Boolean [read only]

  IsDirty As Boolean [read only]

  IsInitialized As Boolean

  Name As String [read only]

  Save (EventName As String, TaskID As Int)

  URL As String [read only]

  Version As Double [read only]

Members description:

Get (EventName As String, TaskID As Int)
Gets the data for the object from the server.
The DoneGet event will be raised when saving completes.
If an error occurs Success will be False and a ParseException with a message describing the error will be placed in LastException.
Initialize (SaveName As String, Data() As Byte)
Initializes the ParseFile with a name and the file data as a Byte array.
Giving a SaveName with a proper file extension (e.g. ".png") is best because it allows
Parse to deduce the content type of the file and set appropriate HTTP headers when it is fetched.
Initialize2 (Path As String, Name As String, SaveName As String)
Initializes the ParseFile from a filename and path.
Giving a SaveName with a proper file extension (e.g. ".png") is best because it allows
Parse to deduce the content type of the file and set appropriate HTTP headers when it is fetched.
IsDataAvailable As Boolean [read only]
Returns whether the file has available data.
IsDirty As Boolean [read only]
Returns whether the file still needs to be saved.
IsInitialized As Boolean
Name As String [read only]
Returns the file SaveName. Before Save is called, this is just the SaveName given by Initialize.
After Save is called, that name gets prefixed with a unique identifier.
Save (EventName As String, TaskID As Int)
Saves the object on the server.
The DoneSave event will be raised when saving completes.
If you want to ignore the event then pass an empty String for EventName.
If an error occurs Success will be False and a ParseException with a message describing the error will be placed in LastException.
A ParseFile must be saved before it can be added to a ParseObject
URL As String [read only]
This returns the url of the file.
It's only available after you Save or after you get the file from a ParseObject.
Version As Double [read only]
Returns the version of the library.

ParseGeoPoint

ParseGeoPoint represents a latitude/longitude point that may be associated with a key in a ParseObject
or used as a reference point for geo queries. This allows proximity based queries on the key.

Only one Key in a class may contain a GeoPoint.

Points should not equal or exceed the extreme ends of the allowable ranges.
Latitude should not be -90.0 or 90.0.
Longitude should not be -180.0 or 180.0.
Attempting to set latitude or longitude out of bounds will cause an error.

Events:

None

Members:


  DistanceInKilometersTo (GeoPoint As com.parse.ParseGeoPoint) As Double

  DistanceInMilesTo (GeoPoint As com.parse.ParseGeoPoint) As Double

  DistanceInRadiansTo (GeoPoint As com.parse.ParseGeoPoint) As Double

  Initialize (latitude As Double, longitude As Double)

  Initialize2

  IsInitialized As Boolean

  Latitude As Double

  Longitude As Double

  Version As Double [read only]

Members description:

DistanceInKilometersTo (GeoPoint As com.parse.ParseGeoPoint) As Double
Get the distance between this point and another geopoint in kilometers.
DistanceInMilesTo (GeoPoint As com.parse.ParseGeoPoint) As Double
Get the distance between this point and another geopoint in miles.
DistanceInRadiansTo (GeoPoint As com.parse.ParseGeoPoint) As Double
Get distance in radians between this point and another GeoPoint.
This is the smallest angular distance between the two points.
Initialize (latitude As Double, longitude As Double)
Initializes the object and sets latitude and longitude.
Latitude should not be -90.0 or 90.0.
Longitude should not be -180.0 or 180.0.
Initialize2
Initializes the object and sets both latitude and longitude 0.
IsInitialized As Boolean
Latitude As Double
Gets or sets the latitude for this GeoPoint.
Latitude should not be -90.0 or 90.0.
Longitude As Double
Gets or sets the longitude for this GeoPoint.
Longitude should not be -180.0 or 180.0.
Version As Double [read only]
Returns the version of the library.

ParseObject

The ParseObject is a local representation of data that can be saved and retrieved from the Parse cloud.
The basic workflow for creating new data is to construct a new ParseObject, use Put() to fill it with data, and then use Save() to persist to the database.
The basic workflow for accessing existing data is to use a ParseQuery to specify which existing data to retrieve.

Events:

DoneSave(Success As Boolean, TaskID As Int)
DoneDelete(Success As Boolean, TaskID As Int)
DoneRefresh(Success As Boolean, TaskID As Int)

Members:


  Add (Key As String, Value As Object)

  ContainsKey (Key As String) As Boolean

  CreatedAt As Long [read only]

  CreateWithoutData (ClassName As String, ObjectID As String) As com.parse.ParseObject

  Delete (EventName As String, TaskID As Int)

  GetBoolean (Key As String) As Boolean

  GetDouble (Key As String) As Double

  GetInt (Key As String) As Int

  GetJSONArray (Key As String) As String

  GetKeys As String()

  GetLong (Key As String) As Long

  GetObject (Key As String) As Object

  GetObjectType (Key As String) As String

  GetRelation (Key As String) As ParseRelation

  GetString (Key As String) As String

  Increment (Key As String, Number As Double)

  Initialize (ClassName As String)

  IsDataAvailable As Boolean [read only]

  IsInitialized As Boolean

  ObjectId As String [read only]

  Put (Key As String, Value As Object)

  Refresh (EventName As String, TaskID As Int)

  Save (EventName As String, TaskID As Int)

  UpdatedAt As Long [read only]

  Version As Double [read only]

Members description:

Add (Key As String, Value As Object)
Adds the provided Value to the array of values for Key.
The first use of Add for a Key defines the Value of that Key as an array
The array of values for a Key may be accessed by GetJSONArray.
ContainsKey (Key As String) As Boolean
Returns True if the provided Key is present in the ParseObject.
CreatedAt As Long [read only]
Returns the time when the data was first created on the Parse server.
This reports time as the server sees it, so that if you create a ParseObject,
then wait a while, and then call save(), the creation time will be the time of
the first save() call rather than the time the object was created locally.
CreateWithoutData (ClassName As String, ObjectID As String) As com.parse.ParseObject
Creates a reference to an existing ParseObject for use in creating associations between ParseObjects.
Calling IsDataAvailable on this object will return false until Refresh has been called.
No network request will be made.
Delete (EventName As String, TaskID As Int)
Deletes the object from the server.
The DoneDelete event will be raised when saving completes.
If an error occurs Success will be False and a ParseException with a message describing the error will be placed in LastException.
If you want to ignore the event then pass an empty String for EventName.
GetBoolean (Key As String) As Boolean
Returns the Value of Key as a Boolean. Note that Key is case-sensitive.
GetDouble (Key As String) As Double
Returns the Value of Key as a Double. Note that Key is case-sensitive.
GetInt (Key As String) As Int
Returns the Value of Key as an Int. Note that Key is case-sensitive.
GetJSONArray (Key As String) As String
Returns the value of a Key as a JSON array or an empty string if the value is undefined.
Note that Key is case-sensitive.
GetKeys As String()
Returns a String array containing the names of the Keys in the ParseObject.
Only the Keys with defined data values are returned.
GetLong (Key As String) As Long
Returns the Value of Key as a Long.
GetObject (Key As String) As Object
Returns the Value object for the specified Key. Note that Key is case-sensitive.
In most cases it is more convenient to use a helper function such as GetString or GetInt.
This is mostly for use with Byte arrays, ParseFile, ParseGeoPoint and ParseObject objects.
GetObjectType (Key As String) As String
Returns the type name of the Value that is returned by GetObject for the specified Key.
Note that Key is case-sensitive. This is provided for diagnostic purposes.
GetRelation (Key As String) As ParseRelation
Access or create a Relation value for a key.
Returns the ParseRelation object if the relation already exists, or can be created, for the Key.
GetString (Key As String) As String
Returns the Value of Key as a String. Note that Key is case-sensitive.
Increment (Key As String, Number As Double)
Increment (or decrement) the value of the given Key by the amount Number.
Initialize (ClassName As String)
Initializes the ParseObject and sets the class name into which the Key Value pairs will be saved.
IsDataAvailable As Boolean [read only]
Returns True if the ParseObject is new or has been fetched or refreshed. False otherwise.
IsInitialized As Boolean
ObjectId As String [read only]
Returns the unique ObjectId for the ParseObject.
An object id is assigned as soon as an object is saved to the server.
The combination of a Class name and an ObjectId uniquely identifies an object in your application.
Put (Key As String, Value As Object)
Places the provided Key Value pair in the present ParseObject.
Refresh (EventName As String, TaskID As Int)
Refreshes the object by reading it from the server.
The DoneRefresh event will be raised when the operation completes.
If an error occurs Success will be False and a ParseException with a message describing the error will be placed in LastException.
Save (EventName As String, TaskID As Int)
Saves the object on the server.
The DoneSave event will be raised when saving completes.
If an error occurs Success will be False and a ParseException with a message describing the error will be placed in LastException.
If you want to ignore the event then pass an empty String for EventName.
UpdatedAt As Long [read only]
Returns the time when the data was last updated on the Parse server.
This reports time as the server sees it, so that if you make changes to a ParseObject,
then wait a while, and then call save(), the updated time will be the time of the save()
call rather than the time the object was changed locally.
Version As Double [read only]
Returns the version of the library.

ParsePush

A class that is used to access all of the children of a many-to-many relationship.
Each instance of Parse.Relation is associated with a particular parent object and key.
A ParseRelation is obtained by invoking GetRelation on a ParseObject.

Events:

DoneSend(Success As Boolean, TaskID As Int)

Members:


  ClearExpiration

  Initialize

  IsInitialized As Boolean

  Send (EventName As String, TaskID As Int)

  SetChannel (Channel As String)

  SetExpirationTime (TimeTicks As Long)

  SetExpirationTimeInterval (Interval As Long)

  SetMessage (Message As String)

  Version As Double [read only]

Members description:

ClearExpiration
Clears both expiration values, indicating that the notification should never expire.
Initialize
Initializes the ParsePush object.
The default channel is the empty string, also known as the global broadcast channel,
but this value can be overridden using SetChannel(String)
IsInitialized As Boolean
Send (EventName As String, TaskID As Int)
Send the push notification. The DoneSend event will be raised when sending completes.
If an error occurs Success will be False and a ParseException with a message describing the error will be placed in LastException.
If you want to ignore the event then pass an empty String for EventName.
SetChannel (Channel As String)
Sets the channel on which this push notification will be sent.
SetExpirationTime (TimeTicks As Long)
Sets the timestamp at which this notification should expire, in seconds (UTC).
This notification will be sent to devices which are either online at the time the notification is sent,
or which come online before the expiration time is reached.
Because device clocks are not guaranteed to be accurate, most applications should instead use ParsePush.setExpirationTimeInterval.
Note that the underlying ParsePush method wants a Unix time so this method takes an Android time in ticks and converts it.
SetExpirationTimeInterval (Interval As Long)
Sets the time interval after which this notification should expire, in seconds.
This notification will be sent to devices which are either online at the time the notification is sent,
or which come online within the given number of seconds of the notification being received by Parse's server.
An interval which is less than or equal to zero indicates that the message should only be sent to devices which are currently online.
SetMessage (Message As String)
Sets the message that will be shown in the notification.
Version As Double [read only]
Returns the version of the library.

ParseQuery


Events:

DoneGet(Success As Boolean, PO As ParseObject, TaskId As Int)
DoneFind(Success As Boolean, ListOfPO As List, TaskId As Int)
DoneCount(Success As Boolean, Count As Int, TaskId As Int)

Members:


  Count (EventName As String, TaskId As Int)

  Find (EventName As String, TaskId As Int)

  GetById (EventName As String, ObjectId As String, TaskId As Int)

  Initialize (ClassName As String)

  IsInitialized As Boolean

  Limit As Int [write only]

  OrderBy (Key As String, Ascending As Boolean)

  Version As Double [read only]

  WhereEqualTo (Key As String, Value As Object) As ParseQuery

  WhereGreaterThan (Key As String, Value As Object) As ParseQuery

  WhereLessThan (Key As String, Value As Object) As ParseQuery

  WhereNear (Key As String, GeoPoint As com.parse.ParseGeoPoint) As ParseQuery

  WhereNotEqualTo (Key As String, Value As Object) As ParseQuery

  WhereWithinKilometers (Key As String, GeoPoint As com.parse.ParseGeoPoint, Distance As Double) As ParseQuery

  WhereWithinMiles (Key As String, GeoPoint As com.parse.ParseGeoPoint, Distance As Double) As ParseQuery

Members description:

Count (EventName As String, TaskId As Int)
Counts the number of objects matching the query.
The DoneCount event will be raised when the operation completes.
If an error occurs Success will be False and a ParseException with a message describing the error will be placed in LastException.
Find (EventName As String, TaskId As Int)
Finds all objects matching the query.
The DoneFind event will be raised when the operation completes.
If an error occurs Success will be False and a ParseException with a message describing the error will be placed in LastException.
GetById (EventName As String, ObjectId As String, TaskId As Int)
Gets an object based on its ObjectId.
The DoneGet event will be raised when the operation completes.
If an error occurs Success will be False and a ParseException with a message describing the error will be placed in LastException.
Initialize (ClassName As String)
Initializes the object and sets the Class name.
IsInitialized As Boolean
Limit As Int [write only]
Limits the number of results. Pass -1 to retrieve all items.
OrderBy (Key As String, Ascending As Boolean)
Sets the ordering of the query results as Ascending or Descending.
Version As Double [read only]
Returns the version of the library.
WhereEqualTo (Key As String, Value As Object) As ParseQuery
Adds a WhereEqualTo condition to the query.
WhereGreaterThan (Key As String, Value As Object) As ParseQuery
Adds a WhereGreaterThan condition to the query.
WhereLessThan (Key As String, Value As Object) As ParseQuery
Adds a WhereLessThan condition to the query.
WhereNear (Key As String, GeoPoint As com.parse.ParseGeoPoint) As ParseQuery
Adds a WhereNear condition to the query.
WhereNotEqualTo (Key As String, Value As Object) As ParseQuery
Adds a WhereNotEqualTo condition to the query.
WhereWithinKilometers (Key As String, GeoPoint As com.parse.ParseGeoPoint, Distance As Double) As ParseQuery
Adds a WhereWithinKilometers condition to the query.
WhereWithinMiles (Key As String, GeoPoint As com.parse.ParseGeoPoint, Distance As Double) As ParseQuery
Adds a WhereWithinMiles condition to the query.

ParseRelation

A class that is used to access all of the children of a many-to-many relationship.
Each instance of Parse.Relation is associated with a particular parent object and key.
A ParseRelation is obtained by invoking GetRelation on a ParseObject.

Events:

None

Members:


  Add (Object As com.parse.ParseObject)

  GetQuery As ParseQuery

  IsInitialized As Boolean

  Remove (Object As com.parse.ParseObject)

  Version As Double [read only]

Members description:

Add (Object As com.parse.ParseObject)
Adds an object to this relation.
GetQuery As ParseQuery
Gets a ParseQuery that can be used to query the objects in this relation and that
restricts the results to objects in this relation.
IsInitialized As Boolean
Remove (Object As com.parse.ParseObject)
Removes an object from this relation.
Version As Double [read only]
Returns the version of the library.
Top