-2

I'm dealing with this issue for quite a while, I'm trying to show two buttons on an event condition, specifically this one.

            player.on(PlayerEvent.TimeChanged.class,
                (event) -> {
                    context.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit("timeChanged", event.getTime()); 
                    if (Math.floor(event.getTime()) > nextContentStart) {
                        Log.e("ReactNative",""+Math.round(event.getTime()));
                        Log.e("ReactNative",""+nextContentStart);
                        Log.d("ReactNative", "here IF"); //gets here no problem
                        nextBtn.setVisibility(View.VISIBLE); //crashes here
                        creditsBtn.setVisibility(View.VISIBLE);
                    }

                }
        );

It crashes on the part that is commented (nextBtn.setVisibility(View.VISIBLE)).

I guess it's got to be related to the IF clause being looped inside an event emmiter?

Here's the rest of the code:

PlayerActivity.java

import android.os.Bundle;
import android.util.Log;
import android.view.WindowManager;
import android.content.Intent;
import androidx.appcompat.app.AppCompatActivity;
import com.bitmovin.player.PlayerView;
import com.bitmovin.player.api.Player;
import com.bitmovin.player.api.drm.DrmConfig;
import com.bitmovin.player.api.drm.WidevineConfig;
import com.bitmovin.player.api.event.Event;
import com.bitmovin.player.api.event.PlayerEvent;
import com.bitmovin.player.api.source.Source;
import com.bitmovin.player.api.source.SourceConfig;
import com.bitmovin.player.api.source.SourceOptions;
import com.bitmovin.player.api.source.SourceType;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.modules.core.DeviceEventManagerModule;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

import android.util.Log;
import android.view.View;
import android.widget.Button;

import android.app.Activity;

public class PlayerActivity extends AppCompatActivity {

    private PlayerView playerView;
    private Player player;
    private String dashUrl;
    private String hlsUrl;
    private String posterUrl;
    private String drmToken;
    private double watchedSeconds;
    private double durationSeconds;
    private double nextContentStart;

    public static final String CONTENT_ID = "SOURCE_CONTENT_ID";
    public static final String DASH_URL = "SOURCE_DASH_URL";
    public static final String HLS_URL = "SOURCE_HLS_URL";
    public static final String TITLE = "SOURCE_TITLE";
    public static final String DESCRIPTION = "SOURCE_DESCRIPTION";
    public static final String POSTER = "SOURCE_POSTER";
    public static final String DRM_TOKEN = "SOURCE_DRM_TOKEN";
    public static final String WATCHED_SECONDS = "WATCHED_SECONDS";
    public static final String DURATION_SECONDS = "DURATION_SECONDS";
    public static final String NEXT_CONTENT_START = "NEXT_CONTENT_START";

    public static final String WIDEVINE_LICENSE_URL = "https://widevine-license.vudrm.tech/proxy";

    public static Activity activity = null;

