Java 类android.support.v4.content.IntentCompat 实例源码

项目:shortstories    文件:IntentUtil.java   
public static Intent addShowScenarioShortcut(Context context, Choice choice) {
    Intent addShowScenarioShortcutIntent = new Intent(context, AddShowScenarioShortcutActivity.class);
    addShowScenarioShortcutIntent = IntentCompat.makeRestartActivityTask(addShowScenarioShortcutIntent.getComponent());
    addShowScenarioShortcutIntent.setAction(Intent.ACTION_VIEW);
    addShowScenarioShortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
    Serializer serializer = new Persister();
    ByteArrayOutputStream choiceOutputStream = new ByteArrayOutputStream();
    try {
        serializer.write(choice, choiceOutputStream);
    } catch (Exception e) {
        Log.d(TAG, e.toString());
    }
    String choiceXml = choiceOutputStream.toString();
    addShowScenarioShortcutIntent.putExtra(EXTRA_CHOICE_XML, choiceXml);
    return addShowScenarioShortcutIntent;
}
项目:RemindrApp-Android    文件:PreferencesFragment.java   
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    mListener = new SharedPreferences.OnSharedPreferenceChangeListener() {
        @Override
        public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
            //Preferences.sync(getPreferenceManager(), key);
            if (key.equals(getActivity().getString(R.string.pref_theme))) {
                getActivity().finish();
                final Intent intent = getActivity().getIntent();
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | IntentCompat.FLAG_ACTIVITY_CLEAR_TASK);
                getActivity().startActivity(intent);
            }
        }
    };
}
项目:PTHAndroid    文件:LoginActivity.java   
@Override
protected void onPostExecute(Status status){
    super.onPostExecute(status);
    if (status == Status.OK){
        if (loginRequest){
            Intent result = new Intent();
            setResult(Activity.RESULT_OK, result);
            LoginActivity.this.finish();
        }
        else {
            Intent intent = new Intent(LoginActivity.this, ProfileActivity.class);
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | IntentCompat.FLAG_ACTIVITY_CLEAR_TASK);
            startActivity(intent);
        }
    }
    else if (status == Status.COOKIE_EXPIRED){
        Toast.makeText(LoginActivity.this, "Cookie expired, please login", Toast.LENGTH_LONG).show();
    }
    else {
        Toast.makeText(LoginActivity.this, "Could not login", Toast.LENGTH_LONG).show();
    }
}
项目:FMTech    文件:NavUtils.java   
public Intent getParentActivityIntent(Activity paramActivity)
{
  String str = NavUtils.getParentActivityName(paramActivity);
  if (str == null) {
    return null;
  }
  ComponentName localComponentName = new ComponentName(paramActivity, str);
  try
  {
    if (NavUtils.getParentActivityName(paramActivity, localComponentName) == null) {
      return IntentCompat.makeMainActivity(localComponentName);
    }
    Intent localIntent = new Intent().setComponent(localComponentName);
    return localIntent;
  }
  catch (PackageManager.NameNotFoundException localNameNotFoundException)
  {
    Log.e("NavUtils", "getParentActivityIntent: bad parentActivityName '" + str + "' in manifest");
  }
  return null;
}
项目:wordpress_app_android    文件:PostUploadService.java   
public PostUploadNotifier(Post post) {
    // add the uploader to the notification bar
    mNotificationManager = (NotificationManager) SystemServiceFactory.get(mContext,
            Context.NOTIFICATION_SERVICE);

    mNotificationBuilder = new NotificationCompat.Builder(getApplicationContext());
    mNotificationBuilder.setSmallIcon(android.R.drawable.stat_sys_upload);

    Intent notificationIntent = new Intent(mContext, post.isPage() ? PagesActivity.class : PostsActivity.class);
    notificationIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK
            | IntentCompat.FLAG_ACTIVITY_CLEAR_TASK);
    notificationIntent.setAction(Intent.ACTION_MAIN);
    notificationIntent.addCategory(Intent.CATEGORY_LAUNCHER);
    notificationIntent.setData((Uri.parse("custom://wordpressNotificationIntent"
            + post.getLocalTableBlogId())));
    notificationIntent.putExtra(PostsActivity.EXTRA_VIEW_PAGES, post.isPage());
    PendingIntent pendingIntent = PendingIntent.getActivity(mContext, 0, notificationIntent,
            PendingIntent.FLAG_UPDATE_CURRENT);

    mNotificationBuilder.setContentIntent(pendingIntent);

    mNotificationId = (new Random()).nextInt() + post.getLocalTableBlogId();
    startForeground(mNotificationId, mNotificationBuilder.build());
}
项目:RemindrApp-Android    文件:PreferencesFragment.java   
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    mListener = new SharedPreferences.OnSharedPreferenceChangeListener() {
        @Override
        public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
            //Preferences.sync(getPreferenceManager(), key);
            if (key.equals(getActivity().getString(R.string.pref_theme))) {
                getActivity().finish();
                final Intent intent = getActivity().getIntent();
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | IntentCompat.FLAG_ACTIVITY_CLEAR_TASK);
                getActivity().startActivity(intent);
            }
        }
    };
}
项目:bblfr-android    文件:NavigationDrawerActivity.java   
@Override
public void onBackPressed() {
    if (!mHasNavigationDrawer) {
        super.onBackPressed();
        return;
    }

    DrawerLayout drawer = mNavigationDrawer.mLayout;
    if (drawer.isDrawerVisible(GravityCompat.START)) {
        drawer.closeDrawer(GravityCompat.START);
    } else {
        if (NavigationDrawerEntry.FIND_BAGGER.equals(mSelectedDrawerItem)) {
            super.onBackPressed();
        } else {
            Intent intent = BaggersListActivity.createLaunchIntent(this, mPrefs.getCity());
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | IntentCompat.FLAG_ACTIVITY_CLEAR_TASK);
            startActivityWithoutTransition(intent);
            finish();
        }
    }
}
项目:ShoppingMall    文件:TaskStackBuilder.java   
/**
 * Start the task stack constructed by this builder. The Context used to obtain
 * this builder must be an Activity.
 *
 * <p>On devices that do not support API level 11 or higher the topmost activity
 * will be started as a new task. On devices that do support API level 11 or higher
 * the new task stack will be created in its entirety.</p>
 *
 * @param options Additional options for how the Activity should be started.
 * See {@link android.content.Context#startActivity(Intent, Bundle)
 */
