\r
private boolean mConfigurationChangedToLandscape = false;\r
private FileDownloaderBinder mDownloaderBinder = null;\r
+ private ServiceConnection mConnection = null;\r
\r
@Override\r
protected void onCreate(Bundle savedInstanceState) {\r
);\r
\r
if (!mConfigurationChangedToLandscape) {\r
+ mConnection = new DetailsServiceConnection();\r
bindService(new Intent(this, FileDownloader.class), mConnection, Context.BIND_AUTO_CREATE);\r
\r
setContentView(R.layout.file_activity_details);\r
\r
\r
/** Defines callbacks for service binding, passed to bindService() */\r
- private ServiceConnection mConnection = new ServiceConnection() {\r
+ private class DetailsServiceConnection implements ServiceConnection {\r
\r
@Override\r
public void onServiceConnected(ComponentName className, IBinder service) {\r
mDownloaderBinder = (FileDownloaderBinder) service;\r
FileDetailFragment fragment = (FileDetailFragment) getSupportFragmentManager().findFragmentByTag(FileDetailFragment.FTAG);\r
if (fragment != null)\r
- fragment.updateFileDetails(); // a new chance to get the mDownloadBinder through getDownloadBinder()\r
+ fragment.updateFileDetails(); // let the fragment gets the mDownloadBinder through getDownloadBinder() (see FileDetailFragment#updateFileDetais())\r
}\r
\r
@Override\r
@Override\r
public void onDestroy() {\r
super.onDestroy();\r
- unbindService(mConnection);\r
+ if (mConnection != null) {\r
+ unbindService(mConnection);\r
+ mConnection = null;\r
+ }\r
}\r
\r
\r