Example usage for android.content Intent setFlags

List of usage examples for android.content Intent setFlags

Introduction

In this page you can find the example usage for android.content Intent setFlags.

Prototype

public @NonNull Intent setFlags(@Flags int flags) 

Source Link

Document

Set special flags controlling how this intent is handled.

Usage

From source file:fm.smart.r1.activity.CreateItemActivity.java

public void onClick(View v) {
    EditText cueInput = (EditText) findViewById(R.id.cue);
    EditText responseInput = (EditText) findViewById(R.id.response);
    Spinner posInput = (Spinner) findViewById(R.id.pos);
    EditText characterResponseInput = (EditText) findViewById(R.id.response_character);
    EditText characterCueInput = (EditText) findViewById(R.id.cue_character);
    final String cue = cueInput.getText().toString();
    final String response = responseInput.getText().toString();
    final String pos = posInput.getSelectedItem().toString();
    final String character_cue = characterCueInput.getText().toString();
    final String character_response = characterResponseInput.getText().toString();
    String pos_code = Utils.POS_MAP.get(pos);
    if (TextUtils.isEmpty(pos_code)) {
        pos_code = "NONE";
    }/*from  w w w . j  a  v a  2s. c  om*/
    final String final_pos_code = pos_code;

    if (Main.isNotLoggedIn(this)) {
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setClassName(this, LoginActivity.class.getName());
        intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); // avoid
        // navigation
        // back to this?
        LoginActivity.return_to = CreateItemActivity.class.getName();
        LoginActivity.params = new HashMap<String, String>();
        LoginActivity.params.put("list_id", list_id);
        LoginActivity.params.put("cue", cue);
        LoginActivity.params.put("response", response);
        LoginActivity.params.put("cue_language", cue_language);
        LoginActivity.params.put("response_language", response_language);
        LoginActivity.params.put("pos", pos);
        LoginActivity.params.put("character_cue", character_cue);
        LoginActivity.params.put("character_response", character_response);
        startActivity(intent);
    } else {
        // TODO cue and response languages need to be inferred from list we are
        // adding to ... Might want to fix those, i.e. not allow variation
        // on
        // search ...
        // TODO wondering whether there is some way to edit existing items
        // ...

        final ProgressDialog myOtherProgressDialog = new ProgressDialog(this);
        myOtherProgressDialog.setTitle("Please Wait ...");
        myOtherProgressDialog.setMessage("Creating Item ...");
        myOtherProgressDialog.setIndeterminate(true);
        myOtherProgressDialog.setCancelable(true);

        final Thread create_item = new Thread() {
            public void run() {
                // TODO make this interruptable .../*if
                // (!this.isInterrupted())*/
                CreateItemActivity.create_item_result = createItem(cue, cue_language, character_cue,
                        final_pos_code, response, response_language, character_response, list_id);

                myOtherProgressDialog.dismiss();

            }
        };
        myOtherProgressDialog.setButton("Cancel", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                create_item.interrupt();
            }
        });
        OnCancelListener ocl = new OnCancelListener() {
            public void onCancel(DialogInterface arg0) {
                create_item.interrupt();
            }
        };
        myOtherProgressDialog.setOnCancelListener(ocl);
        myOtherProgressDialog.show();
        create_item.start();
    }
}

From source file:com.polyvi.xface.extension.XTelephonyExt.java

/**
 * ???//from  w  w  w.  j a va2 s  .c om
 *
 * @param[in] phoneNumber ????
 * @return ???
 * */
private boolean initiateVoiceCall(String phoneNumber) {
    try {
        if (isLegalPhoneNum(phoneNumber)) {
            Intent intent = new Intent(Intent.ACTION_CALL);
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            intent.setData(Uri.parse(WebView.SCHEME_TEL + phoneNumber));
            getContext().startActivity(intent);
            return true;
        }
    } catch (ActivityNotFoundException e) {
        XLog.e(CLASS_NAME, e.toString());
    } catch (SecurityException e) {
        XLog.e(CLASS_NAME, e.toString());
    }
    return false;
}

From source file:org.zywx.wbpalmstar.engine.EDownloadDialog.java

private void downloadDone() {
    stopDownload();/*  w  w w . ja v a2s.  com*/
    Intent installIntent = new Intent(Intent.ACTION_VIEW);
    String filename = mTmpFile.getAbsolutePath();
    Uri path = Uri.parse(filename);
    if (path.getScheme() == null) {
        path = Uri.fromFile(new File(filename));
    }
    installIntent.setDataAndType(path, mimetype);
    installIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    try {
        getContext().startActivity(installIntent);
    } catch (Exception e) {
        e.printStackTrace();
        mProgressHandler.sendMessage(mProgressHandler.obtainMessage(-2, "?"));
    }
}

From source file:com.android.nobadgift.DashboardActivity.java

