예제 #1
0
 public static Intent getParentActivityIntent(Context paramContext, Class<?> paramClass)
     throws PackageManager.NameNotFoundException {
   String str = getParentActivityName(paramContext, new ComponentName(paramContext, paramClass));
   if (str == null) {
     return null;
   }
   ComponentName localComponentName = new ComponentName(paramContext, str);
   if (getParentActivityName(paramContext, localComponentName) == null) {
     return IntentCompat.makeMainActivity(localComponentName);
   }
   return new Intent().setComponent(localComponentName);
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_settings);

    Toolbar toolbar = getToolbar();
    if (toolbar != null) {
      toolbar.setTitle(R.string.title_settings);
      toolbar.setNavigationIcon(R.drawable.ic_up);
      toolbar.setNavigationOnClickListener(
          view ->
              navigateUpToFromChild(
                  PreferenceActivity.this,
                  IntentCompat.makeMainActivity(
                      new ComponentName(PreferenceActivity.this, BrowseMoviesActivity.class))));
    }

    if (savedInstanceState == null) {
      getFragmentManager().beginTransaction().add(R.id.container, new SettingsFragment()).commit();
    }
  }
예제 #3
0
 public Intent getParentActivityIntent(Activity paramActivity) {
   String str = NavUtils.getParentActivityName(paramActivity);
   if (str == null) {
     return null;
   }
   ComponentName localComponentName = new ComponentName(paramActivity, str);
   Object localObject;
   try {
     if (NavUtils.getParentActivityName(paramActivity, localComponentName) == null) {
       localObject = IntentCompat.makeMainActivity(localComponentName);
     } else {
       Intent localIntent = new Intent().setComponent(localComponentName);
       localObject = localIntent;
     }
   } catch (PackageManager.NameNotFoundException localNameNotFoundException) {
     Log.e(
         "NavUtils",
         "getParentActivityIntent: bad parentActivityName '" + str + "' in manifest");
     return null;
   }
   return localObject;
 }