0
我有FragmenActivity與ViewPager和3頁內。它們都將數據綁定在服務上。當我關閉啓動函數中所有片段的活動時出錯。我在那裏綁定那些碎片。在片段導致錯誤的綁定服務
01-29 21:42:39.394 69
45-6945/ E/ActivityThread﹕ Activity Activity has leaked ServiceConnection [email protected] that was originally bound here
android.app.ServiceConnectionLeaked: Activity Activity has leaked ServiceConnection [email protected] that was originally bound here
at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:974)
at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:868)
at android.app.ContextImpl.bindService(ContextImpl.java:1762)
at android.app.ContextImpl.bindService(ContextImpl.java:1751)
at android.content.ContextWrapper.bindService(ContextWrapper.java:480)
at Fragment.onStart(Fragment.java:127)
代碼,在片段:
@Override
public void onStart() {
super.onStart();
// Bind to the service
getActivity().bindService(new Intent(getActivity(), Service.class), mConnection, Context.BIND_AUTO_CREATE);
}