如果我在PrefsFragment中调用passport.use(new GitHubStrategy({
clientID: GITHUB_CLIENT_ID,
clientSecret: GITHUB_CLIENT_SECRET,
callbackURL: "http://localhost:8080/auth/github/callback",
},
function(accessToken, refreshToken, profile, done) {
// asynchronous verification, for effect...
process.nextTick(function () {
return done(null, profile);
});
}
));
app.get('/auth/github', passport.authenticate('github', { scope: [ 'user:email' ] }), function(req, res){
// The request will be redirected to GitHub for authentication, so this
// function will not be called.
});
app.get('/auth/github/callback', passport.authenticate('github', { failureRedirect: '/login' }), function(req, res) {
console.log(req); // <- This ideally should have the access_token? but doesn't
});
。我收到这个错误......为什么?
如何修复此iusse并理解此错误。
((MainActivity)getActivity()).clearApp();
答案 0 :(得分:1)
方法是clearApp(); MainActivity或PrefsActivity中是否存在?
如果它在PrefsActivity中,那么你可以试试这样的东西
((PrefsActivity)getActivity()).clearApp(); // because You are currently in PrefsActivity
如果方法在MainActivity中,并且您仍想使用PrefsFragment中的方法(PrefsActivity中的PrefsFragment片段)。将clearApp()方法声明为static并访问如下所示
MainActivity.clearApp();
clearApp方法在MainActivty
中应该是这样的public static void clearApp()
{
// your implementation
}