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

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.

Related

Getting car information in Android Auto (not Automotive OS)

In my Android Auto projection-type app I am trying to get info on the car I am attached to. Preferably manufacturer or other VHAL type parameters. Speed, tach, gear position etc would be nice too.
Is this possible in Android Auto?
I tried:
car = Car.createCar(getCarContext());
CarInfoManager carInfoManager = (CarInfoManager) car.getCarManager(Car.INFO_SERVICE);
but I get an exception on Car.createCar
I am trying this code in the onCreateSession in the CarAppService with no luck
Two previous answers to my question from other people got deleted. No idea why, but they gave me the hints I needed to fix the code and get it working.
in the CarAppService implementation, in the
public Session onCreateSession() {
at the end where I do:
return new Session() {
I have a block of code like this:
CarInfo carInfo =
getCarContext().getCarService(CarHardwareManager.class).getCarInfo();
mCarHardwareExecutor = ContextCompat.getMainExecutor(getCarContext());
OnCarDataAvailableListener<Model> mModelListener = data -> {
synchronized (this) {
String statusText = "" + data.getYear().getValue() + " " + data.getManufacturer().getValue() + " " + data.getName().getValue();
theSimpleAAScreen.setStatusText(statusText);
theSimpleAAScreen.invalidate();
}
/* get year, make, model */
try {
carInfo.fetchModel(mCarHardwareExecutor, mModelListener);
} catch (SecurityException e) {
Log.e(TAG, "No permission to get model");
}
theSimpleAAScreen is an object that is the android auto screen: I set a value for what to print and invalidate the screen so it redraws. There is probably a better / smoother way but this works and answers my question.

“Error getting Mms Carrier values” when querying Android Telephony.Carriers public class

I am having trouble obtaining the "server", "mms_proxy", and "mms_port". I haven't found anything official anywhere from Google about why this is? I would assume if this is something I cannot do then that would be stated by Google.
The Android developer website shows the Telephony.Carriers class and all that is available but says nothing about restrictions of any kind so at this point I believe it is fair to assume I can access these rather than have to ask the user to find the APN values manually which will make many people give up instantly and not use my App.
Can we please try to find an official answer as to what is going on here, I have attempted to get this information in many ways all leading to very confusing errors that seemingly cannot be explained.
I am running Android 6.01 on the device ZTE Axon 7. The lowest api that my App will allow is api_21 and the Telephony.Carriers class in available from api_19 and up.
I have declared all then necessary permission in the Manifest file and since I am currently testing on sdk "M" (Android 6), I have also acquired the permissions explicitly at Runtime from the user.
This is the code inside my Activity that I run and receive a an error stating "Error getting Mms Carrier values"...this is the whole problem and where I have become stuck.
ContentResolver contentResolver = getContentResolver();
int index_ID;
final String[] PROJECT =
{
Telephony.Carriers.TYPE,
Telephony.Carriers.MMSC,
Telephony.Carriers.MMSPROXY,
Telephony.Carriers.MMSPORT,
};
grantMyUriPermission(activity, Telephony.Carriers.CONTENT_URI, Intent.FLAG_GRANT_READ_URI_PERMISSION);
grantMyUriPermission(activity, Telephony.Carriers.CONTENT_URI, Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
Cursor carriers_cursor = SqliteWrapper.query(activity, contentResolver,
Uri.withAppendedPath(Telephony.Carriers.CONTENT_URI, "current"), PROJECT, null, null, null);
if (carriers_cursor != null)
{
/*This crap below isn't needed for this situation but helps avoid ERROR*/
index_ID = carriers_cursor.getColumnIndex(Telephony.Carriers._ID);
//--------------------------------------------------------------------------------------
if (index_ID < 0 || !carriers_cursor.moveToFirst())
{
Log.i(TAG, "Error getting Mms Carrier values");
carriers_cursor.close();
return;
}
//--------------------------------------------------------------------------------------
do
{
//Confirm cursor has value assigned to it
Log.i(TAG, "cursor: "+ carriers_cursor);
//Get the available columns names
for (String item : carriers_cursor.getColumnNames())
{
//Name of each column available with Cursor
Log.i(TAG, "item: " + item);
//Attempt to get String value for each available column
try
{
//Use the name of the column, to get the index, to get the String value
Log.i(TAG, "getString(): " + carriers_cursor.getString(carriers_cursor.getColumnIndex(item)));
}
catch (Exception e)
{
Log.i(TAG, "Exception: " + e);
}
}
}
while (carriers_cursor.moveToNext());
carriers_cursor.close();
}
The Log output is:
I/SmsReceiveIntentService: Running grantMyUriPermission()
I/SmsReceiveIntentService: Running grantMyUriPermission()
I/NewConversationActivity: Error getting Mms Carrier values
And that's it! Nothing else to go on...?

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

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.

ParseUser SignUpInBackground issue: Value == Null

I've been trying to use the Parse library to access MongoDB in order to create users or objects for my Android application. The issue is that every time I attempt to SignUpInBackground or SignInInBackground I get this super unspecific error.
"java.lang.NullPointerException: value == null"
Just value == null.. I have no idea which value this refers to but the most frustrating part is that the code I'm using works perfectly in one app and despite copying it over, it always returns this error.
I usually wouldn't bother making a question for my issue but I've been trying to find a solution to this for about a week now and have been unable to find anything related to my issue online.
Hope someone out there has seen this before, as I'm about out of ideas for this one. Thanks in advance to anyone who gets back to me on this :)
The Sign Up Method:
private void signUp(){
String username = "Andy"; //Temp
ParseUser user = new ParseUser();
user.setUsername(username);
user.setEmail(txtUsername.getText().toString());
user.setPassword(txtPassword.getText().toString());
Log.i(TAG,"SignUp method. Parse user = " + user.getUsername() + ", " + user.getEmail());
user.signUpInBackground(new SignUpCallback() {
#Override
public void done(ParseException e) {
if(e==null){
Log.i(TAG, "Successfully created new user!");
signIn();
} else {
Log.i(TAG, "Failed to create new user. Error: " + e.getMessage());
Toast.makeText(getContext(),"Sign up failed! " + e.getMessage(), Toast.LENGTH_SHORT).show();
}
}
});
}
Error:
I/LogIn: Validation success
I/LogIn: SignUp method. Parse user = Andy, test
I/LogIn: Failed to create new user. Error: java.lang.NullPointerException: value == null
Edit:
While stepping through the parse libraries, I ended up with this error message several times in the log.
I/art: Rejecting re-init on previously-failed class java.lang.Class

How to properly integrate Pinterest in Android app?

I am using the REST API for integrating Pinterest into my Android app, but I'm getting an error when attempting to access categories.
My code:
String url = "https://api.pinterest.com/";
String allCategories = "/v2/boards/categories/";
RestClient client = new RestClient(url + allCategories);
String response = "";
try {
client.AddParam("limit", "36");
try {
client.Execute(RequestMethod.GET);
} catch (Exception e) {
e.printStackTrace();
}
response = client.getResponse();
} catch (Exception e) {
System.out.println(">>> Exception >>> " + e + " >>> Message >>> "
+ e.getMessage());
}
System.out.println(">>> response >>> " + response);
Log.d(">> Login response >>> ", response);
I'm getting the following error returned from the endpoint:
{
"message": "Please upgrade your app!",
"error": "Authentication failed: Please upgrade your app!"
}
Pinterest doesn't have any official api, and it's unofficial api is not working now. So I don't think your code will work any way, unless someone finds any other unofficial api or Pinterest releases the official version.
PS: More Info.
As of today, pinterest API has been taken down
(look here)
In the meantime you might want to use this 3rd party implemented scraper, which works just like an API
http://pinterestapi.co.uk/
You can use this to get the boards, likes and pins of a user.
Note: Curiously the count for the v1 api still works. But again this is undocumented behaviour and dont rely on this

Categories

Resources