Y
Y
yarovoi_ivan2016-05-30 11:31:59
Java
yarovoi_ivan, 2016-05-30 11:31:59

How to deal with this java.lang.NullPointerException when calling VideosActivity?

This is the error that occurs

05-30 13:25:38.584 12963-12963/com.wasdclub.android E/AndroidRuntime: FATAL EXCEPTION: main
                                                                      Process: com.wasdclub.android, PID: 12963
                                                                      java.lang.NullPointerException
                                                                          at android.content.ComponentName.<init>(ComponentName.java:77)
                                                                          at android.content.Intent.<init>(Intent.java:4398)
                                                                          at com.sample.drawer.MainActivity$1.onClick(MainActivity.java:53)
                                                                          at android.view.View.performClick(View.java:4640)
                                                                          at android.view.View$PerformClick.run(View.java:19431)
                                                                          at android.os.Handler.handleCallback(Handler.java:733)
                                                                          at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                          at android.os.Looper.loop(Looper.java:146)
                                                                          at android.app.ActivityThread.main(ActivityThread.java:5598)
                                                                          at java.lang.reflect.Method.invokeNative(Native Method)
                                                                          at java.lang.reflect.Method.invoke(Method.java:515)
                                                                          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
                                                                          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
                                                                          at dalvik.system.NativeStart.main(Native Method)

When I want to execute
Button myButton = (Button) findViewById(R.id.button);
        myButton.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                Intent intent = new Intent(context, VideosActivity.class);
                context.startActivity(intent);
            }
        });

from MainActivity , you
may need some more parts of the code to understand, say) thanks in advance

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
GavriKos, 2016-05-30
@GavriKos

Debugger in hand and go ahead to see what you have == null in line 53. For example, context is null, or something else - line numbers are not visible

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question