public void startActivities(Bundle options) {
    if (mIntents.isEmpty()) {
        throw new IllegalStateException(
                "No intents added to TaskStackBuilder; cannot startActivities");
    }

    Intent[] intents = mIntents.toArray(new Intent[mIntents.size()]);
    intents[0] = new Intent(intents[0]).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
            IntentCompat.FLAG_ACTIVITY_CLEAR_TASK |
            IntentCompat.FLAG_ACTIVITY_TASK_ON_HOME);
    if (!ContextCompat.startActivities(mSourceContext, intents, options)) {
        Intent topIntent = new Intent(intents[intents.length - 1]);
        topIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        mSourceContext.startActivity(topIntent);
    }
}
项目:ShoppingMall    文件:NavUtils.java   
@Override
public Intent getParentActivityIntent(Activity activity) {
    String parentName = NavUtils.getParentActivityName(activity);
    if (parentName == null) return null;

    // If the parent itself has no parent, generate a main activity intent.
    final ComponentName target = new ComponentName(activity, parentName);
    try {
        final String grandparent = NavUtils.getParentActivityName(activity, target);
        final Intent parentIntent = grandparent == null
                ? IntentCompat.makeMainActivity(target)
                : new Intent().setComponent(target);
        return parentIntent;
    } catch (NameNotFoundException e) {
        Log.e(TAG, "getParentActivityIntent: bad parentActivityName '" + parentName +
                "' in manifest");
        return null;
    }
}
项目:MaterialTasksApp-Android    文件:SettingsFragment.java   
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    mListener = new SharedPreferences.OnSharedPreferenceChangeListener() {
        @Override
        public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
            //Preferences.sync(getPreferenceManager(), key);
            if (key.equals(getActivity().getString(R.string.pref_theme))) {
                getActivity().finish();
                final Intent intent = getActivity().getIntent();
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | IntentCompat.FLAG_ACTIVITY_CLEAR_TASK);
                getActivity().startActivity(intent);
            }
            /*if(key.equals(getActivity().getString(R.string.pref_help))){
                getActivity().finish();
                startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://android.bowenchin.com")));
            }*/
        }
    };
}
项目:saarang-iosched    文件:SettingsActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_settings);

    Toolbar toolbar = getActionBarToolbar();
    toolbar.setTitle(R.string.title_settings);
    toolbar.setNavigationIcon(R.drawable.ic_up);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            navigateUpToFromChild(SettingsActivity.this,
                    IntentCompat.makeMainActivity(new ComponentName(SettingsActivity.this,
                            BrowseSessionsActivity.class)));
        }
    });

    if (savedInstanceState == null) {
        getFragmentManager().beginTransaction()
                .add(R.id.container, new SettingsFragment())
                .commit();
    }
}
项目:AppDevFestSudeste2015    文件:SettingsActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_settings);

    Toolbar toolbar = getActionBarToolbar();
    toolbar.setTitle(R.string.title_settings);
    toolbar.setNavigationIcon(R.drawable.ic_up);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            navigateUpToFromChild(SettingsActivity.this,
                    IntentCompat.makeMainActivity(new ComponentName(SettingsActivity.this,
                            BrowseSessionsActivity.class)));
        }
    });

    if (savedInstanceState == null) {
        getFragmentManager().beginTransaction()
                .add(R.id.container, new SettingsFragment())
                .commit();
    }
}
项目:MiBandDecompiled    文件:NavUtils.java   
public static Intent getParentActivityIntent(Context context, ComponentName componentname)
{
    String s = getParentActivityName(context, componentname);
    if (s == null)
    {
        return null;
    }
    ComponentName componentname1 = new ComponentName(componentname.getPackageName(), s);
    if (getParentActivityName(context, componentname1) == null)
    {
        return IntentCompat.makeMainActivity(componentname1);
    } else
    {
        return (new Intent()).setComponent(componentname1);
    }
}
项目:MiBandDecompiled    文件:NavUtils.java   
public static Intent getParentActivityIntent(Context context, Class class1)
{
    String s = getParentActivityName(context, new ComponentName(context, class1));
    if (s == null)
    {
        return null;
    }
    ComponentName componentname = new ComponentName(context, s);
    if (getParentActivityName(context, componentname) == null)
    {
        return IntentCompat.makeMainActivity(componentname);
    } else
    {
        return (new Intent()).setComponent(componentname);
    }
}
项目:Hentoid    文件:Helper.java   
public static void doRestart(@NonNull Context cxt) {
    try {
        PackageManager pm = cxt.getPackageManager();
        if (pm != null) {
            Intent intent = pm.getLaunchIntentForPackage(cxt.getPackageName());
            if (intent != null) {
                ComponentName componentName = intent.getComponent();
                Intent mainIntent = IntentCompat.makeRestartActivityTask(componentName);
                mainIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
                        | Intent.FLAG_ACTIVITY_NEW_TASK
                        | Intent.FLAG_ACTIVITY_CLEAR_TASK);
                cxt.startActivity(mainIntent);

                Runtime.getRuntime().exit(0);
            } else {
                LogHelper.d(TAG, "Was not able to restart application, intent null");
            }
        } else {
            LogHelper.d(TAG, "Was not able to restart application, PM null");
        }
    } catch (Exception e) {
        LogHelper.e(TAG, e, "Was not able to restart application");
    }
}
项目:CodenameOne    文件:TaskStackBuilder.java   
/**
 * Start the task stack constructed by this builder. The Context used to obtain
 * this builder must be an Activity.
 *
 * <p>On devices that do not support API level 11 or higher the topmost activity
 * will be started as a new task. On devices that do support API level 11 or higher
 * the new task stack will be created in its entirety.</p>
 *
 * @param options Additional options for how the Activity should be started.
 * See {@link android.content.Context#startActivity(Intent, Bundle)
 */
