How to get a text from a DataInteraction object - android

I am testing an android application in which I want to retrieve the text from a datainteraction object. Is there any code to do the same.
Below is the sample code which i did.
onData(anything()).inAdapterView(withId(R.id.procedureListView)).atPosition(i).onChildView(withId(R.id.workOrderStatus))).toString()
When I tried to run the code, it returns some random datainteraction object string which is not the expected one.

Related

ParseObject.remove not working in Back4App

I am triying to delete a field of an object in Back4App, but I cannot achieve such a simple operation. By "deleting" I mean set a field that has data to "undefined".
According to the guide, I just have to call myObject.remove("field"). I tryed that (with correct field name), then save the object (I tried all of the saving functions available), but the object is unmodified. There is no error thrown.
I can change the field (with put ("field", otherObject), because it is a pointer field) with no problem. But put("field", JSONObject.NULL) is not working either.
I do not know if this code would work in the original Parse, I am coding this now. The equivalent function in iOS ([myObject removeObjectForKey:#"field"];) in the same database is working nicely...
For what I could gather from your question, the problem is that you're trying to clean a field from a relational object:
"I can change the field (with put ("field", otherObject), because it is
a pointer field)"
On that case, I'm not really sure if using simple object deletion would work. I'd suggest you to take a look at Parse's documentation on Relational Data in order to understand how you should remove that field.
Long story short, I'm not sure if the idea of cleaning the field that you wish will work, but what can be done when you have a relation like this:
ParseUser user = ParseUser.getCurrentUser();
ParseRelation<ParseObject> relation = user.getRelation("field");
relation.add(MyObject);
user.saveInBackground();
Is to simply remove the relation like this:
relation.remove(MyObject);
As you can check in the link above.

Android - How to get the assignment code of a variable from the watch

I'm doing unit tests and one of my classes constructor takes in parameters a very "complicated" one (very big array of maps, which values come from NFC tag).
I'd like to test this method and to use it, I need to make this array.
Is there a way to get it in debug mode from the watch and automagically get the corresponding assignment code.
Example:
In the watch: myArray = {string[200]#123456789}
Intended output: "String[] myArray = {"aaa", "bbb", "ccc", ...}"
In the watch panel : right click on your variable > customize data view > Java Data Type renderer. Then choose the class to render, click on Use following expression and write any expression as you where in a method of the class you are watching.
You can write a custom method that you call there like toTestString()
I found another solution :
I simply made a .toString() on my ArrayList (in the Watches), and then I use the string in return to recreate the ArrayList.

Can't set user objectId to parse pointer field

For a new project I was running some tests. For now I have a function in which I am trying to save an object to the parse.com framework and all went well untill I added a user pointer object. The pointer line seems to block my code when I use the current user's objectId as a value for it. Using a random word of the user's email adres however does work. I added my code below.
// Create a data object and store it online.
public void createDataObject(){
ParseObject object = new ParseObject("TestData");
object.put("action", "trial");
object.put("value", "succes?");
object.put("name", ParseUser.getCurrentUser().getUsername());
String pointer = ParseUser.getCurrentUser().getObjectId();
Log.i(TAG, pointer);
object.put("pointer", ParseObject.createWithoutData("_User", pointer));
object.saveEventually();
}
I hope anyone can help me figure it out, help is greatly appreciated!
Update: The problem is not my pointer command but it's the fact I use saveEventually(); If I use saveInBackground it just works but I want to use saveEventually because of possible lost network connection. Does anyone have a clue what could be the problem?
Update 2: Finally decided to delete the app and the installationId of the Parse data browser. Upon reinstalling the app everything started working like it should. I probably had a bad piece of code that got stuck with my installation Id. I hope others with the same problem reach this post fast and don't spend several days searching for an answer!
Update 3: There was a certain function that tried to find a user based on a pointer with the app user's object ID which made the app crash once and than totally unusable. I marked the first answer as the correct answer since it solved my original question but just fyi.. there was more going on than I expected at first.
Just try this:
public void createDataObject(){
ParseObject object = new ParseObject("TestData");
object.put("action", "trial");
object.put("value", "succes?");
object.put("name", ParseUser.getCurrentUser().getUsername());
object.put("pointer", ParseUser.getCurrentUser());
object.saveEventually();
}
No need to get the object ID to set the current User.
Edit:
You can also refer https://stackoverflow.com/a/28403968/2571060 to set pointer
I had a similar issue with the iOS SDK. Are you using 'automatic user creation' ? Cause in that case, ParseUser.getCurrentUser() returns a User object whose objectId is null. According the documentation, it is null until the user or any object related to it is saved. But in my experience, it is not the case, I had to save the user first or I would get an error like 'User can only be created during signUp' or something like this.

how can I use Text datatype in app engine entity

I am getting problems in using Text datatype in entity class for storing values more than 500 characters long while using app engine. As com.google.appengine.api.datastore.Text is not available in my android activity class, how do I create a Text datatype in my android class?
I tried using below code while defining my entity class, but I still get illegalargument exception when trying to use get/set methods in my android activity class.
private Text storyContent;
public String getStoryContent() {return storyContent.getValue();}
public void setStoryContent(String storyContentString) {
this.storyContent=new Text(storyContentString);
}
updating App engine SDK to the latest one(1.8) seems to have resolve the issues. Looks like it was a known issue in app engine. I guess for longer than 500 characters long values, datastore is internally converting to Text type. hence I can see my values are being stored at Text type in datastore viewer.
http://code.google.com/p/googleappengine/issues/detail?id=9035

Passing a string's variable by reference in Android

Hello all I'm new to android programming and I have a problem.
I created a sudoku app with preset puzzles for 3 difficulties using an e - book's directions.
The thing is that I made a puzzle generator for my puzzles to make them infinite.Now here is my problem :
To save your pre-defined puzzle in the book's example you had to use :
getPreferences(MODE_PRIVATE).edit().putString(PREF_PUZZLE,
toPuzzleString(puzzle)).commit();
toPuzzleString obviously converts the puzzle into a string(which was stored before in a 1 dimention array)
In order to load your saved settings to make the Continue option to work you had to use :
puz = getPreferences(MODE_PRIVATE).getString(PREF_PUZZLE,easyPuzzle);
BUT this works for a predefined puzzle stored in a private final string called "easypuzzle" at the beggining of the game.class . My puzzle is generated and stored in a 1 dimentional array when user clicks New Game.As a result I have to pass my generated puzzle as a reference(this is what I think) cause i tried to pass it like this :
getPreferences(MODE_PRIVATE).getString(PREF_PUZZLE,toPuzzleString(puzzle));
and when I close the game or just go back and try to Continue my game generates a new puzzle for me (or this is what I think it is) instead of loading the saved one.
What am I doing wrong? Can anyone help me , or tell me how to pass my puzzle as a reference like in c++?
Thank you all for your time any help would be appreciated....
As mentioned above, your puzzle may not be saved in preferences correctly. In order to check, change the getString(...) method to something like this:
String puzzleFromPrefs = getPreferences(MODE_PRIVATE).getString(PREF_PUZZLE, null);
if( null == puzzleFromPrefs ) {
// Then you know that it wasn't saved correctly...
}
This will cause null to be returned if the puzzle hasn't already been saved in the preferences. This will help narrow down where the issue may be.

Categories

Resources