I'm writing a game in android using Google Play Games Services. I want to get other players using GamesClient.loadPlayerCenteredScores. The problem has to do with getting the profile image. I use getScoreHolderIconImageUri() and fetch the URI with ImageManager.loadImage. My image loaded listener never gets called and games services stops working like a second after the call, the game continues normally (As if games services was disconnected) and I don't get any error in the log whatsoever except for a warning.
Here is the code:
public void PlayersLoader(){
getMainActivity().getGamesClient().loadPlayerCenteredScores(
new OnLeaderboardScoresLoadedListener(){
#Override
public void onLeaderboardScoresLoaded(int statusCode, LeaderboardBuffer leaderboard, LeaderboardScoreBuffer scores){
if(statusCode==0){
LeaderboardScore score;
String playerId=getMainActivity().getGamesClient().getCurrentPlayer().getPlayerId();
ImageManager imMan=ImageManager.create(getContext());
for(int i=0;i<scores.getCount();i++){
score=scores.get(i);
String name;
if(score.getScoreHolder().getPlayerId().equals(playerId)){
name=getResources().getString(R.string.your_best);
}
else{
name=score.getScoreHolderDisplayName();
}
Uri imuri=score.getScoreHolderIconImageUri();
if(imuri!=null){
imMan.loadImage(new ImageLoaded(name),imuri);
}
}
System.out.println("Finish");
scores.close();
leaderboard.close();
}
}
},getResources().getString(R.string.HighScores),LeaderboardVariant.TIME_SPAN_ALL_TIME,
LeaderboardVariant.COLLECTION_SOCIAL,10);
}
}
class ImageLoaded implements OnImageLoadedListener{
String mName;
public ImageLoaded(String name){
mName=new String(name);
System.out.println(mName);
//This does get printed out (the names of the players)
}
#Override
public void onImageLoaded(Uri uri, Drawable drawable){
System.out.println("imageLoaded"); //This never gets printed out
}
}
This is what I get in the log:
//Your Best
//Player 1 Name
//Player 2 Name
//Finished
//Games Services has stopped working dialog in phone, when I click OK, this warning shows:
//*** Unexpectedly disconnected. Severing remaining connections.
If I remove the ImageManager call and print out the names only, they get printed out correctly and nothing stops working.
I don't know what's happening, I'm desperate.
EDIT
Even if I comment this line:
imMan.loadImage(new ImageLoaded(name),imuri);
the error happens.
It is only when I remove this that it stops happening:
Uri imuri=score.getScoreHolderIconImageUri();
It's so strange! Even if I do not do anything with imuri.
EDIT I posted the issue here. It seems it was a bug of Google Play Services. Sure they will fix it soon!
Sounds like maybe you're running into the same problem described in the public bug tracker. If so, a fix is inbound and things should be working again Real Soon Now[tm].
Related
I try to show Unity Ads rewarded placement through mediation on Android device, i figured out that its working on android 8 but when i test it on android 9 then UnityAds.isReady() always returns false.
this is the latest mediation gradle configuration.
implementation 'com.google.ads.mediation:unity:3.4.6.0'
this is my configuration code
//UnityAds.initialize(AdTask.this, AdConfig.UNITY_AD_GAME_ID, unityAdsListener,true);//this approach is depecated
UnityAds.initialize(AdTask.this,AdConfig.UNITY_AD_GAME_ID,true);
UnityAds.isInitialized(); // just to making sure that its been initialized
UnityAdsImplementation.addListener(unityAdsListener);
this is how i try to show the ad
if (UnityAds.isReady(AdConfig.UNITY_AD_NEW_TASK_PLACEMENT_ID)) {
UnityAds.show(AdTask.this, AdConfig.UNITY_AD_NEW_TASK_PLACEMENT_ID);
}
and this is my listener class
private class UnityAdsListener implements IUnityAdsListener {
#Override
public void onUnityAdsReady (String placementId) {
// Implement functionality for an ad being ready to show.
}
#Override
public void onUnityAdsStart (String placementId) {
// Implement functionality for a user starting to watch an ad.
}
#Override
public void onUnityAdsFinish (String placementId, UnityAds.FinishState finishState) {
// Implement functionality for a user finishing an ad.
Log.d("unityad","finished");
}
#Override
public void onUnityAdsError (UnityAds.UnityAdsError error, String message) {
// Implement functionality for a Unity Ads service error occurring.
Log.d("ERROR","zzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"+message);
}
}
i debugged each steps and found that unity ad gets initialized but ad is not ready to be shown.
log has no clue what is happening therefore i am not sharing the logcat. if any of you have experienced this before then i would love to know how you handled this.
I don't know if it's related, But I'm currently working on my game and ads were working fine, today (like 1 hour ago) i tested my game and the ads were not ready no matter what.. perhaps it's a problem with Google ads?
This is my second question here. I am not 100% on the formatting and etiquette yet. I apologize in advance. I have a published app using the BaseGameUtils provided by Google. My achievements unlock properly, and the popups show properly, using incrementImmediate(parameters) with a result. However, the result, which I do receive, always comes back as STATUS_OK, even when the call results in unlocking the achievement. I can't manage to get result.getStatus().getStatusCode() to ever be STATUS_ACHIEVEMENT_UNLOCKED. Can anyone help?
Try to use the code given in this SO question, it will make your achievement increment by the amount of steps you want.
Games.Achievements.incrementImmediate(GoogleApiClient apiClient, String id, int numSteps).setResultCallback(new ResultCallback<Achievements.UpdateAchievementResult>() {
#Override
public void onResult(UpdateAchievementResult result) {
if (result.getStatus().getStatusCode() == GamesStatusCodes.STATUS_ACHIEVEMENT_UNLOCKED) {
}
}
});
The STATUS_ACHIEVEMENT_UNLOCKED indicates that the incremental achievement was also unlocked when the call was made to increment the achievement.
You can also try to check this related SO question.
need a little help. Im making an android app and integrated Soomla for a simple "No ads" purchase inside my app. Ive a purchase button which should do the actual purchase via google.
What occurs is a popup from google : "Error
authentication needed, You have to login in your google account" .
I think its a small problem, but i dont get what. I am logged in in my google account. Store in Soomla is running ( at least it says so). ive enable test purchase.Im using my phone for the purchase ofc. What i am missing?
public class NoADsButton : MonoBehaviour {
private static bool storeInitialized = false; // prevent store to be initialized twice
void Start () {
if(storeInitialized) return;
SoomlaHighway.Initialize();
StoreEvents.OnSoomlaStoreInitialized += onSoomlaStoreInitialized;
SoomlaStore.Initialize(new SoomlaAssets());
}
public void onSoomlaStoreInitialized() {
storeInitialized = true;
}
public void OnMouseDown(){
StoreInventory.BuyItem("no_ads");
}
And the item ive done as its shown in the soomla example:
public const string NO_ADDS_PRODUCT_ID = "no_ads";
public static VirtualGood NO_ADS_LTVG = new LifetimeVG(
"No Ads", // name
"No More Ads!", // description
"no_ads", // item id
new PurchaseWithMarket(NO_ADDS_PRODUCT_ID, 0.99)); // the way this virtual good is purchased
}
This usually happens when the process of publishing the app for testing wasn't done properly. Try going carefully over Google's instructions, make sure you didn't miss anything. http://developer.android.com/google/play/billing/billing_testing.html#billing-testing-test
I have integrated Brightcove android-sdk-4.2.7 and trying to play video using videoID.
Here is the code snippet :
Catalog catalog = new Catalog(<**MEDIA_READ_TOKEN**>);
catalog.findVideoByID(videoId, new VideoListener() {
#Override
public void onError(String error) {
Log.e(TAG, "onError : " + error);
}
#Override
public void onVideo(Video video) {
Log.i(TAG, "onVideo called" );
brightcoveVideoView.add(video);
brightcoveVideoView.start();
}
});
When I launch video_player_activity from other activity for the first time video plays perfectly fine, but when I go back to second activity and again try to play the same/other video, It does not play. onVideo does not get called. Sometimes it gets called after a long time.
Following are some more details :
activity is getting destroyed properly when I go back
onError is not getting called
video id is getting set properly
Tried emitter events and READY_TO_PLAY event occurs but DID_PLAY does not
Android version I tested on is 4.4.x
What might be the possible issues? Any help/pointer around this will be really appreciated.
Thanks!
Repeated calls to findVideoByID(), should work fine. For each one, you should see a request in the logcat, something like:
D/HttpService(27297): issuing GET request: http://api.brightcove.com/services/library?command=find_video_by_id&video_id=3603631382001...
and a response, something like:
D/HttpService(27297): response: {"id":36036...
If that is not the case, please file a bug with Brightcove Support. If that is working, there isn't enough information here to debug further. You could try to compare what you are doing with the public sample apps available on Github:
https://github.com/BrightcoveOS/android-player-samples
These apps don't have multiple activities like your scenario, but they do handle the app going into the background and then being brought back to the foreground. Extending the BrightcovePlayer or BrightcovePlayerFragment enables the lifecycle handling. If you don't extend one of those classes, you have to write your own lifecycle handling, as if you were using the Android VideoView. For example, calling pause() in onPause() and calling stopPlayback() in onStop().
Lately, I have been trying to add static interstitial ads into my Unity game. For some reason, I could not get the system to show anything, or even react to me. After trying to work with the base Chartboost plugin, I tried to match a tutorial that I was following and purchased Prime31's Chartboost plugin and have been using that. However, neither the base plugin, nor Prime31's plugin, seem to be allowing me to show any ads. The code is pretty much done inside a single object, and it seems simple enough.
public class Advertisement : MonoBehaviour {
public string chartboostAppID = "5461129ec909a61e38b1505b";
public string chartboostAppSignature = "672b3b34e3e358e7a003789ddc36bd2bc49ea3b5";
// Use this for initialization
void Start () {
DontDestroyOnLoad(this.gameObject);
ChartboostAndroid.init (chartboostAppID, chartboostAppSignature, true);
ChartboostAndroid.cacheInterstitial(null);
}
void OnLevelWasLoaded(int level) {
ChartboostAndroid.cacheInterstitial(null);
if(Application.loadedLevelName == "Network Lobby") {
showAds();
}
}
public static void showAds() {
Debug.Log("Showing ad");
ChartboostAndroid.showInterstitial(null);
}
}
As you can see, it's pretty straightforward. This object is created at the game's splash screen, which appears only once, and it's never destroyed until the program ends. The goal is, whenever I enter the lobby scene, I want to see an ad before going to the lobby's menus. As it is, I do see the log printing "Showing ad", so I know the function is being called. However, nothing appears. Do I need to disable the GUI system first? Is there a step I'm missing?
I have already performed the following steps:
I have created and registered the app with chartboost, as well as double and triple checked the AppID and App Signature.
I have created a publishing campaign and registered it to the app.
I double-checked the orientation and confirmed that it's correct.
I registered this specific device as a test device.
The tutorial showed a call to ChartBoostAndroid.OnStart(), but there was no function like that for me to call. Perhaps that is from an older version?
I emailed Chartboost support and have not heard from them yet. I do not have that much time on this project, so if anyone can offer help, I'd appreciate it.