public void startActivities(Bundle options) {
    if (mIntents.isEmpty()) {
        throw new IllegalStateException(
                "No intents added to TaskStackBuilder; cannot startActivities");
    }

    Intent[] intents = mIntents.toArray(new Intent[mIntents.size()]);
    intents[0] = new Intent(intents[0]).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
            IntentCompat.FLAG_ACTIVITY_CLEAR_TASK |
            IntentCompat.FLAG_ACTIVITY_TASK_ON_HOME);
    if (!ContextCompat.startActivities(mSourceContext, intents, options)) {
        Intent topIntent = new Intent(intents[intents.length - 1]);
        topIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        mSourceContext.startActivity(topIntent);
    }
}
项目:CodenameOne    文件:NavUtils.java   
@Override
public Intent getParentActivityIntent(Activity activity) {
    String parentName = NavUtils.getParentActivityName(activity);
    if (parentName == null) return null;

    // If the parent itself has no parent, generate a main activity intent.
    final ComponentName target = new ComponentName(activity, parentName);
    try {
        final String grandparent = NavUtils.getParentActivityName(activity, target);
        final Intent parentIntent = grandparent == null
                ? IntentCompat.makeMainActivity(target)
                : new Intent().setComponent(target);
        return parentIntent;
    } catch (NameNotFoundException e) {
        Log.e(TAG, "getParentActivityIntent: bad parentActivityName '" + parentName +
                "' in manifest");
        return null;
    }
}
项目:MyCTFWriteUps    文件:NavUtils.java   
public static Intent getParentActivityIntent(Context context, ComponentName componentname)
    throws android.content.pm.PackageManager.NameNotFoundException
{
    String s = getParentActivityName(context, componentname);
    if (s == null)
    {
        return null;
    }
    componentname = new ComponentName(componentname.getPackageName(), s);
    if (getParentActivityName(context, componentname) == null)
    {
        return IntentCompat.makeMainActivity(componentname);
    } else
    {
        return (new Intent()).setComponent(componentname);
    }
}
项目:MyCTFWriteUps    文件:NavUtils.java   
public static Intent getParentActivityIntent(Context context, Class class1)
    throws android.content.pm.PackageManager.NameNotFoundException
{
    class1 = getParentActivityName(context, new ComponentName(context, class1));
    if (class1 == null)
    {
        return null;
    }
    class1 = new ComponentName(context, class1);
    if (getParentActivityName(context, class1) == null)
    {
        return IntentCompat.makeMainActivity(class1);
    } else
    {
        return (new Intent()).setComponent(class1);
    }
}
项目:adt-leanback-support    文件:TaskStackBuilder.java   
/**
 * Start the task stack constructed by this builder. The Context used to obtain
 * this builder must be an Activity.
 *
 * <p>On devices that do not support API level 11 or higher the topmost activity
 * will be started as a new task. On devices that do support API level 11 or higher
 * the new task stack will be created in its entirety.</p>
 *
 * @param options Additional options for how the Activity should be started.
 * See {@link android.content.Context#startActivity(Intent, Bundle)
 */
