0

Android用のFcaebook sdkを使用する必要があるアプリを開発しています。私がしなければならないことは、ユーザーがアプリに正常にログインすると、ユーザーは 2 番目のアクティビティに移動することです。ただし、ユーザーがホーム ボタンを押して 2 番目のアクティビティからホームに移動し、ユーザーがデバイスからアプリ アイコンを再度クリックすると、ログイン アクティビティではなく 2 番目のアクティビティが存在する必要があります。これが私のコードです...

login.setSessionStatusCallback(new Session.StatusCallback() {

            @Override
            public void call(Session session, SessionState state, Exception exception) {
                // TODO Auto-generated method stub
                if(session.isOpened())
                {
                    Request.executeMeRequestAsync(session, new Request.GraphUserCallback() {

                        @Override
                        public void onCompleted(GraphUser user, Response response) {
                            String email = user.asMap().get("email").toString();
                            Toast.makeText(getBaseContext(), email + " " + user.getBirthday() , 1000).show();
                            Intent in = new Intent(getBaseContext(), Second.class);
                            in.putExtra("ID", user.getId());
                            startActivity(in);
                            Login.this.finish();
                        }
                    });
                }

            }
        });

2 番目のアクティビティからホーム ボタンを押した後にアプリ アイコンをクリックすると、ログアウト ボタンからログイン アクティビティが開始されます。でも、ここで第二の活動を始めたいと思っています。何をする必要がありますか?

4

4 に答える 4

2

onResume()LoginActivityで何かをする

@Override
protected void onResume() {

    super.onResume();
    if (session!=null&&session.isOpened()) {
        Request.executeMeRequestAsync(session,new Request.GraphUserCallback() {

                    @Override
                    public void onCompleted(GraphUser user,
                            Response response) {
                        String email = user.asMap().get("email").toString();
                        Toast.makeText(getBaseContext(),
                                email + " " + user.getBirthday(), 1000)
                                .show();
                        Intent in = new Intent(getBaseContext(),
                                Second.class);
                        in.putExtra("ID", user.getId());
                        startActivity(in);
                        Login.this.finish();
                    }
                });
    }
}
于 2013-09-06T07:16:48.313 に答える
-2

SharedPreference Boolen LOGGEDIN=trueログインが完了している場合はa を使用します。

それから、

if (LOGGEDIN)
// Go To Second Activity
于 2013-09-06T07:16:41.233 に答える