-1

please advise that how can I pass this intent from menu screen to Next screen

public class MainActivity extends Activity {

Button cant, iu, let, s, handle;
TextView menu;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    cant = (Button) findViewById(R.id.bCANT);
    iu = (Button) findViewById(R.id.bIU);
    let = (Button) findViewById(R.id.bLET);
    s = (Button) findViewById(R.id.bS);
    handle = (Button) findViewById(R.id.handle);
    menu = (TextView) findViewById(R.id.tvM);
}

public void importUser(View v) {
    Intent i = new Intent();
    i.setClassName("com.dklstudio.inout", "com.dklstudio.inout.ImportUserPage");
    startActivity(i);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

}

when I click Button"iu", the applicate it self crash and shows "Unfornately InOut has stopped"

Any help will be appreciated

logcat as follow

         03-19 13:59:45.683: D/libEGL(16356): loaded /vendor/lib/egl/libEGL_adreno.so
 03-19 13:59:45.683: D/libEGL(16356): loaded /vendor/lib/egl/libGLESv1_CM_adreno.so
 03-19 13:59:45.693: D/libEGL(16356): loaded /vendor/lib/egl/libGLESv2_adreno.so
 03-19 13:59:45.693: I/Adreno-EGL(16356): <qeglDrvAPI_eglInitialize:316>: EGL 1.4 QUALCOMM build:  (CL4169980)
 03-19 13:59:45.693: I/Adreno-EGL(16356): OpenGL ES Shader Compiler Version: 17.01.10.SPL
 03-19 13:59:45.693: I/Adreno-EGL(16356): Build Date: 12/01/13 Sun
 03-19 13:59:45.693: I/Adreno-EGL(16356): Local Branch: 
 03-19 13:59:45.693: I/Adreno-EGL(16356): Remote Branch: 
 03-19 13:59:45.693: I/Adreno-EGL(16356): Local Patches: 
 03-19 13:59:45.693: I/Adreno-EGL(16356): Reconstruct Branch: 
 03-19 13:59:45.723: D/OpenGLRenderer(16356): Enabling debug mode 0
 03-19 13:59:46.724: D/AndroidRuntime(16356): Shutting down VM
 03-19 13:59:46.724: W/dalvikvm(16356): threadid=1: thread exiting with uncaught exception (group=0x415508b0)
 03-19 13:59:46.724: E/AndroidRuntime(16356): FATAL EXCEPTION: main
 03-19 13:59:46.724: E/AndroidRuntime(16356): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.dklstudio.inout/com.dklstudio.inout.ImportUserPage}: java.lang.NullPointerException
 03-19 13:59:46.724: E/AndroidRuntime(16356):   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2192)
 03-19 13:59:46.724: E/AndroidRuntime(16356):   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2316)
 03-19 13:59:46.724: E/AndroidRuntime(16356):   at android.app.ActivityThread.access$600(ActivityThread.java:150)
 03-19 13:59:46.724: E/AndroidRuntime(16356):   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1298)
 03-19 13:59:46.724: E/AndroidRuntime(16356):   at android.os.Handler.dispatchMessage(Handler.java:99)
 03-19 13:59:46.724: E/AndroidRuntime(16356):   at android.os.Looper.loop(Looper.java:213)
 03-19 13:59:46.724: E/AndroidRuntime(16356):   at android.app.ActivityThread.main(ActivityThread.java:5225)
 03-19 13:59:46.724: E/AndroidRuntime(16356):   at java.lang.reflect.Method.invokeNative(Native Method)
 03-19 13:59:46.724: E/AndroidRuntime(16356):   at java.lang.reflect.Method.invoke(Method.java:525)
 03-19 13:59:46.724: E/AndroidRuntime(16356):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:741)
 03-19 13:59:46.724: E/AndroidRuntime(16356):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
 03-19 13:59:46.724: E/AndroidRuntime(16356):   at dalvik.system.NativeStart.main(Native Method)
 03-19 13:59:46.724: E/AndroidRuntime(16356): Caused by: java.lang.NullPointerException
 03-19 13:59:46.724: E/AndroidRuntime(16356):   at android.app.Activity.findViewById(Activity.java:1853)
 03-19 13:59:46.724: E/AndroidRuntime(16356):   at com.dklstudio.inout.ImportUserPage.<init>(ImportUserPage.java:15)
 03-19 13:59:46.724: E/AndroidRuntime(16356):   at java.lang.Class.newInstanceImpl(Native Method)
 03-19 13:59:46.724: E/AndroidRuntime(16356):   at java.lang.Class.newInstance(Class.java:1130)
 03-19 13:59:46.724: E/AndroidRuntime(16356):   at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
 03-19 13:59:46.724: E/AndroidRuntime(16356):   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2183)
 03-19 13:59:46.724: E/AndroidRuntime(16356):   ... 11 more

manifest as follow

 <application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.dklstudio.inout.MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
     //Add new Activity class name here
    <activity
        android:name="com.dklstudio.inout.ImportUserPage"
        android:label="@string/title_activity_import_user_page" >
    </activity>
</application>
  • 1
    You have a null pointer exception look at your logcat: Caused by: java.lang.NullPointerException at android.app.Activity.findViewById(Activity.java:1853) at com.dklstudio.inout.ImportUserPage.(ImportUserPage.java:15) – Tobiel Mar 19 '14 at 15:19
  • which line is the 15th line of `ImportUserPage` class? – Hamid Shatu Mar 19 '14 at 15:23

2 Answers2

1

try the following,

public void importUser(View v) {
    Intent i = new Intent();
    i.setClassName(this, ImportUserPage.class);
    startActivity(i);
}
Phillip C
  • 61
  • 2
0

You're calling findViewById() in your ImportUserPage() constructor. You should do that in the onCreate() method of your Activity (just like in MainActivity).

Nachi
  • 4,218
  • 2
  • 37
  • 58
  • You were trying to access a variable that was null, more info here: http://stackoverflow.com/a/218510/1025599 – Nachi Mar 19 '14 at 15:39