public void startActivities(Bundle options) {
    if (mIntents.isEmpty()) {
        throw new IllegalStateException(
                "No intents added to TaskStackBuilder; cannot startActivities");
    }

    Intent[] intents = mIntents.toArray(new Intent[mIntents.size()]);
    intents[0] = new Intent(intents[0]).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
            IntentCompat.FLAG_ACTIVITY_CLEAR_TASK |
            IntentCompat.FLAG_ACTIVITY_TASK_ON_HOME);
    if (!ContextCompat.startActivities(mSourceContext, intents, options)) {
        Intent topIntent = new Intent(intents[intents.length - 1]);
        topIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        mSourceContext.startActivity(topIntent);
    }
}
项目:adt-leanback-support    文件:NavUtils.java   
@Override
public Intent getParentActivityIntent(Activity activity) {
    String parentName = NavUtils.getParentActivityName(activity);
    if (parentName == null) return null;

    // If the parent itself has no parent, generate a main activity intent.
    final ComponentName target = new ComponentName(activity, parentName);
    try {
        final String grandparent = NavUtils.getParentActivityName(activity, target);
        final Intent parentIntent = grandparent == null
                ? IntentCompat.makeMainActivity(target)
                : new Intent().setComponent(target);
        return parentIntent;
    } catch (NameNotFoundException e) {
        Log.e(TAG, "getParentActivityIntent: bad parentActivityName '" + parentName +
                "' in manifest");
        return null;
    }
}
项目:generator-android    文件:TaskStackBuilder.java   
/**
 * Start the task stack constructed by this builder. The Context used to obtain
 * this builder must be an Activity.
 *
 * <p>On devices that do not support API level 11 or higher the topmost activity
 * will be started as a new task. On devices that do support API level 11 or higher
 * the new task stack will be created in its entirety.</p>
 *
 * @param options Additional options for how the Activity should be started.
 * See {@link android.content.Context#startActivity(Intent, Bundle)
 */
