Android: Parse Server save Error 111: This is an invalid Polygon - android

I'm trying to save a GeoPolygon into my Parse server using an android app but I keep getting an:
error 111: this is not a valid polygon
this is my code:
//create the parse object
ParseObject obj = new ParseObject("SomeClass");
List<ParseGeoPoint> geoPoints = new ArrayList<ParseGeoPoint>();
geoPoints.add(new ParseGeoPoint(1.468074, 110.429638));
geoPoints.add(new ParseGeoPoint(1.468075, 110.429287));
geoPoints.add(new ParseGeoPoint(1.467376, 110.429681));
geoPoints.add(new ParseGeoPoint(1.467373, 110.429283));
ParsePolygon geoPolygon = new ParsePolygon(geoPoints);
obj.put("Boundaries", geoPolygon);
obj.saveInBackground(new SaveCallback() {
#Override
public void done(ParseException e) {
if (e == null) {
Toast.makeText(getContext(), "Geo Polygon save complete.", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(getContext(), "Geo Polygon save failed. error: " + e.getMessage(), Toast.LENGTH_SHORT).show();
}
}
});
I followed the Docs for geopolygons here:
http://docs.parseplatform.org/android/guide/#parsepolygon
and somehow, even when I copy pasted the code provided in the docs, it doesnt work.
Any suggestions/ solutions are most welcomed.

I believe not many people may see this but I'll post my solution to this anyway.
The issue was solved after I updated the version of my Parse Server. I didn't note which version I updated the Parse Server from but my current Parse Server is now v2.7.1 .
Previous/ older version of Parse Server does not support geo-Polygons.

Related

Microsoft Face API (Android)- Add Person to Person Group

I know that this may seem to be a rather broad question, but I have been unable to figure out how to create a Person in a Person Group using the Microsoft Face API in Android Studio.
I have tried the following code to make a CreatePersonResult object in Android:
try {
CreatePersonResult person1 = faceServiceClient.createPerson(personGroupId, "Bob", "My Friends");
Toast.makeText(getApplicationContext(), "Created Person called Bob", Toast.LENGTH_LONG).show();
} catch (Exception e) {
Toast.makeText(getApplicationContext(), "Creation failed: " + e.getMessage(), Toast.LENGTH_LONG).show();
}
The above code outputs: "Creation failed: null" which means that the Exception was null for some reason.
In Visual Studio, to create a Person I simply have to do the following:
CreatePersonResult person1 = await faceServiceClient.CreatePersonAsync(personGroupId, "Bob");
Does anyone know how I can create the Person in a Person Group in Android? I have been unable to figure out how to do this in Android, but found plenty of tutorials for Visual Studio.

Parse Android fails to download image with a moved permanently error

I am getting the following exception when trying to download a ParseFile using getData() method.
com.parse.ParseException: Download from S3 failed. Moved Permanently
at com.parse.ParseAWSRequest.onResponseAsync(ParseAWSRequest.java:43)
at com.parse.ParseRequest$3.then(ParseRequest.java:137)
at com.parse.ParseRequest$3.then(ParseRequest.java:133)
at bolts.Task$15.run(Task.java:917)
at bolts.BoltsExecutors$ImmediateExecutor.execute(BoltsExecutors.java:105)
at bolts.Task.completeAfterTask(Task.java:908)
at bolts.Task.continueWithTask(Task.java:715)
at bolts.Task.continueWithTask(Task.java:726)
at bolts.Task$13.then(Task.java:818)
at bolts.Task$13.then(Task.java:806)
at bolts.Task$15.run(Task.java:917)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
The ParseFile is a jpg which is uploaded and then put into a ParseObject called ImageObject. The ImageObject has several other parameters like caption, width, height which upload and download correctly. The image itself uploads correctly as confirmed through the dashboard. Only during the download I get the above exception.
This is my upload code
file.saveInBackground(new SaveCallback() {
#Override
public void done(ParseException e) {
if (e == null) {
Log.d(tag, "Successfully uploaded image file");
ParseObject image = new ParseObject("imageObject"); //Create new Image-ParseObject and set values
image.put("author", ParseUser.getCurrentUser());
image.put("imageFile", file);
image.put("caption", caption);
image.saveInBackground(new SaveCallback() {
#Override
public void done(ParseException e) {
if(e==null){
Log.d(tag, "Successfully saved image file to object");
}else{
Log.d(tag, "Failed to save image file to object", e);
}
}
});
} else {
Log.d(tag, "Failed to save image", e);
}
}
my download code is pretty much ParseFile.getFile() after I have retrieved all the ImageObjects through a ParseQuery.
I Followed Line 43 of ParseAWSRequest.java and I found this,
if (statusCode >= 200 && statusCode < 300 || statusCode == 304) {
// OK
} else {
String action = method == ParseHttpRequest.Method.GET ? "Download from" : "Upload to";
return Task.forError(new ParseException(ParseException.CONNECTION_FAILED, String.format(
"%s S3 failed. %s", action, response.getReasonPhrase())));
}
This and the "Permanently removed" points to my nginx reverse proxy, which returns a 301 code in the redirect to https. Unfortunately I am not sure where to proceed from here.
Extra information,
I have blocked port 80(http) in the firewall for a test and it seems that for the download parse-android-sdk is trying to download from http. Which is odd because I have specified my parse-server link with "https", and the fact that upload is working fine. I can see the uploaded image using dashboard on my server.
Using,
Parse Server 2.2.13
Parse Android SDK 1.13.1
Parse Dashboard 1.0.14
I found a workaround to this issue just by directly downloading the file. I used ParseFile.getUrl() method to get the url and then use that to download and use the file.
In my case it was .jpg files. And then I used an external library that takes care of all the downloading/caching/loading into imageviews.
Both of these libraries work well
https://github.com/koush/ion
http://square.github.io/picasso/

Working with azure mobile service in android

I am working on a project in which I have to work with Azure Back end, I have inserted data into the table, but don't know how to get its response and where should I use Json parsing .. below is my code .. please guide me about this
mClient.getTable(TodoItem.class).insert(item, new TableOperationCallback<TodoItem>() {
public void onCompleted(TodoItem entity, Exception exception, ServiceFilterResponse response) {
if (exception == null) {
// Insert succeeded
Toast.makeText(getApplicationContext(),"yes", Toast.LENGTH_LONG).show();
} else {
// Insert failed
String msg=exception.getCause().getMessage();
Toast.makeText(getApplicationContext(), "No", Toast.LENGTH_LONG).show();
}
}
});
For information on using the Android client SDK for Azure Mobile Apps, see the following articles:
Create an Android app
Enable offline sync for your Android mobile app
How to use the Android client library for Mobile Apps

Android, unable to get current location using Parse SDK, always times out

ParseGeoPoint.getCurrentLocationInBackground(10000, new LocationCallback() {
#Override
public void done(ParseGeoPoint geoPoint, ParseException e) {
if (e!=null)
Print("location not found " + e.getLocalizedMessage());
else
{
Print("location found ");
}
}
});
I have added the required permissions in the manifest.
I have also asked this question here Parse SDK unable to fetch location in background, always time out exception
Thanks
Finally I had to use the default Android apis for getting the user's current location.
Did not find any other solution on how to get the user's location from Parse. Looks like there is no way to it on Parse directly.

Android - Parse - deleteInBackground, record not being deleted

I'm using Parse with Android in order to sync my data.
I'm trying to delete an object which is stored in the Parse cloud via
The callback returns and there's no exception, the Logcat message is "deleted".
But the object still exists in table when I check the Parse Data.
tastToEdit is an object from Task class (configured locally in my app).
ParseObject parse_task = new ParseObject("Task");
parse_task.put("Description",tastToEdit.getDescription());
parse_task.put("DueDate",tastToEdit.getDueDate());
parse_task.put("Priority",tastToEdit.getPriority().ordinal());
int com_state = (tastToEdit.getCompleted()) ? 1 : 0;
parse_task.put("IsCompleted",com_state);
parse_task.put("Location",0);
parse_task.put("Category",tastToEdit.getTask_catg().ordinal());
parse_task.put("Status", tastToEdit.getTask_sts().ordinal());
//parse_task.deleteInBackground();
parse_task.deleteInBackground(new DeleteCallback() {
public void done(ParseException e) {
if (e == null) {
Log.d("msg","deleted");
} else {
Log.d("msg", "not deleted");
e.printStackTrace();
}
}
});
What might be causing the callback to return as "deleted" but the object still remains?
Thanks in advance.
You are creating a new ParseObject and you try to delete it after but you don't provide an ObjectID.
A better way to do this will be to first do a ParseQuery for that task you are looking and the in the completion delete it.

Categories

Resources