Description for google play game services Match - android

I'm implementing a game with turn based multiplayer with google play game services:
https://developers.google.com/games/services/android/turnbasedMultiplayer
My game has some different variations and in order to help users choose easily from the default UI, I would want to add a name for each match.
If it was possible, a player with for example 2 current matches would be able to identify each one easily without opening it.
Thanks.

You could put this information into your Turn data. Like this...
// This is the byte array we will write out to the TBMP API.
public byte[] persist() {
JSONObject retVal = new JSONObject();
try {
retVal.put("data", data);
...
You could then write a custom function to retrieve the match data and you would have to put that information into a custom inbox dialog. I have not done this currently...

This functionality is part of the standard product. Look at the sample from google skeletonTBMP.java and also the skeletonTurn.java (I think it is called). This is where you pass data between turns. It would be fairly easy to populate this into the "data" object which gets updated at each turn, and then display this value on the screen as text. Link here...
https://github.com/playgameservices/android-basic-samples/tree/master/BasicSamples/SkeletonTbmp/src/main/java/com/google/example/tbmpskeleton

Related

How do I get my own node_id for dataclient.getDataItem(Uri)?

In my project a wearos app communicates with a handheld mobile app using dataitems. My wearOS app sends data by placing and changing a data item in the data layer.
Before placing the item I want to load/get the item before potentially overwriting its content. I can recieve it using dataClient.getDataItems(). Yet to me this just seems not optimal, I wanna use dataClient.getDataItem(uri). In order to get the specific item I merely need the uri.
uri format: wear://<node_id>/<path>
The only thing I dont know is the node_id of my creator node. Through logging I have seen, that, even doe I create a new DataClient everytime, when I put a new item to data layer, the node id stays same. Yet I couldnt find a way to access the id.
I feel like there should be a simple function like getLocalNodeId() to get the missing uri part. Am I wrong?
No idear, why that took me so long to find:
var node_id = Tasks.await(getNodeClient(context).localNode).id

filter json results into image path

Hello i am using MIT App Inventor 2 to make an app that runs on an old (spare) android phone to display the folder.jpg of currently playing movie (later on I also want to do that with music).
I can't filter the path to use, for example this is the result of the json:
{"id":"VideoGetItem","jsonrpc":"2.0","result":{"item":{"id":1,"label":"2012","thumbnail":"image://F%3a%5cMovies%5c2012%5cfolder.jpg/","type":"movie"}}}
I want to keep: image://F%3a%5cMovies%5c2012%5cfolder.jpg which is the dvd cover (and maybe the label: 2012 which is the title of the movie).
I tried various options like making a list but then I still get text with lot of params between '()'
Can someone help me with this?
Thanks
Use the JSON decode block together with the lookup in pairs block. As you can see, it helps to use Do it...
I have something that is doing it for me for starters.
I see a flaw but that's in Kodi(.tv) itself (I am not a fan of the library system in kodi, so I put a folder.jpg in every drawer of a movie, but sometimes kodi doesn't display it and presents me with a video preview of the movie, I have to sort that out with kodi developers)
For now I am glad I have it working,
solution picture

Inquiry google game services for current matches

I'm implementing turn based game services for a simple game:
https://developers.google.com/games/services/android/turnbasedMultiplayer
I'm using the GameHelper class from basegameutils as recommended.
I want to save some data that isn't relevant (statistics) so I don't want to sent it between players. I'm saving this data locally (sqlite) linking it with TurnBasedMatch.getMatchId().
What I need to know is how to inquiry google game services (I guess via GameHelper) which are the current matches for the signed player, so I can delete old local data.
Thanks.
Looking better at documentation I finally found a solution for that.
If your activity extends from BaseGameActivity you can do the following:
Games.TurnBasedMultiplayer.loadMatchesByStatus(getApiClient(),
TurnBasedMatch.MATCH_TURN_STATUS_COMPLETE,
TurnBasedMatch.MATCH_TURN_STATUS_MY_TURN,
TurnBasedMatch.MATCH_TURN_STATUS_THEIR_TURN)
.setResultCallback(deleteNotPresentMatches);
using your own call back, for example:
private ResultCallback<TurnBasedMultiplayer.LoadMatchesResult> deleteNotPresentMatches = new ResultCallback<TurnBasedMultiplayer.LoadMatchesResult>() {
public void onResult(TurnBasedMultiplayer.LoadMatchesResult r) {
//whatever you want, in my case delete local data for old matches
}
};

Testing html5 inputs in Android application by Robotium

At start i want to say sorry about my English skill. I write automated test for the hybrid Android application. GUI of this app is written in HTML5/JS/CSS3 (with angularJS framework). I want to test any data form. Form is filled with some data on the start (received from server). To enter new data I have to clear current value and enter the new one. For enter new text i use:
By element = By.cssSelector("...");
solo.waitForWebElement(element);
solo.typeTextInWebElement(element, "foo", 0);
and it works well. I have got problems with data clear. In the Robotium documentation i found method:
solo.clearTextInWebElement(item);
This method cannot get index parameter (I don't know why), it only use the "By" object to catch specified element. I decided to use code like:
By item = By.cssSelector("input:nth-child(3)");
this.solo.waitForWebElement(item);
this.solo.sleep(3000);
this.solo.clearTextInWebElement(item);
but still doesn't work too. I don't know how to test web inputs by Robotium.
If the web elements have name or id attributes then you can use By.id("elementId") or By.name("elementName") to access them.
Your question will be easier to answer if you post more sample code, particularly the html of the elements you're trying to test.

Smartway to implement media in Android

I am working on an Android app, where media(audio/video/images) could be stored either internally/externally. I would be facing the following scenarios
Case I
Setting dynamically images from the random value broadcasted by the app.
Right now, I am managing it as
if(rowData.strName.equals("football")){
imageView.setImageResource(R.drawable.football);
}else if(rowData.strName.equals("chess")){
imageView.setImageResource(R.drawable.chess);
Problem As of now, I am having few records so managing else if loop in not big headache, but later it could turn out to be one.
Case II
Downloading a media from internet, saving it in external storage and loading it on an imageview as an when required
Problem Incase, the image has already been downloaded(app keeps track of downloaded image), the user ejects the card, then I plan to use
try{
}catch(FileNotFoundException e){
imageView.setImageResource(R.drawable.no_media);//media from the app
}
Case III
I will be having a listView of a category.Each Category contains certain sub-category names,their images(inbuilt & to be downloaded externally) & their description.Each sub-category has sub records with each record having its own one or image(inbuilt & to be downloaded externally),description and media files(both audio and video).
I am confused on what Collection class shall I use for this case and how to begin with? For data that is to be retrieved from the server(online), I plan to use XMLParsing. Please suggest me the best way to achieve the problem.
Wow! This is really three questions. If only I could get three times the rep :)
Case I
Use a Map to store and retrieve stuff. Saves you writing lots of if/else statements.
Map<String,Integer> drawableMap = new HashMap<String,Integer>();
drawableMap.put("football", R.drawable.football);
// Then later to retrieve...
imageView.setImageResource(drawableMap.get("football"));
Case II
OK, this seems fine. Though for most of my image loading I use existing libraries like Universal Image Loader or Volley. These may do what you need, I'm not sure.
Case III
I would take an OO approach and model the data appropriately. You don't have to choose "a" Collection class to use. Create a Category class. Create a SubCategory class. Have the Category class "have" SubCategories, etc. Take it from there.
XML parsing is fine, I'm not sure what you're expecting to be suggested. You may also like to consider JSON, a popular data format.

Categories

Resources