public void startActivities(Bundle options) {
    if (mIntents.isEmpty()) {
        throw new IllegalStateException(
                "No intents added to TaskStackBuilder; cannot startActivities");
    }

    Intent[] intents = mIntents.toArray(new Intent[mIntents.size()]);
    intents[0] = new Intent(intents[0]).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
            IntentCompat.FLAG_ACTIVITY_CLEAR_TASK |
            IntentCompat.FLAG_ACTIVITY_TASK_ON_HOME);
    if (!ContextCompat.startActivities(mSourceContext, intents, options)) {
        Intent topIntent = new Intent(intents[intents.length - 1]);
        topIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        mSourceContext.startActivity(topIntent);
    }
}
项目:generator-android    文件:NavUtils.java   
@Override
public Intent getParentActivityIntent(Activity activity) {
    String parentName = NavUtils.getParentActivityName(activity);
    if (parentName == null) return null;

    // If the parent itself has no parent, generate a main activity intent.
    final ComponentName target = new ComponentName(activity, parentName);
    try {
        final String grandparent = NavUtils.getParentActivityName(activity, target);
        final Intent parentIntent = grandparent == null
                ? IntentCompat.makeMainActivity(target)
                : new Intent().setComponent(target);
        return parentIntent;
    } catch (NameNotFoundException e) {
        Log.e(TAG, "getParentActivityIntent: bad parentActivityName '" + parentName +
                "' in manifest");
        return null;
    }
}
项目:informant-droid    文件:TaskStackBuilder.java   
/**
 * Start the task stack constructed by this builder. The Context used to obtain
 * this builder must be an Activity.
 *
 * <p>On devices that do not support API level 11 or higher the topmost activity
 * will be started as a new task. On devices that do support API level 11 or higher
 * the new task stack will be created in its entirety.</p>
 *
 * @param options Additional options for how the Activity should be started.
 * See {@link android.content.Context#startActivity(Intent, Bundle)
 */
public void startActivities(Bundle options) {
    if (mIntents.isEmpty()) {
        throw new IllegalStateException(
                "No intents added to TaskStackBuilder; cannot startActivities");
    }

    Intent[] intents = mIntents.toArray(new Intent[mIntents.size()]);
    intents[0] = new Intent(intents[0]).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
            IntentCompat.FLAG_ACTIVITY_CLEAR_TASK |
            IntentCompat.FLAG_ACTIVITY_TASK_ON_HOME);
    if (!ContextCompat.startActivities(mSourceContext, intents, options)) {
        Intent topIntent = new Intent(intents[intents.length - 1]);
        topIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        mSourceContext.startActivity(topIntent);
    }
}
项目:informant-droid    文件:NavUtils.java   
@Override
public Intent getParentActivityIntent(Activity activity) {
    String parentName = NavUtils.getParentActivityName(activity);
    if (parentName == null) return null;

    // If the parent itself has no parent, generate a main activity intent.
    final ComponentName target = new ComponentName(activity, parentName);
    try {
        final String grandparent = NavUtils.getParentActivityName(activity, target);
        final Intent parentIntent = grandparent == null
                ? IntentCompat.makeMainActivity(target)
                : new Intent().setComponent(target);
        return parentIntent;
    } catch (NameNotFoundException e) {
        Log.e(TAG, "getParentActivityIntent: bad parentActivityName '" + parentName +
                "' in manifest");
        return null;
    }
}
项目:Secrecy_fDroid_DEPRECIATED    文件:OutgoingCallReceiver.java   
@Override
public void onReceive(final Context context, Intent intent) {

    // Gets the intent, check if it matches our secret code
    if (Intent.ACTION_NEW_OUTGOING_CALL.equals(intent.getAction()) &&
            intent.getExtras() != null) {
        Intent launcher = new Intent(context, MainActivity_.class);
        //These flags are added to make the new mainActivity in the home stack.
        //i.e. back button returns to home not dialer.
        launcher.addFlags(IntentCompat.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK | IntentCompat.FLAG_ACTIVITY_TASK_ON_HOME);
        String phoneNumber = intent.getExtras().getString(android.content.Intent.EXTRA_PHONE_NUMBER);
        if (Pref.OpenPIN().exists())
            if (("*#" + Pref.OpenPIN().get()).equals(phoneNumber))
                // Launch the main app!!
                launchActivity(context, launcher);
    }
}
项目:Secrecy_fDroid_DEPRECIATED    文件:SettingsFragment.java   
void confirm_stealth(String password) {
    final View dialogView = View.inflate(context, R.layout.dialog_confirm_stealth, null);
    ((TextView) dialogView
            .findViewById(R.id.stealth_keycode))
            .append(password);
    new AlertDialog.Builder(context)
            .setInverseBackgroundForced(true)
            .setView(dialogView)
            .setMessage(R.string.Settings__try_once_before_hide)
            .setPositiveButton(getString(R.string.OK), new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    Prefs.stealthMode().put(-1);
                    Intent dial = new Intent();
                    dial.setAction("android.intent.action.DIAL");
                    dial.setData(Uri.parse("tel:"));
                    dial.setFlags(IntentCompat.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
                    startActivity(dial);
                    context.finish();
                }
            })
            .show();
}
项目:android-recipes-app    文件:TaskStackBuilder.java   
/**
 * Start the task stack constructed by this builder. The Context used to obtain
 * this builder must be an Activity.
 *
 * <p>On devices that do not support API level 11 or higher the topmost activity
 * will be started as a new task. On devices that do support API level 11 or higher
 * the new task stack will be created in its entirety.</p>
 *
 * @param options Additional options for how the Activity should be started.
 * See {@link android.content.Context#startActivity(Intent, Bundle)
 */
