0
A
回答
0
這是可能的。您將要實現私有構造函數/的getInstance()組合 -
/**
* Private constructor.
*/
private GPSPlotter(Context theContext) {
initializeInstance();
initializeFields(theContext);
buildApiClient();
connectClient();
}
/**
* Returns an instance of the GPS Plotter.
*/
public static GPSPlotter getInstance(Context theContext) {
if (gpsPlotterInstance == null)
return new GPSPlotter(theContext);
else
return gpsPlotterInstance;
}
我相當肯定的傳球語境爲模型參數對象與Android約定休息,但構建你的代碼像這應該工作。
相關問題
- 1. 關於Android中的融合位置提供者獲取位置
- 2. 位置爲null融合位置提供者android
- 3. 提供者模型的單例問題
- 4. Android:爲什麼位置的新實例需要提供者?
- 5. 實例化TestBed中的提供者與另一個提供者的實例
- 6. OAuthServce與James Ferreira融合表示例
- 7. 融合位置提供商和「Wi-Fi和移動網絡位置」設置
- 8. 融合位置提供商不夠快速更新
- 9. 例外:沒有HeroService的提供者?
- 10. 內容提供者和內容觀察者示例?
- 11. 在線提供示例RAML
- 12. Facebook新聞提供示例
- 13. 檢查提供的位置信息是否來自融合位置服務提供商是從GPS
- 14. 融合圖表圖例
- 15. 融合的位置崩潰
- 16. 融合的位置提供者似乎並沒有按照間隔集合更新座標
- 17. GAE針對直接提供者聯合身份驗證的Python示例
- 18. 消費者和提供商的LTI兼容示例
- 19. 使用多個提供者的OpenID Connect示例?
- 20. 如何替換Guice的單例(數據源提供者)?
- 21. Android中的位置提供者?
- 22. Android:位置對象的提供者
- 23. 內容提供者示例不使用SQLite
- 24. Android - Xamarin - 融合位置
- 25. 內容提供者是單個阻止實例嗎?
- 26. 提供基本的boto create_qualification_type示例
- 27. 在DotNetOpenAuth中提供SREG/AX的示例
- 28. Angular2 - browser_adapter.ts原來的例外:沒有提供商的位置
- 29. 同時有多個位置提供者
- 30. 確定位置提供者 - Android