    Button nextBtn;
    Button creditsBtn;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        activity = this;
        setContentView(R.layout.activity_bitmovin_player);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
        init(getIntent());
        loadSource();
    }

    private void loadSource() {
        SourceConfig sourceConfig = null;
        if (dashUrl != null && !dashUrl.isEmpty()) {
            sourceConfig = new SourceConfig(dashUrl, SourceType.Dash);
        } else if (hlsUrl != null && !hlsUrl.isEmpty()) {
            sourceConfig = new SourceConfig(hlsUrl, SourceType.Hls);
        }

        if (sourceConfig != null) {
            if (posterUrl != null) {
                sourceConfig.setPosterImage(posterUrl, false);
            }
            if (drmToken != null) {
                WidevineConfig drmConfig = new WidevineConfig(WIDEVINE_LICENSE_URL);
                Map<String, String> headers = new HashMap<String, String>();
                headers.put("x-vudrm-token", drmToken);
                drmConfig.setHttpHeaders(headers);
                sourceConfig.setDrmConfig(drmConfig);
            }
            if ( watchedSeconds > 0 ) {
                SourceOptions options = new SourceOptions();
                options.setStartOffset(watchedSeconds);
                sourceConfig.setOptions(options);
            }
            Source source = Source.create(sourceConfig);
            playerView = this.findViewById(R.id.playerView);
            player = playerView.getPlayer();
            addTrackListener();

            player.on(PlayerEvent.Ready.class, (event) -> player.play());
            player.load(source);
            player.on(PlayerEvent.PlaybackFinished.class, (event) -> player.unload());

            nextBtn = (Button) findViewById(R.id.nextButton);
            creditsBtn = (Button) findViewById(R.id.creditsButton);
            nextBtn.setVisibility(View.GONE);
            creditsBtn.setVisibility(View.GONE);
            ReactContext context = ((MainApplication) getApplication()).getReactNativeHost().getReactInstanceManager().getCurrentReactContext();
            nextBtn.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    context.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit("nextBtn", player.getCurrentTime());
                }
            });
            creditsBtn.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    context.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit("creditsBtn", player.getCurrentTime());
                    creditsBtn.setVisibility(View.GONE);
                    nextBtn.setVisibility(View.GONE);
                }
            });

        }
    }

    private void setDimensions(View view, int width, int height){
        android.view.ViewGroup.LayoutParams params = view.getLayoutParams();
        params.width = width;
        params.height = height;
        view.setLayoutParams(params);
    }

    @Override
    public void onWindowFocusChanged(boolean hasFocus) {
        super.onWindowFocusChanged(hasFocus);
        Log.e("ReactNative",""+playerView.getWidth());
        Log.e("ReactNative",""+playerView.getHeight());
    }

    @Override
    protected void onNewIntent(Intent intent) {
        Log.d("ReactNative", "onNewINtent");
        super.onNewIntent(intent);

        init(intent);
        loadSource();
    }
        
    private void init(Intent intent) {
        dashUrl = intent.getStringExtra(DASH_URL);
        hlsUrl = intent.getStringExtra(HLS_URL);
        posterUrl = intent.getStringExtra(POSTER);
        drmToken = intent.getStringExtra(DRM_TOKEN);
        watchedSeconds = intent.getDoubleExtra(WATCHED_SECONDS, 0);
        durationSeconds = intent.getDoubleExtra(DURATION_SECONDS, 0);
        nextContentStart = intent.getDoubleExtra(NEXT_CONTENT_START, 0);
    }

    private void addTrackListener() {
        ReactContext context = ((MainApplication) getApplication()).getReactNativeHost().getReactInstanceManager().getCurrentReactContext();
        if (context != null) {
            player.on(PlayerEvent.TimeChanged.class,
                    (event) -> {
                        context.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit("timeChanged", event.getTime());
                       
                        if (Math.floor(event.getTime()) > nextContentStart) {
                            Log.e("ReactNative",""+Math.round(event.getTime()));
                            Log.e("ReactNative",""+nextContentStart);
                            Log.d("ReactNative", "here IF"); //gets here no problem
                            nextBtn.setVisibility(View.VISIBLE); //crashes here
                            creditsBtn.setVisibility(View.VISIBLE);
                        }
                       
                    }
            );
            player.on(PlayerEvent.Seeked.class,
                    (event) -> context.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit("timeSeeked", player.getCurrentTime()));
            player.on(PlayerEvent.PlaybackFinished.class,
                    (event) -> context.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit("timeFinished", player.getCurrentTime()));
        }
    }

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

    @Override
    protected void onResume() {
        super.onResume();
        playerView.onResume();
    }

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

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

    @Override
    protected void onDestroy() {
        super.onDestroy();
        ReactContext context = ((MainApplication) getApplication()).getReactNativeHost().getReactInstanceManager().getCurrentReactContext();
        if (context != null) {
            context.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit("timeExited", player.getCurrentTime());
        }
        playerView.onDestroy();
    }

    public static void close() {
        PlayerActivity.activity.finish();
    }

}