public void startActivities(Bundle options) {
    if (mIntents.isEmpty()) {
        throw new IllegalStateException(
                "No intents added to TaskStackBuilder; cannot startActivities");
    }

    Intent[] intents = mIntents.toArray(new Intent[mIntents.size()]);
    intents[0] = new Intent(intents[0]).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
            IntentCompat.FLAG_ACTIVITY_CLEAR_TASK |
            IntentCompat.FLAG_ACTIVITY_TASK_ON_HOME);
    if (!ContextCompat.startActivities(mSourceContext, intents, options)) {
        Intent topIntent = new Intent(intents[intents.length - 1]);
        topIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        mSourceContext.startActivity(topIntent);
    }
}
项目:android-recipes-app    文件:NavUtils.java   
@Override
public Intent getParentActivityIntent(Activity activity) {
    String parentName = NavUtils.getParentActivityName(activity);
    if (parentName == null) return null;

    // If the parent itself has no parent, generate a main activity intent.
    final ComponentName target = new ComponentName(activity, parentName);
    try {
        final String grandparent = NavUtils.getParentActivityName(activity, target);
        final Intent parentIntent = grandparent == null
                ? IntentCompat.makeMainActivity(target)
                : new Intent().setComponent(target);
        return parentIntent;
    } catch (NameNotFoundException e) {
        Log.e(TAG, "getParentActivityIntent: bad parentActivityName '" + parentName +
                "' in manifest");
        return null;
    }
}
项目:bitcast    文件:TaskStackBuilder.java   
/**
 * Start the task stack constructed by this builder. The Context used to obtain
 * this builder must be an Activity.
 *
 * <p>On devices that do not support API level 11 or higher the topmost activity
 * will be started as a new task. On devices that do support API level 11 or higher
 * the new task stack will be created in its entirety.</p>
 *
 * @param options Additional options for how the Activity should be started.
 * See {@link android.content.Context#startActivity(Intent, Bundle)
 */
