InvitationID null in production but not in the same apk installed manually - google-play-services

I have a very strange beaviour in my game.
First of all, I have two version: paid and free, linked in same play service ID.
I developed and try the apps, and they work perfectly, so I put them in production, on google play.
Then I discover by feedback that the paid version, when accept the invitation, don't handle, becouse it's null!
In the free version instead, it works fine.
THE CODE IS THE SAME.
How is possible?
The same APK installed manually works, then put on google play doesn't works.
Anyone has this problem?
This is the code:
#Override
public void onSignInSucceeded() {
super.onSignInSucceeded();
Log.i(GameProps.TAG, "invitation: "+getInvitationId());
if (getInvitationId()!=null) {
Intent intent=new Intent(this, OnlineGameScreen.class);
intent.putExtra(GameProps.INVITATION_ID, getInvitationId());
startActivity(intent);
}
}
getInvitationId() return null.
How it is possibile?
Bye.

I solved.
The code before is changed with this:
#Override
public void onSignInSucceeded() {
super.onSignInSucceeded();
getGamesClient().loadInvitations(new OnInvitationsLoadedListener() {
#Override
public void onInvitationsLoaded(int statusCode, InvitationBuffer buffer) {
ArrayList<Long> timestamps=new ArrayList<Long>();
for (Invitation invitation:buffer) {
timestamps.add(invitation.getCreationTimestamp());
}
Collections.sort(timestamps);
if (!timestamps.isEmpty()) {
for (Invitation invitation:buffer) {
Log.i(GameProps.TAG, "invitation buffer: "+invitation.getInvitationId());
if (invitation.getCreationTimestamp()==timestamps.get(timestamps.size()-1)) {
invitationId=invitation.getInvitationId();
}
}
}
Log.i(GameProps.TAG, "invitation: "+invitationId);
if (invitationId!=null) {
Intent intent=new Intent(MainScreen.this, OnlineGameScreen.class);
intent.putExtra(GameProps.INVITATION_ID, invitationId);
startActivity(intent);
}
}
});
}
So I have to say that GooglePlayGames lib is buggy, becouse getInvitationId() doesn't work correctly.
Expecially becouse it works if apk is installed manually, and not for app downloaded from playstore.
It's happend with 2 of 4 of my apps, so I think it will remain a mistery.

Related

Asynchronous programming for IotHub Device Registration in Java?

I am currently trying to implement the Java web service(Rest API) where the endpoint creates the device in the IoTHub and updates the device twin.
There are two methods available in the azure-iot sdk. One is
addDevice(deviceId, authenticationtype)
and another is to
addDeviceAsync(deviceId, authenticationtype)
I just wanted to figure out which one should I use in the web service(as a best practice). I am not very strong in MultiThreading/Concurrency so was wondering to receive people's expertise on this. Any suggestion/Link related to this is much appreciated
Thanks.
The Async version of AddDevice is basically the same. If you use AddDeviceAsync then a thread is created to run the AddDevice call so you are not blocked on it.
Check the code#L269 of RegistryManager doing exactly that: https://github.com/Azure/azure-iot-sdk-java/blob/master/service/iot-service-client/src/main/java/com/microsoft/azure/sdk/iot/service/RegistryManager.java#L269
public CompletableFuture<Device> addDeviceAsync(Device device) throws IOException, IotHubException
{
if (device == null)
{
throw new IllegalArgumentException("device cannot be null");
}
final CompletableFuture<Device> future = new CompletableFuture<>();
executor.submit(() ->
{
try
{
Device responseDevice = addDevice(device);
future.complete(responseDevice);
}
catch (IOException | IotHubException e)
{
future.completeExceptionally(e);
}
});
return future;
}
You can as well build your own async wrapper and call AddDevice() from there.

Android Vitals “Bad Behaviour” Flags

