我正在使用class ProgressTask extends AsyncTask<Integer, Void, Void>{
ProgressDialog pd = new ProgressDialog(MainActivity.this);
@Override
protected Void doInBackground(Integer... i) {
for(int j = 0; j < item.size(); j++) {
pd.setProgress(j);
pd.setMessage((j) + "/" + item.size());
}
return null;
}
@Override
protected void onPreExecute() {
pd.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
pd.setTitle("변경중");
pd.setMax(item.size());
pd.show();
}
}
和omniauth-facebook
gem。我想获得一些用户的信息。但我不知道为什么我不能过生日。
在devise.rb中配置:
devise
控制器:
config.omniauth :facebook, ENV["APP_ID"], ENV["APP_SECRET"], scope: "email,public_profile,user_birthday", info_fields: "email,name,gender,birthday"
型号:
class User::OmniauthCallbacksController < Devise::OmniauthCallbacksController
def facebook
user_info = request.env["omniauth.auth"]
@user = User.find_by_uid user_info.uid
if @user
sign_in @user, event: :authentication
# set_flash_message(:notice, :success, kind: "Facebook") if is_navigational_format?
redirect_to user_root_path
else
redirect_to new_user_user_path(uid: user_info.uid,
email: user_info.info.email, name: user_info.info.name)
end
end
def failure
redirect_to user_session_path
end
end
我从class User < ActiveRecord::Base
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
devise :omniauthable, omniauth_providers: [:facebook]
belongs_to :email_language, class_name: M::SystemLanguage.name,
foreign_key: :email_language_id
validates :email, presence: true, length: {maximum: 255}
validates :uid, uniqueness: true
def active_for_authentication?
super && !withdrawn_at
end
class << self
def available include_withdrawn
include_withdrawn ? all : where("withdrawn_at IS NULL")
end
end
end
获得了价值,但它返回user_info.extra.raw_info.birthday
。