随着Android Studio的更新无法启动活动

时间:2015-10-20 15:35:34

标签: android android-activity android-studio

Android工作室已更新,在一切正常之前,但现在有了这个更新,我似乎无法在成功登录后开始我的下一个活动,在这里:

public void doLogIn(View v) {

EditText username =  (EditText) findViewById(R.id.userEditText);
EditText password = (EditText) findViewById(R.id.passwordditText);

final Intent intent = new Intent(this, Menu.class);

if (username.getText().toString().isEmpty() || password.getText().toString().isEmpty()) {


  //Intent intent = new Intent(this, Registro_activity.class);
  //intent.putExtra(EXTRA_MESSAGE, change);
  Toast.makeText(this, "Necesitas poner tu usuario y la contraseña para acceder.", Toast.LENGTH_LONG).show();


} else {

  Log.d("We", "are almost");

  ParseUser.logInInBackground(username.getText().toString(), password.getText().toString(), new LogInCallback() {
    @Override
    public void done(ParseUser user, com.parse.ParseException e) {
      if (user != null) {
        // Hooray! The user is logged in.
        Log.d("IN", "APP");

        validLogin(e);


        startActivityNew(intent);

      } else {
        // Signup failed. Look at the ParseException to see what happened.

        Log.d("error", e.toString());
        invalidLogin(e);
      }
    }
  });
}

 }

public void startActivityNew(Intent intent) {

startActivity(intent);
}

它在AndroidManifest.xml中声明为:

<application
    android:name=".StarterApplication"
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <meta-data
        android:name="com.parse.APPLICATION_ID"
        android:value="@string/parse_app_id" />
    <meta-data
        android:name="com.parse.CLIENT_KEY"
        android:value="@string/parse_client_key" />

    <activity
        android:name=".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=".ChangePass"
        android:label="@string/title_activity_change_pass" >
    </activity>
    <activity
        android:name=".Menu"
        android:label="@string/title_activity_menu"
        android:parentActivityName=".MainActivity"
        android:theme="@style/AppTheme" >
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value="com.parse.starter.MainActivity" />
    </activity>
</application>

错误:

10-19 23:44:58.922 21649-21649/com.parse.starter E/AndroidRuntime: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.parse.starter/android.view.Menu}; have you declared this activity in your AndroidManifest.xml?

发生了什么事?任何帮助?

2 个答案:

答案 0 :(得分:2)

试试这个Manifest

<application
    android:name=".StarterApplication"
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <meta-data
        android:name="com.parse.APPLICATION_ID"
        android:value="@string/parse_app_id" />
    <meta-data
        android:name="com.parse.CLIENT_KEY"
        android:value="@string/parse_client_key" />

    <activity
        android:name=".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=".ChangePass"
        android:label="@string/title_activity_change_pass" >
    </activity>
    <activity
        android:name="com.parse.starter.Menu"
        android:label="@string/title_activity_menu"
        android:parentActivityName="com.parse.starter.MainActivity"
        android:theme="@style/AppTheme" >
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value="com.parse.starter.MainActivity" />
    </activity>
</application>

答案 1 :(得分:1)

ActivityNotFoundException (YES, this activity is declared in AndroidManifest.xml)

给Menu.class一个更具体的位置,即上面的链接,将包添加为后缀。