Pergunta

I'm currently developing an android app that displays a letter for a user to draw and the user then enters the letter as a gesture. I got this activity working perfectly and then wanted to add in user login features. So I followed the tutorial here: http://techblogon.com/android-login-registration-screen-with-sqlite-database-example/

Which successfully added in a login and signup feature. However after a user logs in I want to switch to the main activity of checking the gestures, but instead the app just refreshes to the login screen again. Here's how I'm trying to start the intent:

if(password.equals(storedPassword))
{
    Toast.makeText(HomeActivity.this, "Congrats: Login Successfull", Toast.LENGTH_LONG).show(); 
    Intent intentLetterChecker=new Intent(getApplicationContext(),MainActivity.class);
    startActivity(intentLetterChecker);
}

Here's the applications manifest xml (homeActivity is the login activity and MainActivity is the gesture checker):

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.gmail.Sheridjohn.letterchecker"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="19" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.gmail.Sheridjohn.letterchecker.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>

         <activity
            android:name=".HomeActivity"/>

         <activity
            android:name=".SignUPActivity">
           </activity>
    </application>

</manifest>

Clarification note: I'm not getting any errors, the application simply isn't performing as it's supossed to.

Foi útil?

Solução

You initialized the Intent wrong way,try this. MainActivity is login screen and HomeActivity is where users gets when login is successful.

    if(password.equals(storedPassword))
    {
        Toast.makeText(HomeActivity.this, "Congrats: Login Successfull",          Toast.LENGTH_LONG).show(); 
        Intent intentLetterChecker=new Intent(MainActivity.this,HomeActivity.class);
        startActivity(intentLetterChecker);
    }
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top