/**
 * Go back to the home activity.// w w w. ja  v a2 s.  com
 * 
 * @param context Context
 * @return void
 */

public void goHome(Context context) {
    final Intent intent = new Intent(context, HomeActivity.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    context.startActivity(intent);
}

From source file:com.synchophy.ui.CoverFlowActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    Intent i = null;

    switch (item.getItemId()) {

    case BrowseActivity.MAIN:
        i = new Intent(this, MainMenuActivity.class);
        i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(i);/*w  ww .  j av a 2 s .com*/
        return true;
    case BrowseActivity.PLAYLIST:
        i = new Intent(this, PlaylistActivity.class);
        startActivityForResult(i, BrowseActivity.PLAYLIST);
        return true;
    case BrowseActivity.FILTER:
        PlayerManager.setFiltering(!PlayerManager.isFiltering());
        refresh();
        return true;
    }
    return false;
}

From source file:de.unclenet.dehabewe.CalendarActivity.java

private void gotAccount(final AccountManager manager, final Account account) {
    SharedPreferences settings = getSharedPreferences(PREF, 0);
    SharedPreferences.Editor editor = settings.edit();
    editor.putString("accountName", account.name);
    editor.commit();//from  w w w .  java2  s. c o  m
    new Thread() {

        @Override
        public void run() {
            try {
                final Bundle bundle = manager.getAuthToken(account, AUTH_TOKEN_TYPE, true, null, null)
                        .getResult();
                runOnUiThread(new Runnable() {

                    public void run() {
                        try {
                            if (bundle.containsKey(AccountManager.KEY_INTENT)) {
                                Intent intent = bundle.getParcelable(AccountManager.KEY_INTENT);
                                int flags = intent.getFlags();
                                flags &= ~Intent.FLAG_ACTIVITY_NEW_TASK;
                                intent.setFlags(flags);
                                startActivityForResult(intent, REQUEST_AUTHENTICATE);
                            } else if (bundle.containsKey(AccountManager.KEY_AUTHTOKEN)) {
                                authenticatedClientLogin(bundle.getString(AccountManager.KEY_AUTHTOKEN));
                            }
                        } catch (Exception e) {
                            handleException(e);
                        }
                    }
                });
            } catch (Exception e) {
                handleException(e);
            }
        }
    }.start();
}

From source file:org.ohmage.sync.OhmageSyncAdapter.java

private void showInstallApkNotification(int id, Builder builder, Intent intent) {
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    PendingIntent resultPendingIntent = PendingIntent.getActivity(getContext(), 0, intent,
            PendingIntent.FLAG_UPDATE_CURRENT);
    builder.setContentIntent(resultPendingIntent).setAutoCancel(true).setDefaults(Notification.DEFAULT_ALL);

    NotificationManager mNotificationManager = (NotificationManager) getContext()
            .getSystemService(Context.NOTIFICATION_SERVICE);
    mNotificationManager.notify(id, builder.build());
}

From source file:fm.smart.r1.activity.CreateExampleActivity.java

public void onClick(View v) {
    EditText exampleInput = (EditText) findViewById(R.id.create_example_sentence);
    EditText translationInput = (EditText) findViewById(R.id.create_example_translation);
    EditText exampleTransliterationInput = (EditText) findViewById(R.id.sentence_transliteration);
    EditText translationTransliterationInput = (EditText) findViewById(R.id.translation_transliteration);
    final String example = exampleInput.getText().toString();
    final String translation = translationInput.getText().toString();
    if (TextUtils.isEmpty(example) || TextUtils.isEmpty(translation)) {
        Toast t = Toast.makeText(this, "Example and translation are required fields", 150);
        t.setGravity(Gravity.CENTER, 0, 0);
        t.show();//  w  ww.  j  a  va2 s.c o m
    } else {
        final String example_language_code = Utils.LANGUAGE_MAP.get(example_language);
        final String translation_language_code = Utils.LANGUAGE_MAP.get(translation_language);
        final String example_transliteration = exampleTransliterationInput.getText().toString();
        final String translation_transliteration = translationTransliterationInput.getText().toString();

        if (Main.isNotLoggedIn(this)) {
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setClassName(this, LoginActivity.class.getName());
            intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); // avoid
            // navigation
            // back to this?
            LoginActivity.return_to = CreateExampleActivity.class.getName();
            LoginActivity.params = new HashMap<String, String>();
            LoginActivity.params.put("list_id", list_id);
            LoginActivity.params.put("item_id", item_id);
            LoginActivity.params.put("example", example);
            LoginActivity.params.put("translation", translation);
            LoginActivity.params.put("example_language", example_language);
            LoginActivity.params.put("translation_language", translation_language);
            LoginActivity.params.put("example_transliteration", example_transliteration);
            LoginActivity.params.put("translation_transliteration", translation_transliteration);
            startActivity(intent);
        } else {

            final ProgressDialog myOtherProgressDialog = new ProgressDialog(this);
            myOtherProgressDialog.setTitle("Please Wait ...");
            myOtherProgressDialog.setMessage("Creating Example ...");
            myOtherProgressDialog.setIndeterminate(true);
            myOtherProgressDialog.setCancelable(true);

            final Thread create_example = new Thread() {
                public void run() {
                    // TODO make this interruptable .../*if
                    // (!this.isInterrupted())*/
                    try {
                        // TODO failures here could derail all ...
                        CreateExampleActivity.add_item_list_result = ItemActivity.addItemToList(list_id,
                                item_id, CreateExampleActivity.this);
                        CreateExampleActivity.create_example_result = createExample(example,
                                example_language_code, example_transliteration, translation,
                                translation_language_code, translation_transliteration, item_id, list_id);
                        CreateExampleActivity.add_sentence_list_result = ItemActivity.addSentenceToList(
                                CreateExampleActivity.create_example_result.http_response, item_id, list_id,
                                CreateExampleActivity.this);
                    } catch (Exception e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }

                    myOtherProgressDialog.dismiss();

                }
            };
            myOtherProgressDialog.setButton("Cancel", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    create_example.interrupt();
                }
            });
            OnCancelListener ocl = new OnCancelListener() {
                public void onCancel(DialogInterface arg0) {
                    create_example.interrupt();
                }
            };
            myOtherProgressDialog.setOnCancelListener(ocl);
            myOtherProgressDialog.show();
            create_example.start();
        }
    }
}

