SDKBOX IAP 2.4.3.3 black screen on resume (Android)

SDKBOX IAP 2.4.3.3 black screen on resume (Android)
0

#1

(Cocos2d-x 3.17)

Scenario:

  1. Push buy button
  2. Purchase interface appears
  3. Go to background
  4. Go to foreground

And we will see black screen on background and purchase interface.

I have this code in AppActivity.java

public class AppActivity extends com.sdkbox.plugin.SDKBoxActivity {

and

@Override
    protected void onResume() {
          super.onResume();
          Cocos2dxHelper.onResume();
          this.getGLSurfaceView().onResume();
    }

#2

It was reproduced.


#3

do you have android:launchMode=“singleInstance” with AndroidManifest.xml ?


#4

No, AndroidManifest.xml does not have “android:launchMode”.


#5

plz show the AndroidManifest.xml


#6
<?xml version="1.0" encoding="utf-8"?>
<manifest 
    xmlns:android="http://schemas.android.com/apk/res/android"
    package="jp.co.hoge.test"
    android:installLocation="auto">

    <uses-feature android:glEsVersion="0x00020000" />
    
    <application 
        android:label="@string/app_name"
        android:icon="@mipmap/ic_launcher"
        android:allowBackup="true">

        <!-- Tell Cocos2dxActivity the name of our .so -->
        <meta-data 
            android:name="android.app.lib_name"
            android:value="MyGame" />
        
        <activity 
            android:name="org.cocos2dx.cpp.AppActivity"
            android:label="@string/app_name"
            android:screenOrientation="portrait"
            android:theme="@android:style/Theme.NoTitleBar"
            android:configChanges="orientation|screenSize">

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>

            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE"/>
                <data android:scheme="test" android:host="aiueo" />
            </intent-filter>
        </activity>

        <!--This meta-data tag is required to use Google Play Services.-->
        <meta-data android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />

        <!--Include the AdActivity configChanges and theme. -->
        <activity android:name="com.google.android.gms.ads.AdActivity"
            android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
            android:theme="@android:style/Theme.Translucent" />

        <!-- play-services-ads:17.0.0以降で必要 -->
        <meta-data
            android:name="com.google.android.gms.ads.APPLICATION_ID"
            android:value="ca-app-pub-12345678901234567890"/>


        <!-- SocialShare: target sdk 24 over need -->
        <provider
            android:name="org.kawaz.socialshare.SocialShare"
            android:authorities="${applicationId}.jp.co.hoge.test"
            android:exported="false"
            android:grantUriPermissions="true">
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/provider_paths"/>
        </provider>

    </application>
    
    <supports-screens 
        android:anyDensity="true"
        android:smallScreens="true"
        android:normalScreens="true"
        android:largeScreens="true"
        android:xlargeScreens="true"/>
    
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="com.android.vending.BILLING"/>


</manifest>

#7

It is reproduced on an empty project after adding IAP. I think the issue is not in the manifest.


#8

plz add

        <activity
            android:name="com.android.billingclient.api.ProxyBillingActivity"
            android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
            android:theme="@android:style/Theme.Translucent.NoTitleBar" />

to application tag.


#9

I added a tag to AndroidManifest, but not fixed it.

It becomes a black screen, but it returns to original by purchase or cancellation.
It is not a critical issue


#10

onResume function not called in my Activity when store interface is open. This is the reason for the black screen.


#11

whats you appactivity.java code.


#12
package org.cocos2dx.cpp;

import org.cocos2dx.lib.Cocos2dxActivity;
import org.cocos2dx.cpp.MyCocos2dxGLSurfaceView;
import org.cocos2dx.lib.Cocos2dxGLSurfaceView;
import org.cocos2dx.lib.Cocos2dxHelper;
import android.content.Intent;
import android.os.Bundle;
import android.os.Build;
import android.content.Context;
import android.content.ClipboardManager;
import android.view.WindowManager;
import android.util.Log;
import org.cocos2dx.cpp.AppInfo;
import java.util.HashMap;
import java.util.Map;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONTokener;
import java.io.StringWriter;
import android.content.ActivityNotFoundException;
import android.app.NotificationManager;

import java.util.Calendar;

import android.app.Activity;
import android.app.AlarmManager;
import android.app.NativeActivity;
import android.app.PendingIntent;
import android.net.Uri;

import com.sdkbox.plugin.SDKBox;

//crashlitics
import com.crashlytics.android.Crashlytics;
import io.fabric.sdk.android.Fabric;

import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GoogleApiAvailability;
import android.support.annotation.Keep;

public class AppActivity extends com.sdkbox.plugin.SDKBoxActivity {
	
    public static AppActivity globalMainActivity = null;
    
    private static final String TAG = Cocos2dxActivity.class.getSimpleName();
    
    @Keep public static native void   sendReferrer (String key, String referrer);
    @Keep public static native void   setOpenAppNotificationData (String quizgeekData);
    @Keep public static native void   setCustomerUserId (String id);
    
    @Override
    protected void onCreate(final Bundle savedInstanceState) {
        super.setEnableVirtualButton(false);
        super.onCreate(savedInstanceState);
        
        if (!isTaskRoot()) {
            // Android launched another instance of the root activity into an existing task
            //  so just quietly finish and go away, dropping the user back into the activity
            //  at the top of the stack (ie: the last state of this task)
            // Don't need to finish it again since it's finished in super.onCreate .
            return;
        }

        MyFirebaseMessagingService.mIsShowPushNotification = false;
    }
    
