0

Android でセッションを管理しようとしています。共有設定を使用してユーザー データを保存しています。ユーザーが完全にログインし、アプリのホームページが開くはずなのに、Logcat にこのページを処理するアクティビティがないというエラーが表示されると、問題が発生します。
Login.java のコードは次のとおりです。

public class Login extends Activity {
    Button but;
    TextView tex,tex2;
    EditText nameEdit,passEdit;

    public static final String MyPREFERENCES = "MyPrefs" ;
       public static final String name = "nameKey"; 
       public static final String pass = "passwordKey"; 
       SharedPreferences sharedpreferences;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);
    but=(Button)findViewById(R.id.login);

 // nameEdit, passEdit get the user entered username and password respectively.
    nameEdit = (EditText)findViewById(R.id.editText1);
    passEdit = (EditText)findViewById(R.id.editText2);

but.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View arg0) {

//storing userdetails in Shared Preference
         Editor editor = sharedpreferences.edit();
              String u = nameEdit.getText().toString();
              String p = passEdit.getText().toString();
              editor.putString(name, u);
              editor.putString(pass, p);
              editor.commit();
             Intent openStartingPoint=new Intent("app.something.com.Menu");
            startActivity(openStartingPoint); //here occurs the error no activity found to handle this
            finish();
            return;

        }
    });
}    
   @Override
   protected void onResume() {

 //if user already logged in then direct him to "Menu".
      sharedpreferences=getSharedPreferences(MyPREFERENCES, Context.MODE_PRIVATE);
      if (sharedpreferences.contains(name))
      {
      if(sharedpreferences.contains(pass)){
         Intent i = new Intent("app.something.com.Menu");  
         startActivity(i);     
      }
      }
      super.onResume();
   }
}

ユーザーをログアウトする方法は、共有設定エディターがクリアされている次のとおりです

   public void logout()
   {
    SharedPreferences sharedpreferences = getSharedPreferences(Login.MyPREFERENCES,Context.MODE_PRIVATE);
    Editor editor = sharedpreferences.edit();
    editor.clear();
    editor.commit();
    moveTaskToBack(true);
    Control_panel.this.finish();                            
    return;
   }

これがマニフェスト コードです。

<activity
        android:screenOrientation="portrait"
        android:name="app.something.com.Login"
        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="app.something.com.Menu"
     android:label="@string/app_name" >
        <intent-filter>
            <action android:name="app.something.com.Menu" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
  </activity>

Menu.java ファイルが Activity クラスを拡張し、マニフェストにも記載されているにもかかわらず、ActivityNotFoundException が発生する理由がわかりません。このランタイム例外の後、アプリを再度起動すると、Menu.java に対応するアクティビティに直接移動します。これは、まさに起こるべきことです。ただし、例外は誰かがログインしようとしたときにのみ発生します。
私を助けてください!!
前もって感謝します :)

4

1 に答える 1