gpt4 book ai didi

android - 首次启动时卡在启动画面,但如果我们不终止应用程序并再次启动应用程序,则应用程序可以正常工作。 ( react 原生)Android

转载 作者:行者123 更新时间:2023-12-04 04:09:51 26 4
gpt4 key购买 nike

我已将代码从 0.53.3 升级到 react-native 0.59.9。我想我可能错过了一些基本步骤并遇到了启动问题。请检查并帮助我使应用程序正常工作。

React Native Navigation 版本:4.0.6

React Native 版本:0.59.9

平台(iOS、Android 或两者?):Android。

设备信息:设备和模拟器两者(所有 Android 版本)。

MainActivity.java

public class MainActivity extends NavigationActivity {
static Backbonebits b;
public void addDefaultSplashLayout() {
LinearLayout splash = new LinearLayout(this);
Drawable splash_screen_bitmap = ContextCompat.getDrawable(getApplicationContext(),R.drawable.splashscreen);
splash.setBackground(splash_screen_bitmap);

setContentView(splash);
}
@override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
MobileAds.initialize(this, new OnInitializationCompleteListener() {
@override
public void onInitializationComplete(InitializationStatus initializationStatus) {
}
});
b = new Backbonebits(this);
}
}

MainApplication.java
public class MainApplication extends NavigationApplication {

private static CallbackManager mCallbackManager = CallbackManager.Factory.create();

protected static CallbackManager getCallbackManager() {
return mCallbackManager;
}

@Override
protected ReactGateway createReactGateway() {
ReactNativeHost host = new NavigationReactNativeHost(this, isDebug(), createAdditionalReactPackages()) {
@Override
protected String getJSMainModuleName() {
return "index";
}
};
return new ReactGateway(this, isDebug(), host);
}

@Override
public boolean isDebug() {
return BuildConfig.DEBUG;
}

protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new FBSDKPackage(mCallbackManager),
);
}

@Override
public List<ReactPackage> createAdditionalReactPackages() {
return getPackages();
}
}

应用程序.js
import React, { Component } from 'react';
import {
Platform
} from 'react-native';
import { Navigation } from 'react-native-navigation'
import TermsOfUseController from "./app/routes/TermsOfUseController"
import Utility from './app/config/Utility';

const registerScreen = (name, component, styles) => {
component.navigatorStyle = {
...defaultNavigatorStyles,
...styles
};
Navigation.registerComponent(name, () => component)
}

function registerAllScreens() {
registerScreen('MyApp.LoginController', LoginController, {})
}

registerAllScreens();

User.loggedInUser((user) => {
User.addSignOutListner()
var screenName = 'MyApp.LoginController';
if (user) {
if (user.id != 0 && user.id != undefined) {
Utility.isFirstTimeLaunch = true
screenName = 'MyApp.HomeScreenController'; // User Already logged in
}
else {
Utility.isFirstTimeLaunch = true
screenName = 'MyApp.LoginController'; // Not Logged in
}
}
});

Navigation.events().registerAppLaunchedListener(() => {

Navigation.setRoot({
root: {
stack: {
children: [{
component: {
name: screenName,
passProps: { ...Navigation }
}
}],
options: {
topBar: {
visible: false
},
}
}
}
});
});
});

最佳答案

我在用户检查条件下启动了监听器。我把它放在外面解决了。它在 android 中产生了问题,但它在 iOS 上运行。

关于android - 首次启动时卡在启动画面,但如果我们不终止应用程序并再次启动应用程序,则应用程序可以正常工作。 ( react 原生)Android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61917685/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com