简体   繁体   中英

I'm trying to implement a new activity after a user logs into his/her account, but the app keeps crashing after sign in is complete

I am trying to implement a new activity after a user logs into his account, but the app keeps crashing after sign in is completes. I am also trying to get this new activity to open the camera in order to scan a picture.

 // Methos to handleClick Event of Sign In Button
public void signIn(View V)
   {
        final Dialog dialog = new Dialog(HomeActivity.this);
        dialog.setContentView(R.layout.login);
        dialog.setTitle("Login");

        // get the Refferences of views
        final  EditText editTextUserName=(EditText)dialog.findViewById(R.id.editTextUserNameToLogin);
        final  EditText editTextPassword=(EditText)dialog.findViewById(R.id.editTextPasswordToLogin);

        Button btnSignIn=(Button)dialog.findViewById(R.id.buttonSignIn);

        // Set On ClickListener
        btnSignIn.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                // get The User name and Password
                String userName=editTextUserName.getText().toString();
                String password=editTextPassword.getText().toString();

                // fetch the Password form database for respective user name
                String storedPassword=loginDataBaseAdapter.getSinlgeEntry(userName);

                // check if the Stored password matches with  Password entered by user
                if(password.equals(storedPassword))
                {
                    startActivity(new Intent("com.xpro.salccregistry.SCANS"));
                }
                else
                {
                    Toast.makeText(HomeActivity.this, "User Name or Password does not match", Toast.LENGTH_LONG).show();
                }
            }
        });

        dialog.show();
}

@Override
protected void onDestroy() {
    super.onDestroy();
    // Close The Database
    loginDataBaseAdapter.close();
}
}

logcat

  02-08 08:30:35.277: D/dalvikvm(1566): GC_FOR_ALLOC freed 35K, 4% free 2888K/3008K,    paused 44ms, total 48ms
 02-08 08:30:35.307: I/dalvikvm-heap(1566): Grow heap (frag case) to 4.411MB for 1589296-byte allocation
02-08 08:30:35.427: D/dalvikvm(1566): GC_FOR_ALLOC freed 2K, 3% free 4437K/4564K, paused 121ms, total 121ms
02-08 08:30:36.067: D/gralloc_goldfish(1566): Emulator without GPU emulation detected.
02-08 08:31:42.137: D/dalvikvm(1566): GC_FOR_ALLOC freed 142K, 5% free 4856K/5076K, paused 85ms, total 90ms
02-08 08:31:42.497: D/InputEventConsistencyVerifier(1566): KeyEvent: ACTION_UP but key was not down.
02-08 08:31:42.497: D/InputEventConsistencyVerifier(1566):   in android.widget.EditText{b3f1d2b8 VFED..CL .F....I. 24,83-432,142 #7f090001 app:id/editTextPasswordToLogin}
02-08 08:31:42.497: D/InputEventConsistencyVerifier(1566):   0: sent at 5829641000000, KeyEvent { action=ACTION_UP, keyCode=KEYCODE_TAB, scanCode=15, metaState=0, flags=0x8, repeatCount=0, eventTime=5829641, downTime=5829573, deviceId=0, source=0x101 }
02-08 08:31:47.237: D/AndroidRuntime(1566): Shutting down VM
02-08 08:31:47.237: W/dalvikvm(1566): threadid=1: thread exiting with uncaught exception (group=0xb3a5cb90)
02-08 08:31:47.267: E/AndroidRuntime(1566): FATAL EXCEPTION: main
02-08 08:31:47.267: E/AndroidRuntime(1566): Process: com.xpro.salccregistry, PID: 1566
02-08 08:31:47.267: E/AndroidRuntime(1566): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.xpro.salccregistry.SCANS }
02-08 08:31:47.267: E/AndroidRuntime(1566):     at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1632)
02-08 08:31:47.267: E/AndroidRuntime(1566):     at android.app.Instrumentation.execStartActivity(Instrumentation.java:1424)
02-08 08:31:47.267: E/AndroidRuntime(1566):     at android.app.Activity.startActivityForResult(Activity.java:3423)
02-08 08:31:47.267: E/AndroidRuntime(1566):     at android.app.Activity.startActivityForResult(Activity.java:3384)
02-08 08:31:47.267: E/AndroidRuntime(1566):     at android.app.Activity.startActivity(Activity.java:3626)
02-08 08:31:47.267: E/AndroidRuntime(1566):     at android.app.Activity.startActivity(Activity.java:3594)
02-08 08:31:47.267: E/AndroidRuntime(1566):     at com.xpro.salccregistry.HomeActivity$2.onClick(HomeActivity.java:71)
02-08 08:31:47.267: E/AndroidRuntime(1566):     at android.view.View.performClick(View.java:4424)
02-08 08:31:47.267: E/AndroidRuntime(1566):     at android.view.View$PerformClick.run(View.java:18383)
02-08 08:31:47.267: E/AndroidRuntime(1566):     at android.os.Handler.handleCallback(Handler.java:733)
02-08 08:31:47.267: E/AndroidRuntime(1566):     at android.os.Handler.dispatchMessage(Handler.java:95)
02-08 08:31:47.267: E/AndroidRuntime(1566):     at android.os.Looper.loop(Looper.java:137)
02-08 08:31:47.267: E/AndroidRuntime(1566):     at  android.app.ActivityThread.main(ActivityThread.java:4998)
02-08 08:31:47.267: E/AndroidRuntime(1566):     at java.lang.reflect.Method.invokeNative(Native Method)
02-08 08:31:47.267: E/AndroidRuntime(1566):     at java.lang.reflect.Method.invoke(Method.java:515)
02-08 08:31:47.267: E/AndroidRuntime(1566):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
02-08 08:31:47.267: E/AndroidRuntime(1566):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593)
02-08 08:31:47.267: E/AndroidRuntime(1566):at     dalvik.system.NativeStart.main(Native Method)
02-08 08:31:52.617: I/Process(1566): Sending signal. PID: 1566 SIG: 9

Change this line

startActivity(new Intent("com.xpro.salccregistry.SCANS"));

to

startActivity(new Intent(CurrentAct.this, NextActivity.class));

and check.

PS: Make sure the NextActivity is declared in manifest file as follows:

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name=".FirstActivity"
        android:label="@string/title_activity_main" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activty
        android:name="com.xpro.salccregistry.SCANS"/>
</application>

Hope this helps.

Please regiser your activity :

You didn't register your activity in AndroidMenifest.xml file : 
See this : http://prntscr.com/2qlobi

try this it just work with me

startActivity(new Intent(this,<class you want to start>.class));

example :

startActivity(new Intent(this,ActivityTwo.class));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM