OnResume Activity 抛出错误,源查找失败

发布于 2024-12-27 18:24:34 字数 2620 浏览 1 评论 0原文

所以 super 来自 MingleActivity,它扩展了 Activity。它不断在 ActivityThread.performResumeActivity(IBinder, boolean) 处抛出错误。我的 Try/Catch 只是抛出 Java.lang.NullpointerException 错误,因此并没有真正获得很多帮助。它只是不断要求我编辑源路径。

    package mingle.mix;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.Animation.AnimationListener;

import android.widget.TextView;
import android.widget.Toast;

public class MingleSpalshActivity extends MingleActivity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.spalsh);
        try
        {
        startAnimating();
        }
        catch (Exception e)
        {
            // this is the line of code that sends a real error message to the log
            Log.e("ERROR", "ERROR IN CODE: " + e.toString());

            // this is the line that prints out the location in
            // the code where the error occurred.
            e.printStackTrace();
        }
    }

    private void startAnimating() {
        // Fade in top title
        TextView logo1 = (TextView) findViewById(R.id.title_text);
        Animation fade1 = AnimationUtils.loadAnimation(this, R.anim.fade_in);
        logo1.startAnimation(fade1);



        // Transition to Main Menu when bottom title finishes animating
        fade1.setAnimationListener(new AnimationListener() {

            public void onAnimationEnd(Animation animation) {


                // The animation has ended, transition to the Main Menu screen
                startActivity(new Intent(MingleSpalshActivity.this, MingleGameActivity.class));
                MingleSpalshActivity.this.finish();
                //Toast toast = Toast.makeText(getApplicationContext(), "A TOAST", Toast.LENGTH_SHORT );
                //toast.show();
            }

            public void onAnimationRepeat(Animation animation) {
            }

            public void onAnimationStart(Animation animation) {
            }
        });
} 
    @Override
    protected void onPause() {
        super.onPause();
        // Stop the animation
        TextView logo1 = (TextView) findViewById(R.id.title_text);
        logo1.clearAnimation();

        }


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

        // Start animating at the beginning so we get the full splash screen experience
        startAnimating();
    }

}

So the super comes from MingleActivity, which extends Activity.It keeps throwing an error at ActivityThread.performResumeActivity(IBinder, boolean). My Try/Catch simply throws a Java.lang.Nullpointerexception error, so not really getting a lot of help there. It just keeps asking me to edit the source path.

    package mingle.mix;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.Animation.AnimationListener;

import android.widget.TextView;
import android.widget.Toast;

public class MingleSpalshActivity extends MingleActivity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.spalsh);
        try
        {
        startAnimating();
        }
        catch (Exception e)
        {
            // this is the line of code that sends a real error message to the log
            Log.e("ERROR", "ERROR IN CODE: " + e.toString());

            // this is the line that prints out the location in
            // the code where the error occurred.
            e.printStackTrace();
        }
    }

    private void startAnimating() {
        // Fade in top title
        TextView logo1 = (TextView) findViewById(R.id.title_text);
        Animation fade1 = AnimationUtils.loadAnimation(this, R.anim.fade_in);
        logo1.startAnimation(fade1);



        // Transition to Main Menu when bottom title finishes animating
        fade1.setAnimationListener(new AnimationListener() {

            public void onAnimationEnd(Animation animation) {


                // The animation has ended, transition to the Main Menu screen
                startActivity(new Intent(MingleSpalshActivity.this, MingleGameActivity.class));
                MingleSpalshActivity.this.finish();
                //Toast toast = Toast.makeText(getApplicationContext(), "A TOAST", Toast.LENGTH_SHORT );
                //toast.show();
            }

            public void onAnimationRepeat(Animation animation) {
            }

            public void onAnimationStart(Animation animation) {
            }
        });
} 
    @Override
    protected void onPause() {
        super.onPause();
        // Stop the animation
        TextView logo1 = (TextView) findViewById(R.id.title_text);
        logo1.clearAnimation();

        }


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

        // Start animating at the beginning so we get the full splash screen experience
        startAnimating();
    }

}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

清引 2025-01-03 18:24:34
  1. 我们可以在 MingleActivity 中看到 onResume() 吗?
  2. 当方法不抛出 Exception 时,为什么要将 startAnimating() 的调用包装在 try/catch 块中?
  1. Can we see the onResume() in MingleActivity?
  2. Why are you wrapping the call to startAnimating() in a try/catch block when the method throws no Exception?
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文