我做对了吗?我有一个启动屏幕(只是一个图像),onCreate()我在运行繁重的功能后启动主要活动:
SPLASH_DISPLAY_LENGHT=2500;
new Handler().postDelayed(new Runnable(){
public void run() {
LONG_OPERATING_FUNCTION();
Intent mainIntent = new Intent(this, MainActivity.class);
Splash.this.startActivity(mainIntent);
Splash.this.finish();
}
}, SPLASH_DISPLAY_LENGHT);
Run Code Online (Sandbox Code Playgroud)
我认为我有内存泄漏,我正在尝试找到它。我认为 Splash 还没有真正结束。
我很想知道是否有任何飞溅可以从此页面获取动态工作内容 - https://nreca.csod.com/ux/ats/careersite/4/home?c=nreca#/requisition/182
为了让 splash 接收 URL 片段,您必须使用 SplashRequest。为了让它处理 JS cookie,我不得不使用 lua 脚本。下面是我的环境、脚本和爬虫代码。
该网站似乎分 3 个“步骤”呈现:
如果您对 URL 执行简单的 GET(即在邮递员中),您将只会看到第 1 步的内容。与飞溅我只得到第 2 步的结果(页眉/页脚)。我确实在 response.cookiejar 中看到了 JS cookie
我无法获得要呈现的动态作业内容(第 3 步)。
环境:
scrapy 1.3.3 scrapy-splash 0.72 设置
script = """
function main(splash)
splash:init_cookies(splash.args.cookies)
assert(splash:go{
splash.args.url,
headers=splash.args.headers,
http_method=splash.args.http_method,
body=splash.args.body,
})
assert(splash:wait(15))
local entries = splash:history()
local last_response = entries[#entries].response
return {
url = splash:url(),
headers = last_response.headers,
http_status = last_response.status, …Run Code Online (Sandbox Code Playgroud) 我创建了一个应用程序并添加了启动屏幕。在 Android 模拟器上加载应用程序需要 1 秒。然而,当我在商店中发布该应用程序后,加载需要 4 秒。
对于这样一个简单的应用程序来说,这非常烦人。
我认为这是因为 _loadResourcesAsync 函数加载图片。因此我注释掉了这些行,但没有任何改变。
任何加快我的应用程序启动速度的建议。
在这里你可以找到我的app.js
import React from 'react';
import { Platform, StatusBar, StyleSheet, View } from 'react-native';
import { AppLoading, Asset } from 'expo';
import AppNavigator from './navigation/AppNavigator';
export default class App extends React.Component {
constructor(props) {
super(props);
this.state = {
isLoadingComplete: false,
};
}
render() {
if (!this.state.isLoadingComplete && !this.props.skipLoadingScreen) {
return (
<AppLoading
startAsync={this._loadResourcesAsync}
onError={this._handleLoadingError}
onFinish={this._handleFinishLoading}
/>
);
} else {
return (
<View style={styles.container}>
{Platform.OS === 'ios' && …Run Code Online (Sandbox Code Playgroud) 当我按照那里所说的进行库的设置时: https: //github.com/crazycodeboy/react-native-splash-screen 我发现在 MainActivity.java 中不再有 onCreate 方法。
MainActivity.java RN 0.60
package com.testApp;
import com.facebook.react.ReactActivity;
public class MainActivity extends ReactActivity {
/**
* Returns the name of the main component registered from JavaScript.
* This is used to schedule rendering of the component.
*/
@Override
protected String getMainComponentName() {
return "testApp";
}
}
Run Code Online (Sandbox Code Playgroud)
所以我尝试在 getMainComponentName 方法中进行设置:MainActivity.java
package com.testApp;
import com.facebook.react.ReactActivity;
import org.devio.rn.splashscreen.SplashScreen;
public class MainActivity extends ReactActivity {
/**
* Returns the name of the main component registered from JavaScript. …Run Code Online (Sandbox Code Playgroud) 我最近构建了一个颤振应用程序。我有一种方法可以检查用户是否登录并在确认检查后显示适当的屏幕。如果用户未登录,它将返回登录屏幕,但如果用户已经登录,则应显示主屏幕。但是,如果用户已登录,它将在显示主屏幕之前显示登录屏幕一两秒钟。检查用户是否登录的代码
class CheckAuth extends StatefulWidget {
@override
_CheckAuthState createState() => _CheckAuthState();
}
class _CheckAuthState extends State<CheckAuth> {
bool isAuth = false;
@override
void initState() {
super.initState();
_checkIfLoggedIn();
}
void _checkIfLoggedIn() async {
SharedPreferences localStorage = await SharedPreferences.getInstance();
var token = localStorage.getString('token');
if (token != null) {
setState(() {
isAuth = true;
});
}
}
@override
Widget build(BuildContext context) {
Widget child;
if (isAuth) {
child = HomePage();
} else {
child = Login();
}
return Scaffold(
body: child,
);
} …Run Code Online (Sandbox Code Playgroud) 我试图在包含BottomNavigationView三个片段的应用程序中实现启动屏幕,并且我使用了最著名的方法,例如在不创建新活动或片段的情况下执行此操作的答案,但在直接启动启动屏幕后出现问题,它得到“RuntimeException”和空指针异常”
E/AndroidRuntime: FATAL EXCEPTION: main\n Process: com.mml.foody, PID: 6868\n java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mml.foody/com.mml.foody.ui.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method \'void androidx.appcompat.app.ActionBar.setTitle(java.lang.CharSequence)\' on a null object reference\n at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3449)\n at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601)\n at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)\n at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)\n at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)\n at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)\n at android.os.Handler.dispatchMessage(Handler.java:106)\n at android.os.Looper.loop(Looper.java:223)\n at android.app.ActivityThread.main(ActivityThread.java:7656)\n at java.lang.reflect.Method.invoke(Native Method)\n at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)\n at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)\n Caused by: java.lang.NullPointerException: Attempt to invoke virtual method \'void androidx.appcompat.app.ActionBar.setTitle(java.lang.CharSequence)\' on a null object reference\n at androidx.navigation.ui.ActionBarOnDestinationChangedListener.setTitle(ActionBarOnDestinationChangedListener.java:48)\n at androidx.navigation.ui.AbstractAppBarOnDestinationChangedListener.onDestinationChanged(AbstractAppBarOnDestinationChangedListener.java:103)\n at androidx.navigation.NavController.addOnDestinationChangedListener(NavController.java:233)\n …Run Code Online (Sandbox Code Playgroud) android splash-screen android-theme kotlin android-databinding
我正在使用这里的Splash Screen .我喜欢它有多简单.但问题是,在我点击之前,启动画面不会消失.在IDE中运行时,它可以正常工作.有任何想法吗?我在这里附上代码,但由于某种原因它没有正确插入.
private System.Windows.Forms.Timer timer1;
//private Splash sp=null;
public Form1()
{
InitializeComponent();
Thread th = new Thread(new ThreadStart(DoSplash));
//th.ApartmentState = ApartmentState.STA;
//th.IsBackground=true;
th.Start();
Thread.Sleep(3000);
th.Abort();
Thread.Sleep(1000);
}
private void DoSplash()
{
Splash sp = new Splash();
sp.ShowDialog();
}
private void timer1_Tick(object sender, System.EventArgs e)
{
// sp.Close();
}
Run Code Online (Sandbox Code Playgroud) 我想知道如何Loading Time在用户启动流程,应用程序实例时测量应用程序,以便我可以显示进度条或某些内容,通知用户在加载应用程序时发生了什么或者完成了多少应用程序加载.
我的意思是如果我想显示进度条的当前进度,所以我认为我能够用数字定义当前进程,所以我可以增加控件的Value属性ProgressBar.
提前致谢.
真诚.
编辑:
我发现的解决方案是:
您可以使用System.Diagnostics.Stopwatch来测量时间.调用方法Start在表单构造函数的开头.
显示表单后,通常Application.Idle事件会上升.因此,您可以在此事件的处理程序中调用Stop方法.但是你应该检查一下这个事件确实会上升,例如使用System.Diagnostics.Debug.WriteLine,以及来自sysinternals.com的工具DebugView.
所以我们可以System.Diagnostics.StopWatch像这样使用:
using System;
using System.Diagnostics;
using System.Threading;
class Program
{
static void Main(string[] args)
{
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
Thread.Sleep(10000);
stopWatch.Stop();
// Get the elapsed time as a TimeSpan value.
TimeSpan ts = stopWatch.Elapsed;
// Format and display the TimeSpan value.
string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
ts.Hours, ts.Minutes, ts.Seconds,
ts.Milliseconds / 10);
Console.WriteLine(elapsedTime, "RunTime");
}
}
Run Code Online (Sandbox Code Playgroud)
然后当空闲事件触发时,我将能够找到加载时间并在进度条上显示它,但我认为进度条不会显示加载时间的准确百分比.
大家好我有这个启动画面的布局main.xml,其中包含一个imageview,这里是main.xml文件
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/LinearLayout2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/slide11" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
这是我的splashscreen.class文件
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
try {
new Handler().postDelayed(new Runnable() {
public void run()
Intent intent = new Intent(getApplicationContext(),content_activity.class);
startActivity(intent);
Main.this.finish(); } }, 5000);
} catch(Exception e){}
}
@Override
public void onBackPressed() {
super.onBackPressed();
} }
Run Code Online (Sandbox Code Playgroud)
当我尝试在我的模拟器中运行这一切都工作正常,但当我尝试通过调试模式在设备中运行它我没有得到imageView中指定的图像,但我得到一个指定时间的白色屏幕.任何帮助将非常感激.
//编辑:我仔细检查了res/drawable文件夹,我主要尝试使用png,并且还使用.gif在设备中没有工作.(设备micromax a110)