문제

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.

도움이 되었습니까?

해결책

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);
    }
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top