在我的應用我使用Facebook的authentication.My代碼看起來像Facebook驗證使應用程序(鈦機器人)的失敗
var win1 = Titanium.UI.createWindow({
title:'Tab 1',
backgroundColor:'#fff',
layout:'vertical'
});win1.open();
Titanium.Facebook.appid = "appid";
Titanium.Facebook.permissions = ['abc'];
var facebook_button = Ti.UI.createButton(
{
height:50,
width:200
});win1.add(facebook_button);
facebook_button.addEventListener('click', function(e)
{
Titanium.Facebook.authorize();
});
var facebook = Titanium.Facebook.createLoginButton({
style:'wide',
bottom:80
});
win1.add(facebook);
Titanium.Facebook.addEventListener('login', connect_facebook);
function connect_facebook()
{
alert('inside');
Titanium.Facebook.logout();
}
當我點擊facebook_button現在的問題發生。當我在Android設備(版本2.2)上安裝應用程序時,我點擊facebook_button它導致強制關閉應用程序。強制關閉後如果我再次啓動應用程序並使用相同的功能它工作正常。我的日誌記錄給出以下錯誤java.lang.NullPointerException。 如果我使用鈦facebook按鈕,即Ti.Facebook.createLoginButton即使在首次使用時也不會發生任何錯誤。但我想用我自己的自定義登錄按鈕。 我想刪除這個空指針異常。我正在使用android sdk 2.0.1。並在Android設備2.2上測試。在模擬器應用程序運行時沒有任何錯誤。是否有任何方法可以解決這個問題?需要幫助..謝謝..
爲什麼你要在代碼中同時使用兩個按鈕(facebook_button和facebook)? –
嗨穆罕默德感謝您的快速回復。我使用這兩個按鈕只是爲了測試。如果我只使用自己創建的按鈕,即facebook_button,那麼它也會給出相同的錯誤。 – nilkash