From source file:com.felkertech.n.cumulustv.activities.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Log.d(TAG, "onCreate");
    sm = new DriveSettingsManager(this);
    ActivityUtils.openIntroIfNeeded(this);
    final ChannelDatabase channelDatabase = ChannelDatabase.getInstance(MainActivity.this);
    Fabric.with(this, new Crashlytics());
    if (AppUtils.isTV(this)) {
        // Go to tv activity
        Intent leanbackIntent = new Intent(this, LeanbackActivity.class);
        leanbackIntent.setFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME);
        startActivity(leanbackIntent);//from w w  w.j a v a  2s.  co  m
    }

    findViewById(R.id.add).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ActivityUtils.openPluginPicker(true, MainActivity.this);
        }
    });
    findViewById(R.id.view).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            String[] channelnames = channelDatabase.getChannelNames();
            if (channelnames.length == 0) {
                new MaterialDialog.Builder(MainActivity.this).title(R.string.no_channels)
                        .content(R.string.no_channels_find).positiveText(R.string.ok).negativeText(R.string.no)
                        .callback(new MaterialDialog.ButtonCallback() {
                            @Override
                            public void onPositive(MaterialDialog dialog) {
                                super.onPositive(dialog);
                                dialog.cancel();
                                findViewById(R.id.suggested).performClick();
                            }
                        }).show();
            } else {
                try {
                    displayChannelPicker(channelDatabase.getJsonChannels(), channelnames);
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
        }
    });
    findViewById(R.id.view_genres).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            // Generate genres
            Set<String> genreSet = new HashSet<>();
            try {
                for (JsonChannel jsonChannel : channelDatabase.getJsonChannels()) {
                    Collections.addAll(genreSet, jsonChannel.getGenres());
                }
                final String[] genreArray = genreSet.toArray(new String[genreSet.size()]);
                new MaterialDialog.Builder(MainActivity.this).title(R.string.select_genres).items(genreArray)
                        .itemsCallback(new MaterialDialog.ListCallback() {
                            @Override
                            public void onSelection(MaterialDialog dialog, View itemView, int position,
                                    CharSequence text) {
                                // Now only get certain channels
                                String selectedGenre = genreArray[position];
                                List<JsonChannel> jsonChannelList = new ArrayList<>();
                                List<String> channelNames = new ArrayList<>();
                                try {
                                    for (JsonChannel jsonChannel : channelDatabase.getJsonChannels()) {
                                        if (jsonChannel.getGenresString().contains(selectedGenre)) {
                                            jsonChannelList.add(jsonChannel);
                                            channelNames
                                                    .add(jsonChannel.getNumber() + " " + jsonChannel.getName());
                                        }
                                    }
                                    displayChannelPicker(jsonChannelList,
                                            channelNames.toArray(new String[channelNames.size()]),
                                            selectedGenre);
                                } catch (JSONException e) {
                                    e.printStackTrace();
                                }
                            }
                        }).show();
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
    });
    findViewById(R.id.suggested).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ActivityUtils.openSuggestedChannels(MainActivity.this, gapi);
        }
    });
    findViewById(R.id.gdrive).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            gapi = ActivityUtils.GoogleDrive.connect(MainActivity.this);
        }
    });
    findViewById(R.id.more_actions).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            moreClick();
        }
    });
}