In my android app i m using open feint and i m facing problem in getting my rank(current player).
how do i get that.here is my code.
//hard coded for example
long scoreValue = 60;
Score s = new Score(scoreValue, null);
Leaderboard l = new Leaderboard(String.valueOf(HomeScreen.LeaderBoardId));
s.submitTo(l, new Score.SubmitToCB() {
#Override
public void onSuccess(boolean newHighScore) {
System.out.println("Score submitted successfully");
}
#Override
public void onFailure(String exceptionMessage) {
Toast.makeText(GameScreen.this,
"Error (" + exceptionMessage + ") posting score.",
Toast.LENGTH_SHORT).show();
}
});
User u= OpenFeint.getCurrentUser();
int rank=s.rank;
System.out.println("RANK"+rank);
i can get the user details but i dont know how do i get my rank. i m stuck.please help.
thanks in advance.
Rank is not set when you submit a score. See this discussion for details.
You have to use the leaderboard to get the rank.
Also openfient is being replaced with GREE, so if you are just starting you may want to switch to the new platform.
Related
I have implemented voice commands on my app to make it easier for the user to set variables, I have tried using StringTokenizer to split the commands so I only get the variable but that doesn't seem to work, can someone point me in the right direction?
#Override
public void OnResult(ArrayList<String> commands) {
for(String command:commands)
{
if (command.contains("set amount to")){
StringTokenizer tokens = new StringTokenizer(command, "to");
String first = tokens.nextToken();
String second = tokens.nextToken();
Log.e("TAG", command);
Log.e("TAG", "First " + first);
Log.e("TAG", "Second " + second);
}
}
}
The command I give is for example set amount to 5 and it comes back as First se and Second am and I am not sure how to make it find the 5 or if they add on additional words after like 5 dollars I don't want to pick up the dollars.
We want to display all leaderboard data into our custom created UI for the game. for that we want to access top scores info such as Profile Picture,Score and Name of the player.
All data will be shown in our custom created UI
we are using following unity3d plugin of google
https://github.com/playgameservices/play-games-plugin-for-unity
Please let us know how to access all players data of our game leaderboard
The you link provided has the actual documentation on how to use the plugin. From Accessing Leaderboard data (where you could get the Score) to Getting Player names, where it is mentioned that you could
use Social.LoadUsers() to load the player profile
from there you could get an IUserProfile to get the image and username. Sample from the same link:
internal void LoadUsersAndDisplay(ILeaderboard lb)
{
// get the user ids
List<string> userIds = new List<string>();
foreach(IScore score in lb.scores) {
userIds.Add(score.userID);
}
// load the profiles and display (or in this case, log)
Social.LoadUsers(userIds.ToArray(), (users) =>
{
string status = "Leaderboard loading: " + lb.title + " count = " +
lb.scores.Length;
foreach(IScore score in lb.scores) {
IUserProfile user = FindUser(users, score.userID);
status += "\n" + score.formattedValue + " by " +
(string)(
(user != null) ? user.userName : "**unk_" + score.userID + "**");
}
Debug.log(status);
});
}
With all that said, if you were hoping for a more detailed and precise sample, it'd be considered as too broad here in Stack Overflow and may be voted to be closed.
I am using Google Fit API, be specific using HistoryApi
I am using Fitness.HistoryApi.readDailyTotal to get steps, calories and distance. From that I got steps and calories but distance is creating problem. But onResult is not getting called. Any help would be highly appreciated.
PendingResult<DailyTotalResult> distanceResult = Fitness.HistoryApi
.readDailyTotal(mClient, DataType.TYPE_DISTANCE_DELTA);
distanceResult.setResultCallback(new ResultCallback<DailyTotalResult>() {
#Override
public void onResult(DailyTotalResult dailyTotalResult) {
if (dailyTotalResult.getStatus().isSuccess()) {
DataSet totalSet = dailyTotalResult.getTotal();
long distance = totalSet.isEmpty()? 0: totalSet.getDataPoints().get(0).getValue(Field.FIELD_DISTANCE).asInt();
Log.i("-------------", "distance= " + distance);
}
}
});
From above code if (dailyTotalResult.getStatus().isSuccess()) { this is false in case of distance and it returns true while I try to get steps and calories.
All above code is run in background thread.
Can you please try adding below scope ?
.addScope(new Scope(Scopes.FITNESS_LOCATION_READ))
Also upgrade with new fit api:
compile 'com.google.android.gms:play-services-fitness:10.0.0'
I am doing offline geocoding with skobbler sdk. I use the offline map for Germany and I am searching for States within Germany. I have set the search language to German. As an example I am looking for "Niedersachsen". Passing the first few letters, e.g. "Nie" makes the SearchManager find "Niedersachsen" but in the skSearchResult variable the name is "Lower Saxony". So the correct State is found but in the wrong language(english instead of german). How can I solve this? Here is my piece of codes which does the search:
public class AddressSearchListener implements SKSearchListener {
// current list level at which to search
private String mapPackageName;
private AddressSearchFragment addressSearchFragment;
public AddressSearchListener() {
Log.d("AddressSearchListener", "begin");
this.mapPackageName = "DE";
}
public void setFragment(AddressSearchFragment addressSearchFragment) {
this.addressSearchFragment = addressSearchFragment;
}
public void startSearch(long parentId, SKSearchManager.SKListLevel searchLevel, String s) {
Log.d("AddressSearchListener", "startSearch begin");
// get a search manager object
SKSearchManager mgr = new SKSearchManager(this);
// get a multi-step search object
SKMultiStepSearchSettings searchSettings = new SKMultiStepSearchSettings();
searchSettings.setSearchLanguage(SKMaps.SKLanguage.LANGUAGE_DE);
// set the offline package in which to search
// the France package in this case needs to be installed
searchSettings.setOfflinePackageCode(mapPackageName);
// set list level of the search
searchSettings.setListLevel(searchLevel);
// set maximum number of results to be received
searchSettings.setMaxSearchResultsNumber(20);
// set the id of the parent in which to search
searchSettings.setParentIndex(parentId);
// set a filter for the results
searchSettings.setSearchTerm(s);
// initiate the search
Log.d("AddressSearchListener", "startSearch time " + System.currentTimeMillis());
mgr.multistepSearch(searchSettings);
}
#Override
public void onReceivedSearchResults(List<SKSearchResult> skSearchResults) {
Log.d(getClass().getName(), "onReceivedSearchResults begin");
Log.d("AddressSearchListener", "onReceivedSearchResults time " + System.currentTimeMillis());
List<AddressSearchResultMeta> addressSearchResults = new ArrayList<AddressSearchResultMeta>();
for (SKSearchResult skSearchResult : skSearchResults) {
Log.d("onReceivedSearchResults", "result: " + skSearchResult);
AddressSearchResultMeta addressSearchResultMeta = new AddressSearchResultMeta(skSearchResult);
addressSearchResults.add(addressSearchResultMeta);
}
addressSearchFragment.passResults(addressSearchResults);
}
}
The issue was just a bug within Skobbler SDK. It is fixed in version 2.5.1.
I am building an app to help you keep track of tv-shows.
When i first add my "widget" to dashclock the notification appear if there is any, but after a while they disappear again.
The code for my activity extending DashClockExtension
#Override
protected void onUpdateData(int reason) {
DatabaseHandler databaseHandler = new DatabaseHandler(this);
ArrayList<Episode> episodes = databaseHandler.GetTodaysEpisodes();
DateHelper dateHelper = new DateHelper();
String numberOfEpisodes = "" +episodes.size();
StringBuilder sb = new StringBuilder();
for (Episode episode : episodes) {
sb.append(dateHelper.Episodenumber(episode) + " " + episode.getTitle() + "\n");
}
publishUpdate(new ExtensionData()
.visible(true)
.icon(R.drawable.ic_icon_dashclock)
.visible(!numberOfEpisodes.equals("0"))
.status(numberOfEpisodes)
.expandedTitle(numberOfEpisodes + " episodes airing today")
.expandedBody(sb.toString())
.clickIntent(new Intent("se.ja1984.twee.CalendarActivity_LAUNCH_IT"))
);
}
Since my data isn´t updated that often I´m satisfied with letting DashClock check for updates.
I´m new to android development and are probably doing something wrong :) And I would really appreciate someone pointing me in the right direction!
Okey so I solved it!
When my app starts I set and static integer with the chosen profile which i then use when fetching data from the database. So when my app is killed by the system it tries to fetch data for profile 0 (which never exists).
Thank you Robby and Roman for the help and time invested in this! :)
You are setting visible=false when numberOfEpisodes is "0". That's most likely what is happening. You can debug the extension like you would debug any other app. Just run it in debug, and then attach to your app through ddms.