activity_bitmovin_player.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <com.bitmovin.player.PlayerView
        android:id="@+id/playerView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentStart="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true">
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <Button
                android:id="@+id/nextButton"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentEnd="true"
                android:layout_alignParentBottom="true"
                android:layout_marginEnd="34dp"
                android:layout_marginBottom="54dp" />

            <Button
                android:id="@+id/creditsButton"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentEnd="true"
                android:layout_alignParentBottom="true"
                android:layout_marginEnd="167dp"
                android:layout_marginBottom="54dp"
                android:text="Watch credits" />
        </RelativeLayout>
    </com.bitmovin.player.PlayerView>

</RelativeLayout>

Thanks in advance,

EDIT: Adding stack trace:

05-01 15:49:31.352  6870  7040 E ReactNative: 86
05-01 15:49:31.352  6870  7040 E ReactNative: 85.0
05-01 15:49:31.587  6870  7040 E ReactNative: 86
05-01 15:49:31.587  6870  7040 E ReactNative: 85.0
05-01 15:49:31.587  6870  7040 D ReactNative: here if // this seems to be where the code crashes
05-01 15:49:31.593  6870  6870 D AndroidRuntime: Shutting down VM
05-01 15:49:31.603  6870  6870 E AndroidRuntime: FATAL EXCEPTION: main
05-01 15:49:31.603  6870  6870 E AndroidRuntime: Process: com.myappapp, PID: 6870
05-01 15:49:31.603  6870  6870 E AndroidRuntime: android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
05-01 15:49:31.603  6870  6870 E AndroidRuntime:    at android.view.ViewRootImpl.checkThread(ViewRootImpl.java:9316)
05-01 15:49:31.603  6870  6870 E AndroidRuntime:    at android.view.ViewRootImpl.requestLayout(ViewRootImpl.java:1772)
05-01 15:49:31.603  6870  6870 E AndroidRuntime:    at android.view.View.requestLayout(View.java:25697)
05-01 15:49:31.603  6870  6870 E AndroidRuntime:    at android.view.View.requestLayout(View.java:25697)
05-01 15:49:31.603  6870  6870 E AndroidRuntime:    at android.view.View.requestLayout(View.java:25697)
05-01 15:49:31.603  6870  6870 E AndroidRuntime:    at android.view.View.requestLayout(View.java:25697)
05-01 15:49:31.603  6870  6870 E AndroidRuntime:    at android.view.View.requestLayout(View.java:25697)
05-01 15:49:31.603  6870  6870 E AndroidRuntime:    at android.view.View.requestLayout(View.java:25697)
05-01 15:49:31.603  6870  6870 E AndroidRuntime:    at android.widget.RelativeLayout.requestLayout(RelativeLayout.java:380)
05-01 15:49:31.603  6870  6870 E AndroidRuntime:    at android.view.View.requestLayout(View.java:25697)
05-01 15:49:31.603  6870  6870 E AndroidRuntime:    at android.view.View.requestLayout(View.java:25697)
05-01 15:49:31.603  6870  6870 E AndroidRuntime:    at android.widget.RelativeLayout.requestLayout(RelativeLayout.java:380)
05-01 15:49:31.603  6870  6870 E AndroidRuntime:    at android.view.View.requestLayout(View.java:25697)
05-01 15:49:31.603  6870  6870 E AndroidRuntime:    at android.view.View.setFlags(View.java:16377)
05-01 15:49:31.603  6870  6870 E AndroidRuntime:    at android.view.View.setVisibility(View.java:11896)
05-01 15:49:31.603  6870  6870 E AndroidRuntime:    at com.myappapp.PlayerActivity.lambda$addTrackListener$2$PlayerActivity(PlayerActivity.java:181)
05-01 15:49:31.603  6870  6870 E AndroidRuntime:    at com.myappapp.-$$Lambda$PlayerActivity$4drhB4sZ6Yh1cjccm1TfDL1Tp1Y.onEvent(Unknown Source:6)
05-01 15:49:31.603  6870  6870 E AndroidRuntime:    at com.bitmovin.player.api.event.EventEmitter$DefaultImpls$d.a(SourceFile:1)
05-01 15:49:31.603  6870  6870 E AndroidRuntime:    at com.bitmovin.player.api.event.EventEmitter$DefaultImpls$d.invoke(SourceFile:1)
05-01 15:49:31.603  6870  6870 E AndroidRuntime:    at com.bitmovin.player.event.b.b(SourceFile:206)
05-01 15:49:31.603  6870  6870 E AndroidRuntime:    at com.bitmovin.player.event.d.a(SourceFile:1)
05-01 15:49:31.603  6870  6870 E AndroidRuntime:    at com.bitmovin.player.n.s0.d$a.run(SourceFile:8)
05-01 15:49:31.603  6870  6870 E AndroidRuntime:    at java.util.TimerThread.mainLoop(Timer.java:562)
05-01 15:49:31.603  6870  6870 E AndroidRuntime:    at java.util.TimerThread.run(Timer.java:512)
05-01 15:49:31.624   569  7154 I DropBoxManagerService: add tag=data_app_crash isTagEnabled=true flags=0x2
05-01 15:49:31.627   569  2465 W ActivityTaskManager:   Force finishing activity com.myappapp/.PlayerActivity
05-01 15:49:31.636   339   375 D goldfish-address-space: claimShared: Ask to claim region [0x1fb110000 0x1fb73c000]
05-01 15:49:31.650   322  7155 D resolv  : GetAddrInfoHandler::run: {100 100 100 983140 10146 0}
05-01 15:49:31.650   322  7155 D resolv  : resolv_getaddrinfo: explore_fqdn(): ai_family=0 ai_socktype=1 ai_protocol=6
05-01 15:49:31.650   322  7155 D resolv  : android_getaddrinfofornetcontext: explore_numeric: ai_family=10 ai_socktype=1 ai_protocol=6
05-01 15:49:31.650   322  7155 D resolv  : explore_numeric_scope
05-01 15:49:31.650   322  7155 D resolv  : android_getaddrinfofornetcontext: explore_numeric: ai_family=2 ai_socktype=1 ai_protocol=6
05-01 15:49:31.650   322  7155 D resolv  : explore_numeric_scope
05-01 15:49:31.650   322  7155 I ResolverController: No valid NAT64 prefix (100, <unspecified>/0)
05-01 15:49:31.743   569   618 W BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.DROPBOX_ENTRY_ADDED flg=0x10 (has extras) } to com.google.android.gms/.stats.service.DropBoxEntryAddedReceiver
05-01 15:49:31.744   569   618 W BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.DROPBOX_ENTRY_ADDED flg=0x10 (has extras) } to com.google.android.gms/.chimera.GmsIntentOperationService$PersistentTrustedReceiver
05-01 15:49:31.775  6870  7121 D CCodecBuffers: [c2.goldfish.h264.decoder#432:1D-Input.Impl[N]] codec released a buffer owned by client (index 0)
05-01 15:49:31.780  6870  7121 D CCodecBuffers: [c2.goldfish.h264.decoder#432:1D-Input.Impl[N]] codec released a buffer owned by client (index 1)
05-01 15:49:31.807   569   608 D CompatibilityChangeReporter: Compat change id reported: 171228096; UID 1000; state: ENABLED
05-01 15:49:31.822   569   608 D CompatibilityChangeReporter: Compat change id reported: 168419799; UID 1000; state: DISABLED
05-01 15:49:31.843   569   611 D CompatibilityChangeReporter: Compat change id reported: 158002302; UID 1000; state: ENABLED
05-01 15:49:31.843   339   375 D goldfish-address-space: claimShared: Ask to claim region [0x1f8000000 0x1f8634000]
05-01 15:49:31.844   339   375 D goldfish-address-space: claimShared: Ask to claim region [0x1f8634000 0x1f8c68000]
05-01 15:49:31.845   339   375 D goldfish-address-space: claimShared: Ask to claim region [0x1f8c68000 0x1f929c000]
05-01 15:49:32.169   569   610 W ActivityTaskManager: Activity top resumed state loss timeout for ActivityRecord{bb0b6da u0 com.myappapp/.PlayerActivity t14 f}}
05-01 15:49:32.172   569   610 W ActivityTaskManager: Activity pause timeout for ActivityRecord{bb0b6da u0 com.myappapp/.PlayerActivity t14 f}}
05-01 15:49:32.956  6870  7117 D BufferPoolAccessor2.0: bufferpool2 0xb400007927a9b758 : 4(32768 size) total buffers - 4(32768 size) used buffers - 1/6 (recycle/alloc) - 5/885 (fetch/transfer)
05-01 15:49:32.958  6870  7121 D CCodecBuffers: [c2.android.aac.decoder#316:1D-Input.Impl[N]] codec released a buffer owned by client (index 0)
05-01 15:49:33.287  6870  7121 D CCodecBuffers: [c2.android.aac.decoder#316:1D-Input.Impl[N]] codec released a buffer owned by client (index 0)
05-01 15:49:33.545   428  7122 D BufferPoolAccessor2.0: bufferpool2 0xb400007421629e18 : 5(20480 size) total buffers - 1(4096 size) used buffers - 898/903 (recycle/alloc) - 9/902 (fetch/transfer)
05-01 15:49:33.655   322  7163 D resolv  : GetAddrInfoHandler::run: {100 100 100 983140 10146 0}
05-01 15:49:33.656   322  7163 D resolv  : resolv_getaddrinfo: explore_fqdn(): ai_family=0 ai_socktype=1 ai_protocol=6
05-01 15:49:33.656   322  7163 D resolv  : android_getaddrinfofornetcontext: explore_numeric: ai_family=10 ai_socktype=1 ai_protocol=6
05-01 15:49:33.656   322  7163 D resolv  : explore_numeric_scope
05-01 15:49:33.656   322  7163 D resolv  : android_getaddrinfofornetcontext: explore_numeric: ai_family=2 ai_socktype=1 ai_protocol=6
05-01 15:49:33.656   322  7163 D resolv  : explore_numeric_scope
05-01 15:49:33.656   322  7163 I ResolverController: No valid NAT64 prefix (100, <unspecified>/0)
05-01 15:49:33.774  6870  7123 D BufferPoolAccessor2.0: bufferpool2 0xb400007927a7b5f8 : 4(8388608 size) total buffers - 4(8388608 size) used buffers - 0/4 (recycle/alloc) - 4/537 (fetch/transfer)
05-01 15:49:35.662   322  7164 D resolv  : GetAddrInfoHandler::run: {100 100 100 983140 10146 0}
05-01 15:49:35.662   322  7164 D resolv  : resolv_getaddrinfo: explore_fqdn(): ai_family=0 ai_socktype=1 ai_protocol=6
05-01 15:49:35.663   322  7164 D resolv  : android_getaddrinfofornetcontext: explore_numeric: ai_family=10 ai_socktype=1 ai_protocol=6
05-01 15:49:35.663   322  7164 D resolv  : explore_numeric_scope
05-01 15:49:35.663   322  7164 D resolv  : android_getaddrinfofornetcontext: explore_numeric: ai_family=2 ai_socktype=1 ai_protocol=6
05-01 15:49:35.663   322  7164 D resolv  : explore_numeric_scope
05-01 15:49:35.663   322  7164 I ResolverController: No valid NAT64 prefix (100, <unspecified>/0)
05-01 15:49:36.717   569   682 W InputDispatcher: Window d44ceaf com.myappapp/com.myappapp.PlayerActivity (server) is unresponsive: d44ceaf com.myappapp/com.myappapp.PlayerActivity (server) is not responding. Waited 5004ms for FocusEvent(hasFocus=false)
05-01 15:49:36.717   569   682 W InputDispatcher: Canceling events for d44ceaf com.myappapp/com.myappapp.PlayerActivity (server) because it is unresponsive
05-01 15:49:36.723   569   682 I WindowManager: ANR in com.myappapp/com.myappapp.PlayerActivity. Reason:d44ceaf com.myappapp/com.myappapp.PlayerActivity (server) is not responding. Waited 5004ms for FocusEvent(hasFocus=false)
05-01 15:49:36.820   569  7167 I ActivityManager: Crashing app skipping ANR: com.android.server.am.ProcessErrorStateRecord@95dcf9b Input dispatching timed out (d44ceaf com.myappapp/com.myappapp.PlayerActivity (server) is not responding. Waited 5004ms for FocusEvent(hasFocus=false))
05-01 15:49:36.820   569  7167 D ActivityManager: Completed ANR of com.myappapp in 22ms, latency 0ms
05-01 15:49:37.189   569   610 I ActivityTaskManager: Config changes=20000480 {1.0 310mcc260mnc [en_US] ldltr sw392dp w392dp h778dp 440dpi nrml long port finger qwerty/v/v dpad/v winConfig={ mBounds=Rect(0, 0 - 1080, 2340) mAppBounds=Rect(0, 0 - 1080, 2208) mMaxBounds=Rect(0, 0 - 1080, 2340) mWindowingMode=fullscreen mDisplayWindowingMode=fullscreen mActivityType=undefined mAlwaysOnTop=undefined mRotation=ROTATION_0} s.68 fontWeightAdjustment=0}
05-01 15:49:37.217   569   610 W ActivityTaskManager: Current config: {1.0 310mcc260mnc [en_US] ldltr sw392dp w802dp h368dp 440dpi nrml long land finger qwerty/v/v dpad/v winConfig={ mBounds=Rect(0, 0 - 2340, 1080) mAppBounds=Rect(0, 0 - 2208, 1080) mMaxBounds=Rect(0, 0 - 2340, 1080) mWindowingMode=fullscreen mDisplayWindowingMode=fullscreen mActivityType=undefined mAlwaysOnTop=undefined mRotation=ROTATION_90} s.68 fontWeightAdjustment=0} unchanged for IME proc com.google.android.inputmethod.latin
05-01 15:49:37.221   569   610 I WindowManager: Override config changes=20000480 {1.0 310mcc260mnc [en_US] ldltr sw392dp w392dp h778dp 440dpi nrml long port finger qwerty/v/v dpad/v winConfig={ mBounds=Rect(0, 0 - 1080, 2340) mAppBounds=Rect(0, 0 - 1080, 2208) mMaxBounds=Rect(0, 0 - 1080, 2340) mWindowingMode=fullscreen mDisplayWindowingMode=fullscreen mActivityType=undefined mAlwaysOnTop=undefined mRotation=ROTATION_0} s.68 fontWeightAdjustment=0} for displayId=0
05-01 15:49:37.231   569   610 V ActivityTaskManager: Sending to IME proc com.google.android.inputmethod.latin new config {1.0 310mcc260mnc [en_US] ldltr sw392dp w392dp h778dp 440dpi nrml long port finger qwerty/v/v dpad/v winConfig={ mBounds=Rect(0, 0 - 1080, 2340) mAppBounds=Rect(0, 0 - 1080, 2208) mMaxBounds=Rect(0, 0 - 1080, 2340) mWindowingMode=fullscreen mDisplayWindowingMode=fullscreen mActivityType=undefined mAlwaysOnTop=undefined mRotation=ROTATION_0} s.68 fontWeightAdjustment=0}
05-01 15:49:37.270   569   610 I InputManager-JNI: Viewport [0] to add: local:4619827259835644672, isActive: true
05-01 15:49:37.274   569   683 I InputReader: Reconfiguring input devices, changes=DISPLAY_INFO | 
05-01 15:49:37.274   569   683 I InputReader: Touch device 'virtio_input_multi_touch_10' could not query the properties of its associated display.  The device will be inoperable until the display size becomes available.
05-01 15:49:37.274   569   683 I InputReader: Touch device 'virtio_input_multi_touch_6' could not query the properties of its associated display.  The device will be inoperable until the display size becomes available.
05-01 15:49:37.274   569   683 I InputReader: Touch device 'virtio_input_multi_touch_11' could not query the properties of its associated display.  The device will be inoperable until the display size becomes available.
05-01 15:49:37.274   569   683 I InputReader: Touch device 'virtio_input_multi_touch_4' could not query the properties of its associated display.  The device will be inoperable until the display size becomes available.
05-01 15:49:37.274   569   683 I InputReader: Device reconfigured: id=8, name='virtio_input_multi_touch_1', size 1080x2340, orientation 0, mode 1, display id 0
05-01 15:49:37.274   569   683 I InputReader: Touch device 'virtio_input_multi_touch_7' could not query the properties of its associated display.  The device will be inoperable until the display size becomes available.
05-01 15:49:37.274   569   683 I InputReader: Touch device 'virtio_input_multi_touch_2' could not query the properties of its associated display.  The device will be inoperable until the display size becomes available.
05-01 15:49:37.274   569   683 I InputReader: Touch device 'virtio_input_multi_touch_9' could not query the properties of its associated display.  The device will be inoperable until the display size becomes available.
05-01 15:49:37.274   569   683 I InputReader: Touch device 'virtio_input_multi_touch_5' could not query the properties of its associated display.  The device will be inoperable until the display size becomes available.
05-01 15:49:37.274   569   683 I InputReader: Touch device 'virtio_input_multi_touch_3' could not query the properties of its associated display.  The device will be inoperable until the display size becomes available.
05-01 15:49:37.274   569   683 I InputReader: Touch device 'virtio_input_multi_touch_8' could not query the properties of its associated display.  The device will be inoperable until the display size becomes available.
05-01 15:49:37.279   825   825 D StatusBar: disable<e i a s b h r c s > disable2<q i n >
05-01 15:49:37.290  1440  1440 W GoogleInputMethodService: GoogleInputMethodService.onConfigurationChanged():1661 onConfigurationChanged() : NewConfig = {1.0 310mcc260mnc [en_US] ldltr sw392dp w392dp h778dp 440dpi nrml long port finger qwerty/v/v dpad/v winConfig={ mBounds=Rect(0, 0 - 1080, 2340) mAppBounds=Rect(0, 0 - 1080, 2208) mMaxBounds=Rect(0, 0 - 1080, 2340) mWindowingMode=fullscreen mDisplayWindowingMode=fullscreen mActivityType=undefined mAlwaysOnTop=undefined mRotation=ROTATION_0} s.104 fontWeightAdjustment=0}
05-01 15:49:37.303  1440  1440 I NormalModeController: NormalModeController.getKeyboardBodyViewHolderPaddingBottom():109 currentPrimeKeyboardType:SOFT systemPaddingBottom:-1
05-01 15:49:37.307   339   375 D goldfish-address-space: claimShared: Ask to claim region [0x1f7664000 0x1f79ac000]
05-01 15:49:37.307  1440  1440 I AbstractOpenableExtension: AbstractOpenableExtension.maybeDestroyExistingKeyboardGroupManager():514 Destroy existing keyboard group manager in fau
05-01 15:49:37.308  1440  1440 I AbstractOpenableExtension: AbstractOpenableExtension.createKeyboardGroupManagerListenableFuture():123 Create keyboard group manager listenable future in fau
05-01 15:49:37.312  1107  1379 D TelephonyProvider: subIdString = 1 subId = 1
05-01 15:49:37.313  1107  1379 D TelephonyProvider: subIdString = 1 subId = 1
05-01 15:49:37.314  1440  1440 I AbstractOpenableExtension: AbstractOpenableExtension.maybeDestroyExistingKeyboardGroupManager():514 Destroy existing keyboard group manager in eyj
05-01 15:49:37.314  1440  1440 I AbstractOpenableExtension: AbstractOpenableExtension.createKeyboardGroupManagerListenableFuture():123 Create keyboard group manager listenable future in eyj
05-01 15:49:37.314  1440  1440 I AbstractOpenableExtension: AbstractOpenableExtension.maybeDestroyExistingKeyboardGroupManager():514 Destroy existing keyboard group manager in fci
05-01 15:49:37.314  1440  1440 I AbstractOpenableExtension: AbstractOpenableExtension.createKeyboardGroupManagerListenableFuture():123 Create keyboard group manager listenable future in fci
05-01 15:49:37.318  1440  7133 I KeyboardGroupDefParser: KeyboardGroupDefParser.parseKeyboardGroupDef():89 parseKeyboardGroupDef() 2132148494 -> 0_resource_name_obfuscated : WaitTime = 0 ms : RunTime = 3 ms
05-01 15:49:37.319  1440  7135 I KeyboardGroupDefParser: KeyboardGroupDefParser.parseKeyboardGroupDef():89 parseKeyboardGroupDef() 2132148499 -> 0_resource_name_obfuscated : WaitTime = 1 ms : RunTime = 3 ms
05-01 15:49:37.322  1440  7169 I KeyboardGroupDefParser: KeyboardGroupDefParser.parseKeyboardGroupDef():89 parseKeyboardGroupDef() 2132148495 -> 0_resource_name_obfuscated : WaitTime = 6 ms : RunTime = 3 ms
05-01 15:49:37.322  1440  1440 I NormalModeController: NormalModeController.getKeyboardBodyViewHolderPaddingBottom():109 currentPrimeKeyboardType:SOFT systemPaddingBottom:-1
05-01 15:49:37.336  1440  1440 I GoogleInputMethodService: GoogleInputMethodService.initializeKeyboardTheme():1399 Apply keyboard theme: theme_border_bottom4dp_keyboard4dp_stylesheet_googleblue_materiallight_builtin_google_blue_light.binarypb_port
05-01 15:49:37.338   339   375 D goldfish-address-space: claimShared: Ask to claim region [0x1f6694000 0x1f69dc000]

  • What is the exception you are getting? "_it crashes_" is not useful. – takendarkk Apr 30 '22 at 21:39
  • ... is `nextBtn` null? – Tyler V Apr 30 '22 at 22:01
  • It's very difficult to debug a crash without a stack trace. See [Unfortunately MyApp has stopped. How can I solve this?](/q/23353173) for Android-specific advice, and [What is a stack trace, and how can I use it to debug my application errors?](/q/3988788) for advice on what to do once you have the stack trace. If you still need help, edit your question to include the **complete stack trace**, as well as **which line of your code** the stack trace points to. – Ryan M May 01 '22 at 06:47

1 Answers1

0

There is a race in your code of whether a PlayerEvent.TimeChanged event will fire before you initialize your buttons.

Move the below lines to somewhere above the call to addTrackListener() in loadSource() to guarantee they are already initialized by the time you register the listener.

creditsBtn = (Button) findViewById(R.id.creditsButton);
nextBtn = (Button) findViewById(R.id.nextButton);

The additional error in the question update also pointed to view updates being posted from a background thread. To run these on the main thread, use a Handler:

new Handler(Looper.getMainLooper()).post(
  () -> {
    nextBtn.setVisibility(View.VISIBLE);
    creditsBtn.setVisibility(View.VISIBLE);
  });
Dan Harms
  • 4,725
  • 2
  • 18
  • 28
  • Thanks for your answer, unfortunately it didn't solve the issue – shurething May 01 '22 at 16:34
  • With your update, you need to wrap your updates to views to run on the main thread. `new Handler(Looper.getMainLooper).post()` will do that for you. – Dan Harms May 02 '22 at 05:56
  • Thanks!! That worked new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { nextBtn.setVisibility(View.VISIBLE); creditsBtn.setVisibility(View.VISIBLE); } }); – shurething May 02 '22 at 12:58