![](/img/trans.png)
[英]Titanium: Check if application installed on the device (android)
[英]Facebook Authentication on android device causes failure of application (Titanium android)
在我的應用程序中,我正在使用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上進行了測試。在模擬器應用程序上運行時沒有任何錯誤。是否有任何方法可以解決此問題? 需要幫助..謝謝..
我沒有從Titanium連接到Facebook的經驗,但是兩天前安裝了他們的新示例應用程序之一: https : //wiki.appcelerator.org/display/guides/Example+Applications#ExampleApplications-ARti
這連接到FB,不知道以什么方式。 您可以從GitHub下載示例代碼,也許您覺得它很有用。
此外,根據我的經驗,您使用的舊版Android SDK會出現一些問題。 我在使用2.3及更高版本時有更好的體驗。 最近使用SDK 4.x編譯了一個應用程序,並使其在具有2.2的設備上運行,因此向后兼容沒有問題。 也許有助於升級您的SDK。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.