    @Override
    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
    }

    @Override
    public Cocos2dxGLSurfaceView onCreateView() {
        
        if ( globalMainActivity == null ) {
            globalMainActivity = this;
        }
        
        NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        notificationManager.cancelAll();

        MyCocos2dxGLSurfaceView glSurfaceView = new MyCocos2dxGLSurfaceView(this);
        // TestCpp should create stencil buffer
        glSurfaceView.setEGLConfigChooser(5, 6, 5, 0, 16, 8);
        
        return glSurfaceView;
    }
    
    
    //start notification functions
    @Keep
    public static void showLocalNotification(String message, int interval, int tag) {
        Log.v(TAG, "showLocalNotification");
        PendingIntent sender = getPendingIntent(message, tag);
        
        Calendar calendar = Calendar.getInstance();
        calendar.setTimeInMillis(System.currentTimeMillis());
        calendar.add(Calendar.SECOND, interval);
        
        AlarmManager am = (AlarmManager)Cocos2dxHelper.getActivity().getSystemService(ALARM_SERVICE);
        am.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), sender);
    }

    @Keep
    public static void cancelLocalNotification(int tag) {
        Log.v(TAG, "cancelLocalNotification");
        PendingIntent sender = getPendingIntent(null, tag);
        AlarmManager am = (AlarmManager)Cocos2dxHelper.getActivity().getSystemService(ALARM_SERVICE);
        am.cancel(sender);
    }

    @Keep
    public static void cancelAllNotification() {
        String ns = globalMainActivity.NOTIFICATION_SERVICE;
        NotificationManager nMgr = (NotificationManager) globalMainActivity.getSystemService(ns);
        nMgr.cancelAll();
    }
    
    private static PendingIntent getPendingIntent(String message, int tag) {
        Intent i = new Intent(Cocos2dxHelper.getActivity().getApplicationContext(), LocalNotificationReceiver.class);
        i.putExtra("notification_id", tag);
        i.putExtra("message", message);
        PendingIntent sender = PendingIntent.getBroadcast(Cocos2dxHelper.getActivity(), 0, i, 0);
        return sender;
    }
    //end notification functions
    
    //Crashlytics manager functions
    @Keep
    public static void setCrashlyticUserData(String id, String name) {
        Log.v(TAG, "setCrashlyticUserData");
        Crashlytics.setUserIdentifier(id);
        Crashlytics.setUserName(name);
    }

    @Keep
    public static void crashlyticLog(String s) {
//        Log.v(TAG, "crashlyticLog");
        Crashlytics.log(s);
    }

    @Keep
    public static void crashliticCrash () {
        Log.v(TAG, "crashliticCrash");
        Crashlytics.getInstance().crash();
    }

    @Keep
    public static void crashliticThrowException () {
        Log.v(TAG, "crashliticThrowException");
        throw new RuntimeException("This is a crash");
    }

    @Keep
    public static void intiCrashlytic() {
        Log.v(TAG, "intiCrashlytic");
        Fabric.with(globalMainActivity, new Crashlytics());
    }
    
    @Override
    protected void onStart() {
          super.onStart();
          MyFirebaseMessagingService.mIsShowPushNotification = false;
    }
    @Override
    protected void onStop() {
          super.onStop();
          MyFirebaseMessagingService.mIsShowPushNotification = true;
    }
    @Override
    protected void onResume() {
          super.onResume();
          Cocos2dxHelper.onResume();
          this.getGLSurfaceView().onResume();
          MyFirebaseMessagingService.mIsShowPushNotification = false;
          Log.v(TAG, "+++ onResume");
    }
    @Override
    protected void onPause() {
          super.onPause();
          Cocos2dxHelper.onPause();
          this.getGLSurfaceView().onPause();
          MyFirebaseMessagingService.mIsShowPushNotification = true;
    }

}

#13

plz try to comment this function.

//@Override
//protected void onNewIntent(Intent intent) {
//    super.onNewIntent(intent);
//}

#14

Didn’t help. Anyway black screen. onResume is called after closing store interface.


#15

Can you reproduce the black screen?


#16

https://www.dropbox.com/s/0mrrpkdliv8liar/1551235175955892.mp4?dl=0
No I can not reproduce this issue.

my appactivity.java

package org.cocos2dx.cpp;

import android.util.Log;
import org.cocos2dx.lib.Cocos2dxActivity;

import android.os.Bundle;
import android.content.Intent;
import com.sdkbox.plugin.SDKBox;

public class AppActivity extends com.sdkbox.plugin.SDKBoxActivity {

    protected void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
    }

    @Override
    protected void onStart() {
        super.onStart();
    }

    @Override
    protected void onStop() {
        super.onStop();
    }

    @Override
    protected void onResume() {
        super.onResume();
        Log.d("AppActivity", "onResume");
    }

    @Override
    protected void onPause() {
        super.onPause();
    }

    @Override
    public void onBackPressed() {
        super.onBackPressed();
    }
}

#17

You are reproducing.
The background character disappears when foreground.


#18

i comment stopAnimation in applicationDidEnterBackground, and the game ui will show.


#19

It works. But it doesn’t seem like a good solution :slight_smile: