如果Facebook已经安装在设备上,Facebook为什么不注册Facebook? [英] android : why Facebook signup not working if Facebook installed in the device already?
本文介绍了如果Facebook已经安装在设备上,Facebook为什么不注册Facebook?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
O已尝试在我的应用程序中使用Facebook,这在没有安装Facebook应用程序的设备上工作正常。但是当设备上已经安装了Facebook时,无法给出会话。可以任何人帮助我这个
public void facebookSignIn(CallbackContext callContext){
try {
isFacebookLogin = true;
getActivity()。runOnUiThread(new Runnable(){
public void run(){
mConnectionProgressDialog.show();}
});
this.callbackContext = callContext;
Session.openActiveSession(this,true,new Session.StatusCallback(){
//当会话更改状态
@Override
时,回调public void call(Session session,SessionState state,异常异常){
Log.d(facebook,session open);
if(session.isOpened()){
//请求/ me API
Request.newMeRequest(session,new Request.GraphUserCallback(){
//在用户对象的Graph API响应之后的回调
@Override
public void onCompleted(GraphUser user,Response response){
if(user!= null){
String userID = user.getId();
callbackContext.success(userID);
Toast.makeText(MDLIVEMain.this,user。 getName()+是c连接。,Toast.LENGTH_LONG).show();
} else {
// TODO:handle exception
callbackContext.error(MDLiveLocalizationSystem.localizedStringForKey(nat_authen_failure));
}
getActivity()。runOnUiThread(new Runnable(){
public void run(){
mConnectionProgressDialog.dismiss();
}
} );
}
})。executeAsync();
}
}
});
} catch(Exception e){
e.printStackTrace();
callbackContext.error(MDLiveLocalizationSystem.localizedStringForKey(nat_authen_failure));
GATrackingExceptions.trackExceptions(e.getLocalizedMessage(),MDLIVEMain.this);
getActivity()。runOnUiThread(new Runnable(){
public void run(){
mConnectionProgressDialog.dismiss();
}
});
}
}
这里是onactivityResult代码
@Override
protected void onActivityResult(int requestCode,int responseCode,Intent intent){
try {
CordovaPlugin callback = this.activityResultCallbacks;
if(callback!= null){
callback.onActivityResult(requestCode,responseCode,intent);
}
Log.d(isFacebookLogin,isFacebookLogin +);
if(isFacebookLogin){
try {
isFacebookLogin = false;
Session.getActiveSession()。onActivityResult(this,requestCode,responseCode,intent);
} catch(Exception e){
e.printStackTrace();
}
} else {
if(requestCode == REQUEST_CODE_RESOLVE_ERR&& responseCode == RESULT_OK){
mConnectionResult = null;
mPlusClient.connect();
}
getActivity()。runOnUiThread(new Runnable(){
public void run(){
mConnectionProgressDialog.dismiss();
}
});
if(requestCode == PASSCODE_RESULT_PAGE){
if(responseCode == RESULT_OK){
activityVisible = true;
this.callbackContext.success(intent.getExtras()。getString(passcode_pin));
} else {
this.callbackContext.success(intent.getExtras()。getString(passcode_pin));
isFromPasscodePage = true;
}
}
}
} catch(异常e){
e.printStackTrace();
}
}
解决方案
已经回答了这种类型的(Hash for fb)问题:
注意:Fb给出了无效的哈希问题bcz,因为你必须生成一个有效的哈希。
O have tried to use Facebook in my application, this works fine on device that doesn't have Facebook app installed. But this fails to give the session while there is Facebook already installed on the device. Can any one help me on this
public void facebookSignIn(CallbackContext callContext){
try {
isFacebookLogin = true;
getActivity().runOnUiThread(new Runnable() {
public void run() {
mConnectionProgressDialog.show(); }
});
this.callbackContext = callContext;
Session.openActiveSession(this, true, new Session.StatusCallback() {
// callback when session changes state
@Override
public void call(Session session, SessionState state, Exception exception) {
Log.d("facebook","session open");
if (session.isOpened()) {
// make request to the /me API
Request.newMeRequest(session, new Request.GraphUserCallback() {
// callback after Graph API response with user object
@Override
public void onCompleted(GraphUser user, Response response) {
if (user != null) {
String userID = user.getId();
callbackContext.success(userID);
Toast.makeText(MDLIVEMain.this, user.getName() + " is connected.", Toast.LENGTH_LONG).show();
} else {
// TODO: handle exception
callbackContext.error(MDLiveLocalizationSystem.localizedStringForKey("nat_authen_failure"));
}
getActivity().runOnUiThread(new Runnable() {
public void run() {
mConnectionProgressDialog.dismiss();
}
});
}
}).executeAsync();
}
}
});
}catch (Exception e){
e.printStackTrace();
callbackContext.error(MDLiveLocalizationSystem.localizedStringForKey("nat_authen_failure"));
GATrackingExceptions.trackExceptions(e.getLocalizedMessage(), MDLIVEMain.this);
getActivity().runOnUiThread(new Runnable() {
public void run() {
mConnectionProgressDialog.dismiss();
}
});
}
}
Here is onactivityResult code
@Override
protected void onActivityResult(int requestCode, int responseCode, Intent intent) {
try {
CordovaPlugin callback = this.activityResultCallbacks;
if (callback != null) {
callback.onActivityResult(requestCode, responseCode, intent);
}
Log.d("isFacebookLogin",isFacebookLogin+"");
if(isFacebookLogin){
try {
isFacebookLogin = false;
Session.getActiveSession().onActivityResult(this, requestCode, responseCode, intent);
}catch (Exception e){
e.printStackTrace();
}
}else {
if (requestCode == REQUEST_CODE_RESOLVE_ERR && responseCode == RESULT_OK) {
mConnectionResult = null;
mPlusClient.connect();
}
getActivity().runOnUiThread(new Runnable() {
public void run() {
mConnectionProgressDialog.dismiss();
}
});
if (requestCode == PASSCODE_RESULT_PAGE) {
if (responseCode == RESULT_OK) {
activityVisible = true;
this.callbackContext.success(intent.getExtras().getString("passcode_pin"));
} else {
this.callbackContext.success(intent.getExtras().getString("passcode_pin"));
isFromPasscodePage = true;
}
}
}
}catch (Exception e){
e.printStackTrace();
}
}
解决方案
I have answered for this type of (Hash for fb) issue here :
Facebook Login and Post To Wall works for first time only
Note: Fb gives issues bcz of not valid Hash, for that you have to generate a valid hash.
这篇关于如果Facebook已经安装在设备上,Facebook为什么不注册Facebook?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文