Google Play recently released the “Android Vitals” feature in the Google Play Console whereby they present analytic information about the released app.
The Android Vitals tab contains analytic information like crashes, ANR, multi-crashes, Slow Rendering, Frozen Frames, etc. They also show “bad behaviour” metrics whereby they compare the analytics of your app with benchmarks. If your app gets flagged with bad beahviours flags, then supposedly it can impact your rankings/downloads etc.
Is anyone else experiencing bad behaviour flags in their app on google play?
Has anyone else seen a dramatic decrease in organic traffic since the Android Vitals tab was introduced?
Does anyone have any advice on how to best solve these “bad behaviour” flags considering our Apps are developed with AS
Thanks in advance
bad behav image
installs
java.lang.NullPointerException:
at com.mydemoapp.player.activity.Dashboard$37.subscribeActual (Dashboard.java:2033)
at io.reactivex.Observable.subscribe (Observable.java:10179)
at io.reactivex.internal.operators.observable.ObservableSubscribeOn$1.run (ObservableSubscribeOn.java:39)
at io.reactivex.Scheduler$1.run (Scheduler.java:134)
at io.reactivex.internal.schedulers.ScheduledRunnable.run (ScheduledRunnable.java:59)
at io.reactivex.internal.schedulers.ScheduledRunnable.call (ScheduledRunnable.java:51)
at java.util.concurrent.FutureTask.run (FutureTask.java:237)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run (ScheduledThreadPoolExecutor.java:272)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:607)
at java.lang.Thread.run (Thread.java:761)
--
private Observable<ArrayList<HashMap<String, String>>> provideSongListOberservable() {
return new Observable<ArrayList<HashMap<String, String>>>() {
#Override
protected void subscribeActual(Observer<? super ArrayList<HashMap<String, String>>> observer) {
File home = new File(MEDIA_PATH);
String[] values = getResources().getStringArray(R.array.array_songs);
ArrayList<HashMap<String, String>> songsList = new ArrayList<>();
if (home.listFiles(new FileExtensionFilter()).length > 0) {
for (File file : home.listFiles(new FileExtensionFilter())) {
try {
HashMap<String, String> song = new HashMap<>();
song.put(KEY_SONG_TITLE,
values[Integer.parseInt(file.getName().split("_")[1].substring(0,
(file.getName().split("_")[1].length() - 4))) - 1]);
song.put(KEY_SONG_PATH, file.getPath());
// Adding each song to SongList
songsList.add(song);
} catch (Exception e) {
e.printStackTrace();
}
}
}
observer.onNext(songsList);
}
};
}
An "App crashing" bad behavior means your app is crashing a lot.
Google Play has publicly said (eg this talk) that it will use bad behavior as a signal when deciding which how to order apps in search results, and choose which apps to promote.
In order to fix this - get your development team to make crash fixing a priority, not just adding new features. Use the crash reports in the Play console to find out the bugs in your app, and fix them.

Minecraft Bukkit Server

I have created my own Craft Bukkit Minecraft server, and have everything almost set up but have run into a problem. You see, I wish for the server to automatically say something like this every 45 seconds or so:
[Server] Remember to follow the rules! (ETC.)
But I am not sure how to do it. I think I'll require a script, but I have no idea how I'd go about writing it.
Thanks for any help.
If you are looking to make your own plugin you can do a scheduler task every X time and Bukkit.broadcastMessage.
Example:
#Override
public void onEnable() {
new BukkitRunnable() {
#Override
public void run() {
Bukkit.broadcastMessage("[Server] This is the message.");
}
}.runTaskTimer(this, 20, 20*60*10); // 20*60*10 = 10 minutes
}
But if you want a already coded plugin you can download it from spigotmc.org
https://www.spigotmc.org/search/31904533/?q=automessage&t=resource_update&o=relevance

Wakelock only working with usb-cable connected

I have a rather odd problem. Lately i tried to use a wakelock in my application using the following code:
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
PowerManager pm = (PowerManager) getSystemService(POWER_SERVICE);
screenLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK, "DoNotDimScreen");
button = (Button)findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
System.out.println("Clicked");
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
if (!locked)
setKeepScreenOn(WakeupLightActivity.this, true);
else setKeepScreenOn(WakeupLightActivity.this, false);
System.out.println("Screen will stay on");
}
});
}
public void setKeepScreenOn(Activity activity, boolean keepScreenOn) {
if(keepScreenOn) {
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
this.screenLock.acquire();
}
else {
activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
this.screenLock.release();
}
}
The wakelock works perfectly: 5 seconds after pressing the button (and locking my phone) the screen turns on. This test, however, was done while my phone was connected to my laptop for debugging using a USB cable.
Now comes the weird part. When I DON'T have my phone connected with the USB cable, the wakelock simply DOES NOT turn on the screen. The device I am using is an HTC desire. I have actually tested it on another HTC desire, which did the same thing. Next, i tried it on an HTC Desire HD. And guess what: It worked perfectly again! I am really confused about this and wondering if the problem is simply a flaw in my phone type, or if I am doing something wrong in my code. Is there anything I can do about it? It would be incredibly awkward if any potential customers with a malfunctioning phone type would encounter the same problem after having purchased my app.
Note that I also tried the application while charging my phone with the cable connected to a wall plug. This leads to the same problem as not having my phone connected at all. Both HTC Desires run the same Android version (2.2.2).
Apparently all of this occured simply because i was using the wrong flags. The problem was solved by creating the WakeLock with the following flags:
PowerManager.SCREEN_BRIGHT_WAKE_LOCK|PowerManager.ACQUIRE_CAUSES_WAKEUP

Facebook SDK android

I am trying to integrate Facebook sdk into my app.
When I press facebook login button, it shows generic erro "An error occurred. Please try again later"
Anyone knows what might be the cause of it.
private final class ButtonOnClickListener implements OnClickListener {
public void onClick(View arg0) {
if (mFb.isSessionValid()) {
SessionEvents.onLogoutBegin();
AsyncFacebookRunner asyncRunner = new AsyncFacebookRunner(mFb);
asyncRunner.logout(getContext(), new LogoutRequestListener());
} else {
mFb.authorize(mActivity, mPermissions, new LoginDialogListener());
}
}
}
Can anyone help me with this issue?
Thanks a lot.
Make sure you use your app id while running the application.
Try EasyFacebookAndroidSDK, it's easy to implement. here is a good sample http://kodefun.junian.net/2011/10/easy-facebook-android-sdk-simple.html