2017-10-11 18 views
-3

Ich versuche, eine Datei aus dem internen Speicher durch "checkDirectory" Aufruf zu lesen und dann, wenn die Daten nicht gefunden wird das Aufrufen eines Registers Klassenprogramm für die Registrierung. Problem ist StartActivity (RegisterIntent) nicht abholen.Ich habe eine andere Aktivität von der Hauptaktivität gestartet, aber die Methode funktioniert nicht

public class LoginActivity erweitert AppCompatActivity {

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.loginscreen); 
    // Set up the login form. 
    mPhoneView = (EditText) findViewById(R.id.PhoneNumber); 
    //populateAutoComplete(); 

    mPasswordView = (EditText) findViewById(R.id.Password); 
    Button mEmailSignInButton = (Button) findViewById(R.id.SignIn); 
    mEmailSignInButton.setOnClickListener(new OnClickListener() { 
     @Override 
     public void onClick(View view) { 
      attemptLogin(); 
     } 
    }); 
} 

*/ 
private void attemptLogin() { 

    if (cancel) { 
     focusView.requestFocus(); 
    } else { 
     // Show a progress spinner, and kick off a background task to 
     // perform the user login attempt. 
     // showProgress(true); 
     String messg = UserLoginTask(phone, password); 
     mPhoneView.setError(messg); 
     focusView = mPhoneView; 
     Intent logindetails = new Intent(LoginActivity.this, MechanicScreen.class); 
     logindetails.putExtra("phone_number", phone); 
     startActivity(logindetails); 
    } 
} 

protected boolean login_password_valid(String mphone, String mpassword, int validno) { 
    boolean cancel = false; 
    View focusView = null; 
    String firstLine = null; 
    String secondLine = null; 
    fPath = retValue[2]; 
    String line; 
     try { 
      if (firstLine == null) { 
       try { 
        Intent registerIntent = new Intent(LoginActivity.this, Register.class); 
        startActivity(registerIntent); 
       } catch (Exception e) { 
        e.printStackTrace(); 
       } 

      } 
public String UserLoginTask(String phone, String password) { 
    //CheckDirectoryIntExt dirCheck = new CheckDirectoryIntExt(); 
    retValue = checkDirectory(dName, fName); 
    //retValue = dirCheck.checkDirectory(dName, fName); 
    if (retValue[0] == null) { 
     if (login_password_valid(phone, password, Customer_valid)) { 
      Customer_valid = 1; 
      System.out.println("First In"); 
      startActivity(new Intent(getApplicationContext(), MechanicScreen.class)); 
     } else { 
      return "Invalid Username or Password"; 
     } 
    } else { 
     return "Error in the Directory Setup"; 
    } 
    return null; 
} 

Manifest ist

<activity 
     android:name="omsairam.servicingrepair.LoginActivity" 
     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="omsairam.servicingrepair.Register" 
     android:label="@string/app_name" > 
     <intent-filter> 
      <action android:name="android.intent.action.GET_CONTENT" /> 
      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
    </activity> 
    <activity 
     android:name="omsairam.servicingrepair.MechanicScreen" 
     android:label="@string/app_name" > 
    </activity> 
</application> 

Problem nicht in der Lage, die Aktivität an der Linie Intent registerIntent = new Intent (LoginActivity.this zu starten, Register.class);

Bitte helfen.

+1

DEFAULT Wenn Sie eine Fehlermeldung erhalten, ist es einfach einfügen. –

Antwort

0

Sie haben zwei LAUNCHER Aktivitäten, machen gerade Register Aktivität

<activity 
    android:name="omsairam.servicingrepair.Register" 
    android:label="@string/app_name" > 
    <intent-filter> 
     <action android:name="android.intent.action.GET_CONTENT" /> 
     <category android:name="android.intent.category.DEFAULT" /> //This line... 
    </intent-filter> 
</activity> 
+0

Änderte den Code wie in den Kommentaren, aber ohne Ergebnis. Absicht startet nicht. –

Verwandte Themen