2014-03-13 30 views
0

我正在使用專業圖書館。
但我剛剛發現doc for free library 我無法找到專業版的任何文檔。如何測試背景掃描並使用iBeacon-Android在後臺啓動應用程序?

此外,我不知道如何實現背景模式,即使使用親樣本。

步驟如下:

  1. 建立親示例項目
  2. (使用新iPad)開始iBeacon顯示源,它可以檢測
  3. 啓動應用程序,然後按Home鍵將使它在 背景
  4. 關閉iBeacon顯示源
  5. 打開iBeacon顯示源
  6. 濠超過5分鐘,應用程序不會啓動

所以,任何人都可以驗證我所做的步驟嗎?
如何更容易地測試背景模式?

另外,對於BootstrapNotifier,它只是在設備重新啓動時才工作?
之後,即使我將應用程序放在後臺,應用程序在檢測到iBeacon時也不會啓動?

回答

1

您的測試方法聽起來很好。我認爲問題是專業圖書館的參考應用程序僅在啓動後第一次檢測時自動啓動應用程序。之後,它會發送通知,然後點擊該通知啓動應用程序。

這純粹是爲了演示的目的。如果您願意,您可以將其更改爲在每次檢測時自動啓動。簡單地改變此代碼haveDetectedIBeaconsSinceBoot邏輯:

@Override 
public void didEnterRegion(Region arg0) { 
    // In this example, this class sends a notification to the user whenever an iBeacon 
    // matching a Region (defined above) are first seen. 
    Log.d(TAG, "did enter region."); 
    if (!haveDetectedIBeaconsSinceBoot) { 
     Log.d(TAG, "auto launching MainActivity"); 

     // The very first time since boot that we detect an iBeacon, we launch the 
     // MainActivity 
     Intent intent = new Intent(this, MainActivity.class); 
     intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
     // Important: make sure to add android:launchMode="singleInstance" in the manifest 
     // to keep multiple copies of this activity from getting created if the user has 
     // already manually launched the app. 
     this.startActivity(intent); 
     haveDetectedIBeaconsSinceBoot = true; 
    } else { 
     // If we have already seen iBeacons and launched the MainActivity before, we simply 
     // send a notification to the user on subsequent detections. 
     Log.d(TAG, "Sending notification."); 
     sendNotification(); 
    } 


} 

的Javadoc鏈接從main documentation page丟失,當你張貼了這個問題。現在已經修復。

+0

剛剛嘗試忽略hasDetectedIBeaconsSinceBoot的所有邏輯,無論如何只需startActivity,然後關閉源10-15秒後,再打開,可以啓動活動。 – jjLin

+1

我已經更新了JavaDoc鏈接:http://developer.radiusnetworks.com/ibeacon/android/pro/javadocs/ – davidgyoung

相關問題