0

I'Am Face This Bug How To Fix It

java.lang.RuntimeException: 
      at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2941)
      at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:3088)
      at android.app.servertransaction.LaunchActivityItem.execute (LaunchActivityItem.java:78)
      at android.app.servertransaction.TransactionExecutor.executeCallbacks (TransactionExecutor.java:108)
      at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:68)
      at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1815)
      at android.os.Handler.dispatchMessage (Handler.java:106)
      at android.os.Looper.loop (Looper.java:193)
      at android.app.ActivityThread.main (ActivityThread.java:6846)
      at java.lang.reflect.Method.invoke (Native Method)
      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:504)
      at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:858)
    Caused by: java.lang.NullPointerException: 
      at com.deepthistudio.sinhalabehethapp.Logo_Screen.onCreate (Logo_Screen.java:19)
      at android.app.Activity.performCreate (Activity.java:8606)
      at android.app.Activity.performCreate (Activity.java:8597)
      at android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1274)
      at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2919)
public class Logo_Screen extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.logo_screen_activity);

        Objects.requireNonNull(getSupportActionBar()).hide();


        Thread Thread = new Thread(() -> {

            try
            {
                java.lang.Thread.sleep(2000);

            } catch (Exception e) {
                e.printStackTrace();

            } finally {
                Intent mainIntent = new Intent(Logo_Screen.this,MainActivity.class);
                startActivity(mainIntent);

            }
        });
        Thread.start();
    }



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

        finish();

    }
}
Slaw
  • 37,820
  • 8
  • 53
  • 80
  • 1
    On line `19` of your `Logo_Screen` class, a `NullPointerException` is being thrown. Fix this problem by making whatever is `null` _not_ `null`, or by otherwise properly handling the `null` reference. – Slaw Jun 02 '22 at 19:52
  • By the way, `catch (Exception e) { e.printStackTrace(); }` is an astoundingly bad thing to do. In this case you're pretty much only ever going to get an InterruptedException, but swallowing exceptions like that is going to burn you one day. – David Conrad Jun 02 '22 at 19:57
  • He! Bro I don't Understand This. Can you tell me how to fix it? – Supun Madushanka Jun 03 '22 at 03:35

0 Answers0