public void startActivities(Bundle options) {
    if (mIntents.isEmpty()) {
        throw new IllegalStateException(
                "No intents added to TaskStackBuilder; cannot startActivities");
    }

    Intent[] intents = mIntents.toArray(new Intent[mIntents.size()]);
    intents[0] = new Intent(intents[0]).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
            IntentCompat.FLAG_ACTIVITY_CLEAR_TASK |
            IntentCompat.FLAG_ACTIVITY_TASK_ON_HOME);
    if (!ContextCompat.startActivities(mSourceContext, intents, options)) {
        Intent topIntent = new Intent(intents[intents.length - 1]);
        topIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        mSourceContext.startActivity(topIntent);
    }
}
项目:bitcast    文件:NavUtils.java   
@Override
public Intent getParentActivityIntent(Activity activity) {
    String parentName = NavUtils.getParentActivityName(activity);
    if (parentName == null) return null;

    // If the parent itself has no parent, generate a main activity intent.
    final ComponentName target = new ComponentName(activity, parentName);
    try {
        final String grandparent = NavUtils.getParentActivityName(activity, target);
        final Intent parentIntent = grandparent == null
                ? IntentCompat.makeMainActivity(target)
                : new Intent().setComponent(target);
        return parentIntent;
    } catch (NameNotFoundException e) {
        Log.e(TAG, "getParentActivityIntent: bad parentActivityName '" + parentName +
                "' in manifest");
        return null;
    }
}
项目:saarang-iosched    文件:SettingsActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_settings);

    Toolbar toolbar = getActionBarToolbar();
    toolbar.setTitle(R.string.title_settings);
    toolbar.setNavigationIcon(R.drawable.ic_up);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            navigateUpToFromChild(SettingsActivity.this,
                    IntentCompat.makeMainActivity(new ComponentName(SettingsActivity.this,
                            BrowseSessionsActivity.class)));
        }
    });

    if (savedInstanceState == null) {
        getFragmentManager().beginTransaction()
                .add(R.id.container, new SettingsFragment())
                .commit();
    }
}
项目:V.FlyoutTest    文件:TaskStackBuilder.java   
/**
 * Start the task stack constructed by this builder. The Context used to obtain
 * this builder must be an Activity.
 *
 * <p>On devices that do not support API level 11 or higher the topmost activity
 * will be started as a new task. On devices that do support API level 11 or higher
 * the new task stack will be created in its entirety.</p>
 *
 * @param options Additional options for how the Activity should be started.
 * See {@link android.content.Context#startActivity(Intent, Bundle)
 */
public void startActivities(Bundle options) {
    if (mIntents.isEmpty()) {
        throw new IllegalStateException(
                "No intents added to TaskStackBuilder; cannot startActivities");
    }

    Intent[] intents = mIntents.toArray(new Intent[mIntents.size()]);
    intents[0] = new Intent(intents[0]).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
            IntentCompat.FLAG_ACTIVITY_CLEAR_TASK |
            IntentCompat.FLAG_ACTIVITY_TASK_ON_HOME);
    if (!ContextCompat.startActivities(mSourceContext, intents, options)) {
        Intent topIntent = new Intent(intents[intents.length - 1]);
        topIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        mSourceContext.startActivity(topIntent);
    }
}
项目:V.FlyoutTest    文件:NavUtils.java   
@Override
public Intent getParentActivityIntent(Activity activity) {
    String parentName = NavUtils.getParentActivityName(activity);
    if (parentName == null) return null;

    // If the parent itself has no parent, generate a main activity intent.
    final ComponentName target = new ComponentName(activity, parentName);
    try {
        final String grandparent = NavUtils.getParentActivityName(activity, target);
        final Intent parentIntent = grandparent == null
                ? IntentCompat.makeMainActivity(target)
                : new Intent().setComponent(target);
        return parentIntent;
    } catch (NameNotFoundException e) {
        Log.e(TAG, "getParentActivityIntent: bad parentActivityName '" + parentName +
                "' in manifest");
        return null;
    }
}
项目:guideshow    文件:TaskStackBuilder.java   
/**
 * Start the task stack constructed by this builder. The Context used to obtain
 * this builder must be an Activity.
 *
 * <p>On devices that do not support API level 11 or higher the topmost activity
 * will be started as a new task. On devices that do support API level 11 or higher
 * the new task stack will be created in its entirety.</p>
 *
 * @param options Additional options for how the Activity should be started.
 * See {@link android.content.Context#startActivity(Intent, Bundle)
 */
