FragmentActivity.java revision 7dc96cc2410f551eefaa973ddc144146ad72d1ec
1/* 2 * Copyright (C) 2011 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package android.support.v4.app; 18 19import android.app.Activity; 20import android.content.Context; 21import android.content.Intent; 22import android.content.res.Configuration; 23import android.content.res.TypedArray; 24import android.os.Bundle; 25import android.os.Handler; 26import android.os.Message; 27import android.os.Parcelable; 28import android.util.AttributeSet; 29import android.util.Log; 30import android.view.KeyEvent; 31import android.view.Menu; 32import android.view.MenuItem; 33import android.view.View; 34import android.view.Window; 35 36import java.io.FileDescriptor; 37import java.io.PrintWriter; 38import java.util.ArrayList; 39import java.util.HashMap; 40 41/** 42 * Base class for activities that want to use the support-based 43 * {@link android.support.v4.app.Fragment} and 44 * {@link android.support.v4.content.Loader} APIs. 45 * 46 * <p>When using this class as opposed to new platform's built-in fragment 47 * and loader support, you must use the {@link #getSupportFragmentManager()} 48 * and {@link #getSupportLoaderManager()} methods respectively to access 49 * those features. 50 * 51 * <p>Known limitations:</p> 52 * <ul> 53 * <li> <p>When using the <fragment> tag, this implementation can not 54 * use the parent view's ID as the new fragment's ID. You must explicitly 55 * specify an ID (or tag) in the <fragment>.</p> 56 * <li> <p>Prior to Honeycomb (3.0), an activity's state was saved before pausing. 57 * Fragments are a significant amount of new state, and dynamic enough that one 58 * often wants them to change between pausing and stopping. These classes 59 * throw an exception if you try to change the fragment state after it has been 60 * saved, to avoid accidental loss of UI state. However this is too restrictive 61 * prior to Honeycomb, where the state is saved before pausing. To address this, 62 * when running on platforms prior to Honeycomb an exception will not be thrown 63 * if you change fragments between the state save and the activity being stopped. 64 * This means that in some cases if the activity is restored from its last saved 65 * state, this may be a snapshot slightly before what the user last saw.</p> 66 * </ul> 67 */ 68public class FragmentActivity extends Activity { 69 private static final String TAG = "FragmentActivity"; 70 71 private static final String FRAGMENTS_TAG = "android:support:fragments"; 72 73 // This is the SDK API version of Honeycomb (3.0). 74 private static final int HONEYCOMB = 11; 75 76 static final int MSG_REALLY_STOPPED = 1; 77 static final int MSG_RESUME_PENDING = 2; 78 79 final Handler mHandler = new Handler() { 80 @Override 81 public void handleMessage(Message msg) { 82 switch (msg.what) { 83 case MSG_REALLY_STOPPED: 84 if (mStopped) { 85 doReallyStop(false); 86 } 87 break; 88 case MSG_RESUME_PENDING: 89 mFragments.dispatchResume(); 90 mFragments.execPendingActions(); 91 break; 92 default: 93 super.handleMessage(msg); 94 } 95 } 96 97 }; 98 final FragmentManagerImpl mFragments = new FragmentManagerImpl(); 99 100 boolean mCreated; 101 boolean mResumed; 102 boolean mStopped; 103 boolean mReallyStopped; 104 boolean mRetaining; 105 106 boolean mOptionsMenuInvalidated; 107 108 boolean mCheckedForLoaderManager; 109 boolean mLoadersStarted; 110 HCSparseArray<LoaderManagerImpl> mAllLoaderManagers; 111 LoaderManagerImpl mLoaderManager; 112 113 static final class NonConfigurationInstances { 114 Object activity; 115 Object custom; 116 HashMap<String, Object> children; 117 ArrayList<Fragment> fragments; 118 HCSparseArray<LoaderManagerImpl> loaders; 119 } 120 121 static class FragmentTag { 122 public static final int[] Fragment = { 123 0x01010003, 0x010100d0, 0x010100d1 124 }; 125 public static final int Fragment_id = 1; 126 public static final int Fragment_name = 0; 127 public static final int Fragment_tag = 2; 128 } 129 130 // ------------------------------------------------------------------------ 131 // HOOKS INTO ACTIVITY 132 // ------------------------------------------------------------------------ 133 134 /** 135 * Dispatch incoming result to the correct fragment. 136 */ 137 @Override 138 protected void onActivityResult(int requestCode, int resultCode, Intent data) { 139 int index = requestCode>>16; 140 if (index != 0) { 141 index--; 142 if (mFragments.mActive == null || index < 0 || index >= mFragments.mActive.size()) { 143 Log.w(TAG, "Activity result fragment index out of range: 0x" 144 + Integer.toHexString(requestCode)); 145 return; 146 } 147 Fragment frag = mFragments.mActive.get(index); 148 if (frag == null) { 149 Log.w(TAG, "Activity result no fragment exists for index: 0x" 150 + Integer.toHexString(requestCode)); 151 } 152 frag.onActivityResult(requestCode&0xffff, resultCode, data); 153 return; 154 } 155 156 super.onActivityResult(requestCode, resultCode, data); 157 } 158 159 /** 160 * Take care of popping the fragment back stack or finishing the activity 161 * as appropriate. 162 */ 163 public void onBackPressed() { 164 if (!mFragments.popBackStackImmediate()) { 165 finish(); 166 } 167 } 168 169 /** 170 * Dispatch configuration change to all fragments. 171 */ 172 @Override 173 public void onConfigurationChanged(Configuration newConfig) { 174 super.onConfigurationChanged(newConfig); 175 mFragments.dispatchConfigurationChanged(newConfig); 176 } 177 178 /** 179 * Perform initialization of all fragments and loaders. 180 */ 181 @Override 182 protected void onCreate(Bundle savedInstanceState) { 183 mFragments.attachActivity(this); 184 // Old versions of the platform didn't do this! 185 if (getLayoutInflater().getFactory() == null) { 186 getLayoutInflater().setFactory(this); 187 } 188 189 super.onCreate(savedInstanceState); 190 191 NonConfigurationInstances nc = (NonConfigurationInstances) 192 getLastNonConfigurationInstance(); 193 if (nc != null) { 194 mAllLoaderManagers = nc.loaders; 195 } 196 if (savedInstanceState != null) { 197 Parcelable p = savedInstanceState.getParcelable(FRAGMENTS_TAG); 198 mFragments.restoreAllState(p, nc != null ? nc.fragments : null); 199 } 200 mFragments.dispatchCreate(); 201 } 202 203 /** 204 * Dispatch to Fragment.onCreateOptionsMenu(). 205 */ 206 @Override 207 public boolean onCreatePanelMenu(int featureId, Menu menu) { 208 if (featureId == Window.FEATURE_OPTIONS_PANEL) { 209 boolean show = super.onCreatePanelMenu(featureId, menu); 210 show |= mFragments.dispatchCreateOptionsMenu(menu, getMenuInflater()); 211 if (android.os.Build.VERSION.SDK_INT >= HONEYCOMB) { 212 return show; 213 } 214 // Prior to Honeycomb, the framework can't invalidate the options 215 // menu, so we must always say we have one in case the app later 216 // invalidates it and needs to have it shown. 217 return true; 218 } 219 return super.onCreatePanelMenu(featureId, menu); 220 } 221 222 /** 223 * Add support for inflating the <fragment> tag. 224 */ 225 @Override 226 public View onCreateView(String name, Context context, AttributeSet attrs) { 227 if (!"fragment".equals(name)) { 228 return super.onCreateView(name, context, attrs); 229 } 230 231 String fname = attrs.getAttributeValue(null, "class"); 232 TypedArray a = context.obtainStyledAttributes(attrs, FragmentTag.Fragment); 233 if (fname == null) { 234 fname = a.getString(FragmentTag.Fragment_name); 235 } 236 int id = a.getResourceId(FragmentTag.Fragment_id, View.NO_ID); 237 String tag = a.getString(FragmentTag.Fragment_tag); 238 a.recycle(); 239 240 View parent = null; // NOTE: no way to get parent pre-Honeycomb. 241 int containerId = parent != null ? parent.getId() : 0; 242 if (containerId == View.NO_ID && id == View.NO_ID && tag == null) { 243 throw new IllegalArgumentException(attrs.getPositionDescription() 244 + ": Must specify unique android:id, android:tag, or have a parent with an id for " + fname); 245 } 246 247 // If we restored from a previous state, we may already have 248 // instantiated this fragment from the state and should use 249 // that instance instead of making a new one. 250 Fragment fragment = id != View.NO_ID ? mFragments.findFragmentById(id) : null; 251 if (fragment == null && tag != null) { 252 fragment = mFragments.findFragmentByTag(tag); 253 } 254 if (fragment == null && containerId != View.NO_ID) { 255 fragment = mFragments.findFragmentById(containerId); 256 } 257 258 if (FragmentManagerImpl.DEBUG) Log.v(TAG, "onCreateView: id=0x" 259 + Integer.toHexString(id) + " fname=" + fname 260 + " existing=" + fragment); 261 if (fragment == null) { 262 fragment = Fragment.instantiate(this, fname); 263 fragment.mFromLayout = true; 264 fragment.mFragmentId = id != 0 ? id : containerId; 265 fragment.mContainerId = containerId; 266 fragment.mTag = tag; 267 fragment.mInLayout = true; 268 fragment.mFragmentManager = mFragments; 269 fragment.onInflate(this, attrs, fragment.mSavedFragmentState); 270 mFragments.addFragment(fragment, true); 271 272 } else if (fragment.mInLayout) { 273 // A fragment already exists and it is not one we restored from 274 // previous state. 275 throw new IllegalArgumentException(attrs.getPositionDescription() 276 + ": Duplicate id 0x" + Integer.toHexString(id) 277 + ", tag " + tag + ", or parent id 0x" + Integer.toHexString(containerId) 278 + " with another fragment for " + fname); 279 } else { 280 // This fragment was retained from a previous instance; get it 281 // going now. 282 fragment.mInLayout = true; 283 // If this fragment is newly instantiated (either right now, or 284 // from last saved state), then give it the attributes to 285 // initialize itself. 286 if (!fragment.mRetaining) { 287 fragment.onInflate(this, attrs, fragment.mSavedFragmentState); 288 } 289 mFragments.moveToState(fragment); 290 } 291 292 if (fragment.mView == null) { 293 throw new IllegalStateException("Fragment " + fname 294 + " did not create a view."); 295 } 296 if (id != 0) { 297 fragment.mView.setId(id); 298 } 299 if (fragment.mView.getTag() == null) { 300 fragment.mView.setTag(tag); 301 } 302 return fragment.mView; 303 } 304 305 /** 306 * Destroy all fragments and loaders. 307 */ 308 @Override 309 protected void onDestroy() { 310 super.onDestroy(); 311 312 doReallyStop(false); 313 314 mFragments.dispatchDestroy(); 315 if (mLoaderManager != null) { 316 mLoaderManager.doDestroy(); 317 } 318 } 319 320 /** 321 * Take care of calling onBackPressed() for pre-Eclair platforms. 322 */ 323 @Override 324 public boolean onKeyDown(int keyCode, KeyEvent event) { 325 if (android.os.Build.VERSION.SDK_INT < 5 /* ECLAIR */ 326 && keyCode == KeyEvent.KEYCODE_BACK 327 && event.getRepeatCount() == 0) { 328 // Take care of calling this method on earlier versions of 329 // the platform where it doesn't exist. 330 onBackPressed(); 331 return true; 332 } 333 334 return super.onKeyDown(keyCode, event); 335 } 336 337 /** 338 * Dispatch onLowMemory() to all fragments. 339 */ 340 @Override 341 public void onLowMemory() { 342 super.onLowMemory(); 343 mFragments.dispatchLowMemory(); 344 } 345 346 /** 347 * Dispatch context and options menu to fragments. 348 */ 349 @Override 350 public boolean onMenuItemSelected(int featureId, MenuItem item) { 351 if (super.onMenuItemSelected(featureId, item)) { 352 return true; 353 } 354 355 switch (featureId) { 356 case Window.FEATURE_OPTIONS_PANEL: 357 return mFragments.dispatchOptionsItemSelected(item); 358 359 case Window.FEATURE_CONTEXT_MENU: 360 return mFragments.dispatchContextItemSelected(item); 361 362 default: 363 return false; 364 } 365 } 366 367 /** 368 * Call onOptionsMenuClosed() on fragments. 369 */ 370 @Override 371 public void onPanelClosed(int featureId, Menu menu) { 372 switch (featureId) { 373 case Window.FEATURE_OPTIONS_PANEL: 374 mFragments.dispatchOptionsMenuClosed(menu); 375 break; 376 } 377 super.onPanelClosed(featureId, menu); 378 } 379 380 /** 381 * Dispatch onPause() to fragments. 382 */ 383 @Override 384 protected void onPause() { 385 super.onPause(); 386 mResumed = false; 387 if (mHandler.hasMessages(MSG_RESUME_PENDING)) { 388 mHandler.removeMessages(MSG_RESUME_PENDING); 389 mFragments.dispatchResume(); 390 } 391 mFragments.dispatchPause(); 392 } 393 394 /** 395 * Dispatch onResume() to fragments. 396 */ 397 @Override 398 protected void onResume() { 399 super.onResume(); 400 mHandler.sendEmptyMessage(MSG_RESUME_PENDING); 401 mResumed = true; 402 mFragments.execPendingActions(); 403 } 404 405 /** 406 * Dispatch onResume() to fragments. 407 */ 408 @Override 409 protected void onPostResume() { 410 super.onPostResume(); 411 mHandler.removeMessages(MSG_RESUME_PENDING); 412 mFragments.dispatchResume(); 413 mFragments.execPendingActions(); 414 } 415 416 /** 417 * Dispatch onPrepareOptionsMenu() to fragments. 418 */ 419 @Override 420 public boolean onPreparePanel(int featureId, View view, Menu menu) { 421 if (featureId == Window.FEATURE_OPTIONS_PANEL && menu != null) { 422 if (mOptionsMenuInvalidated) { 423 mOptionsMenuInvalidated = false; 424 menu.clear(); 425 onCreatePanelMenu(featureId, menu); 426 } 427 boolean goforit = super.onPreparePanel(featureId, view, menu); 428 goforit |= mFragments.dispatchPrepareOptionsMenu(menu); 429 return goforit && menu.hasVisibleItems(); 430 } 431 return super.onPreparePanel(featureId, view, menu); 432 } 433 434 /** 435 * Retain all appropriate fragment and loader state. You can NOT 436 * override this yourself! Use {@link #onRetainCustomNonConfigurationInstance()} 437 * if you want to retain your own state. 438 */ 439 @Override 440 public final Object onRetainNonConfigurationInstance() { 441 if (mStopped) { 442 doReallyStop(true); 443 } 444 445 Object custom = onRetainCustomNonConfigurationInstance(); 446 447 ArrayList<Fragment> fragments = mFragments.retainNonConfig(); 448 boolean retainLoaders = false; 449 if (mAllLoaderManagers != null) { 450 // prune out any loader managers that were already stopped and so 451 // have nothing useful to retain. 452 for (int i=mAllLoaderManagers.size()-1; i>=0; i--) { 453 LoaderManagerImpl lm = mAllLoaderManagers.valueAt(i); 454 if (lm.mRetaining) { 455 retainLoaders = true; 456 } else { 457 lm.doDestroy(); 458 mAllLoaderManagers.removeAt(i); 459 } 460 } 461 } 462 if (fragments == null && !retainLoaders && custom == null) { 463 return null; 464 } 465 466 NonConfigurationInstances nci = new NonConfigurationInstances(); 467 nci.activity = null; 468 nci.custom = custom; 469 nci.children = null; 470 nci.fragments = fragments; 471 nci.loaders = mAllLoaderManagers; 472 return nci; 473 } 474 475 /** 476 * Save all appropriate fragment state. 477 */ 478 @Override 479 protected void onSaveInstanceState(Bundle outState) { 480 super.onSaveInstanceState(outState); 481 Parcelable p = mFragments.saveAllState(); 482 if (p != null) { 483 outState.putParcelable(FRAGMENTS_TAG, p); 484 } 485 } 486 487 /** 488 * Dispatch onStart() to all fragments. Ensure any created loaders are 489 * now started. 490 */ 491 @Override 492 protected void onStart() { 493 super.onStart(); 494 495 mStopped = false; 496 mReallyStopped = false; 497 mHandler.removeMessages(MSG_REALLY_STOPPED); 498 499 if (!mCreated) { 500 mCreated = true; 501 mFragments.dispatchActivityCreated(); 502 } 503 504 mFragments.noteStateNotSaved(); 505 mFragments.execPendingActions(); 506 507 if (!mLoadersStarted) { 508 mLoadersStarted = true; 509 if (mLoaderManager != null) { 510 mLoaderManager.doStart(); 511 } else if (!mCheckedForLoaderManager) { 512 mLoaderManager = getLoaderManager(-1, mLoadersStarted, false); 513 } 514 mCheckedForLoaderManager = true; 515 } 516 // NOTE: HC onStart goes here. 517 518 mFragments.dispatchStart(); 519 if (mAllLoaderManagers != null) { 520 for (int i=mAllLoaderManagers.size()-1; i>=0; i--) { 521 LoaderManagerImpl lm = mAllLoaderManagers.valueAt(i); 522 lm.finishRetain(); 523 lm.doReportStart(); 524 } 525 } 526 } 527 528 /** 529 * Dispatch onStop() to all fragments. Ensure all loaders are stopped. 530 */ 531 @Override 532 protected void onStop() { 533 super.onStop(); 534 535 mStopped = true; 536 mHandler.sendEmptyMessage(MSG_REALLY_STOPPED); 537 538 mFragments.dispatchStop(); 539 } 540 541 // ------------------------------------------------------------------------ 542 // NEW METHODS 543 // ------------------------------------------------------------------------ 544 545 /** 546 * Use this instead of {@link #onRetainNonConfigurationInstance()}. 547 * Retrieve later with {@link #getLastCustomNonConfigurationInstance()}. 548 */ 549 public Object onRetainCustomNonConfigurationInstance() { 550 return null; 551 } 552 553 /** 554 * Return the value previously returned from 555 * {@link #onRetainCustomNonConfigurationInstance()}. 556 */ 557 public Object getLastCustomNonConfigurationInstance() { 558 NonConfigurationInstances nc = (NonConfigurationInstances) 559 getLastNonConfigurationInstance(); 560 return nc != null ? nc.custom : null; 561 } 562 563 void supportInvalidateOptionsMenu() { 564 if (android.os.Build.VERSION.SDK_INT >= HONEYCOMB) { 565 // If we are running on HC or greater, we can use the framework 566 // API to invalidate the options menu. 567 ActivityCompatHoneycomb.invalidateOptionsMenu(this); 568 return; 569 } 570 571 // Whoops, older platform... we'll use a hack, to manually rebuild 572 // the options menu the next time it is prepared. 573 mOptionsMenuInvalidated = true; 574 } 575 576 /** 577 * Print the Activity's state into the given stream. This gets invoked if 578 * you run "adb shell dumpsys activity <activity_component_name>". 579 * 580 * @param prefix Desired prefix to prepend at each line of output. 581 * @param fd The raw file descriptor that the dump is being sent to. 582 * @param writer The PrintWriter to which you should dump your state. This will be 583 * closed for you after you return. 584 * @param args additional arguments to the dump request. 585 */ 586 public void dump(String prefix, FileDescriptor fd, PrintWriter writer, String[] args) { 587 if (android.os.Build.VERSION.SDK_INT >= HONEYCOMB) { 588 // XXX This can only work if we can call the super-class impl. :/ 589 //ActivityCompatHoneycomb.dump(this, prefix, fd, writer, args); 590 } 591 writer.print(prefix); writer.print("Local FragmentActivity "); 592 writer.print(Integer.toHexString(System.identityHashCode(this))); 593 writer.println(" State:"); 594 String innerPrefix = prefix + " "; 595 writer.print(innerPrefix); writer.print("mCreated="); 596 writer.print(mCreated); writer.print("mResumed="); 597 writer.print(mResumed); writer.print(" mStopped="); 598 writer.print(mStopped); writer.print(" mReallyStopped="); 599 writer.println(mReallyStopped); 600 writer.print(innerPrefix); writer.print("mLoadersStarted="); 601 writer.println(mLoadersStarted); 602 if (mLoaderManager != null) { 603 writer.print(prefix); writer.print("Loader Manager "); 604 writer.print(Integer.toHexString(System.identityHashCode(mLoaderManager))); 605 writer.println(":"); 606 mLoaderManager.dump(prefix + " ", fd, writer, args); 607 } 608 mFragments.dump(prefix, fd, writer, args); 609 } 610 611 void doReallyStop(boolean retaining) { 612 if (!mReallyStopped) { 613 mReallyStopped = true; 614 mRetaining = retaining; 615 mHandler.removeMessages(MSG_REALLY_STOPPED); 616 onReallyStop(); 617 } 618 } 619 620 /** 621 * Pre-HC, we didn't have a way to determine whether an activity was 622 * being stopped for a config change or not until we saw 623 * onRetainNonConfigurationInstance() called after onStop(). However 624 * we need to know this, to know whether to retain fragments. This will 625 * tell us what we need to know. 626 */ 627 void onReallyStop() { 628 if (mLoadersStarted) { 629 mLoadersStarted = false; 630 if (mLoaderManager != null) { 631 if (!mRetaining) { 632 mLoaderManager.doStop(); 633 } else { 634 mLoaderManager.doRetain(); 635 } 636 } 637 } 638 639 mFragments.dispatchReallyStop(); 640 } 641 642 // ------------------------------------------------------------------------ 643 // FRAGMENT SUPPORT 644 // ------------------------------------------------------------------------ 645 646 /** 647 * Called when a fragment is attached to the activity. 648 */ 649 public void onAttachFragment(Fragment fragment) { 650 } 651 652 /** 653 * Return the FragmentManager for interacting with fragments associated 654 * with this activity. 655 */ 656 public FragmentManager getSupportFragmentManager() { 657 return mFragments; 658 } 659 660 /** 661 * Modifies the standard behavior to allow results to be delivered to fragments. 662 * This imposes a restriction that requestCode be <= 0xffff. 663 */ 664 @Override 665 public void startActivityForResult(Intent intent, int requestCode) { 666 if (requestCode != -1 && (requestCode&0xffff0000) != 0) { 667 throw new IllegalArgumentException("Can only use lower 16 bits for requestCode"); 668 } 669 super.startActivityForResult(intent, requestCode); 670 } 671 672 /** 673 * Called by Fragment.startActivityForResult() to implement its behavior. 674 */ 675 public void startActivityFromFragment(Fragment fragment, Intent intent, 676 int requestCode) { 677 if (requestCode == -1) { 678 super.startActivityForResult(intent, -1); 679 return; 680 } 681 if ((requestCode&0xffff0000) != 0) { 682 throw new IllegalArgumentException("Can only use lower 16 bits for requestCode"); 683 } 684 super.startActivityForResult(intent, ((fragment.mIndex+1)<<16) + (requestCode&0xffff)); 685 } 686 687 void invalidateSupportFragmentIndex(int index) { 688 //Log.v(TAG, "invalidateFragmentIndex: index=" + index); 689 if (mAllLoaderManagers != null) { 690 LoaderManagerImpl lm = mAllLoaderManagers.get(index); 691 if (lm != null && !lm.mRetaining) { 692 lm.doDestroy(); 693 mAllLoaderManagers.remove(index); 694 } 695 } 696 } 697 698 // ------------------------------------------------------------------------ 699 // LOADER SUPPORT 700 // ------------------------------------------------------------------------ 701 702 /** 703 * Return the LoaderManager for this fragment, creating it if needed. 704 */ 705 public LoaderManager getSupportLoaderManager() { 706 if (mLoaderManager != null) { 707 return mLoaderManager; 708 } 709 mCheckedForLoaderManager = true; 710 mLoaderManager = getLoaderManager(-1, mLoadersStarted, true); 711 return mLoaderManager; 712 } 713 714 LoaderManagerImpl getLoaderManager(int index, boolean started, boolean create) { 715 if (mAllLoaderManagers == null) { 716 mAllLoaderManagers = new HCSparseArray<LoaderManagerImpl>(); 717 } 718 LoaderManagerImpl lm = mAllLoaderManagers.get(index); 719 if (lm == null) { 720 if (create) { 721 lm = new LoaderManagerImpl(this, started); 722 mAllLoaderManagers.put(index, lm); 723 } 724 } else { 725 lm.updateActivity(this); 726 } 727 return lm; 728 } 729} 730