public void startActivities(Bundle options) {
    if (mIntents.isEmpty()) {
        throw new IllegalStateException(
                "No intents added to TaskStackBuilder; cannot startActivities");
    }

    Intent[] intents = mIntents.toArray(new Intent[mIntents.size()]);
    intents[0] = new Intent(intents[0]).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
            IntentCompat.FLAG_ACTIVITY_CLEAR_TASK |
            IntentCompat.FLAG_ACTIVITY_TASK_ON_HOME);
    if (!ContextCompat.startActivities(mSourceContext, intents, options)) {
        Intent topIntent = new Intent(intents[intents.length - 1]);
        topIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        mSourceContext.startActivity(topIntent);
    }
}
项目:guideshow    文件:NavUtils.java   
@Override
public Intent getParentActivityIntent(Activity activity) {
    String parentName = NavUtils.getParentActivityName(activity);
    if (parentName == null) return null;

    // If the parent itself has no parent, generate a main activity intent.
    final ComponentName target = new ComponentName(activity, parentName);
    try {
        final String grandparent = NavUtils.getParentActivityName(activity, target);
        final Intent parentIntent = grandparent == null
                ? IntentCompat.makeMainActivity(target)
                : new Intent().setComponent(target);
        return parentIntent;
    } catch (NameNotFoundException e) {
        Log.e(TAG, "getParentActivityIntent: bad parentActivityName '" + parentName +
                "' in manifest");
        return null;
    }
}
项目:secrecy    文件:SettingsFragment.java   
private void confirm_stealth(String password) {
    final View dialogView = View.inflate(context, R.layout.dialog_confirm_stealth, null);
    ((TextView) dialogView
            .findViewById(R.id.stealth_keycode))
            .append(password);
    new AlertDialog.Builder(context)
            .setInverseBackgroundForced(true)
            .setView(dialogView)
            .setMessage(R.string.Settings__try_once_before_hide)
            .setPositiveButton(getString(R.string.OK), new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    SharedPreferences.Editor editor
                            = PreferenceManager.getDefaultSharedPreferences(context).edit();
                    editor.putBoolean(Config.SHOW_STEALTH_MODE_TUTORIAL, true);
                    editor.apply();
                    Intent dial = new Intent();
                    dial.setAction("android.intent.action.DIAL");
                    dial.setData(Uri.parse("tel:"));
                    dial.setFlags(IntentCompat.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
                    startActivity(dial);
                    getActivity().finish();
                }
            })
            .show();
}
项目:secrecy    文件:OutgoingCallReceiver.java   
@Override
public void onReceive(final Context context, Intent intent) {

    // Gets the intent, check if it matches our secret code
    if (Intent.ACTION_NEW_OUTGOING_CALL.equals(intent.getAction()) &&
            intent.getExtras() != null) {
        Intent launcher = new Intent(context, MainActivity.class);
        //These flags are added to make the new mainActivity in the home stack.
        //i.e. back button returns to home not dialer.
        launcher.addFlags(IntentCompat.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK | IntentCompat.FLAG_ACTIVITY_TASK_ON_HOME);
        String phoneNumber = intent.getExtras().getString(android.content.Intent.EXTRA_PHONE_NUMBER);
        String openPin = PreferenceManager.getDefaultSharedPreferences(context)
                .getString(Config.STEALTH_MODE_PASSWORD, "");
        if (!openPin.equals("")) {
            if (("*#" + openPin).equals(phoneNumber)) {
                // Launch the main app!!
                launchActivity(context, launcher);
            }
        }
    }
}
项目:IntranetEpitechV2    文件:TaskStackBuilder.java   
/**
 * Start the task stack constructed by this builder. The Context used to obtain
 * this builder must be an Activity.
 *
 * <p>On devices that do not support API level 11 or higher the topmost activity
 * will be started as a new task. On devices that do support API level 11 or higher
 * the new task stack will be created in its entirety.</p>
 *
 * @param options Additional options for how the Activity should be started.
 * See {@link android.content.Context#startActivity(Intent, Bundle)
 */
public void startActivities(Bundle options) {
    if (mIntents.isEmpty()) {
        throw new IllegalStateException(
                "No intents added to TaskStackBuilder; cannot startActivities");
    }

    Intent[] intents = mIntents.toArray(new Intent[mIntents.size()]);
    intents[0] = new Intent(intents[0]).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
            IntentCompat.FLAG_ACTIVITY_CLEAR_TASK |
            IntentCompat.FLAG_ACTIVITY_TASK_ON_HOME);
    if (!ContextCompat.startActivities(mSourceContext, intents, options)) {
        Intent topIntent = new Intent(intents[intents.length - 1]);
        topIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        mSourceContext.startActivity(topIntent);
    }
}
项目:IntranetEpitechV2    文件:NavUtils.java   
@Override
public Intent getParentActivityIntent(Activity activity) {
    String parentName = NavUtils.getParentActivityName(activity);
    if (parentName == null) return null;

    // If the parent itself has no parent, generate a main activity intent.
    final ComponentName target = new ComponentName(activity, parentName);
    try {
        final String grandparent = NavUtils.getParentActivityName(activity, target);
        final Intent parentIntent = grandparent == null
                ? IntentCompat.makeMainActivity(target)
                : new Intent().setComponent(target);
        return parentIntent;
    } catch (NameNotFoundException e) {
        Log.e(TAG, "getParentActivityIntent: bad parentActivityName '" + parentName +
                "' in manifest");
        return null;
    }
}