List of usage examples for android.content Intent addFlags
public @NonNull Intent addFlags(@Flags int flags)
From source file:cw.kop.autobackground.sources.SourceListFragment.java
/** * Saves data in list and sends Intent to cycle wallpaper *///from w ww . j av a 2 s . com private void cycleWallpaper() { listAdapter.saveData(); Intent intent = new Intent(); intent.setAction(LiveWallpaperService.CYCLE_IMAGE); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); appContext.sendBroadcast(intent); }
From source file:com.synox.android.ui.activity.FileActivity.java
public void restart() { Intent i = new Intent(this, FileDisplayActivity.class); i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(i);//from w w w. java2 s. c om }
From source file:com.xgf.inspection.qrcode.google.zxing.client.CaptureActivity.java
/** * We want the help screen to be shown automatically the first time a new * version of the app is run. The easiest way to do this is to check * android:versionCode from the manifest, and compare it to a value stored * as a preference.//from w ww .j a v a2 s.c o m */ private boolean showHelpOnFirstLaunch() { try { PackageInfo info = getPackageManager().getPackageInfo(PACKAGE_NAME, 0); int currentVersion = info.versionCode; SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); int lastVersion = prefs.getInt(PreferencesActivity.KEY_HELP_VERSION_SHOWN, 0); if (currentVersion > lastVersion) { prefs.edit().putInt(PreferencesActivity.KEY_HELP_VERSION_SHOWN, currentVersion).commit(); Intent intent = new Intent(this, HelpActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); // Show the default page on a clean install, and the what's new // page on an upgrade. String page = lastVersion == 0 ? HelpActivity.DEFAULT_PAGE : HelpActivity.WHATS_NEW_PAGE; intent.putExtra(HelpActivity.REQUESTED_PAGE_KEY, page); startActivity(intent); return true; } } catch (PackageManager.NameNotFoundException e) { Log.w(TAG, e); } return false; }
From source file:cw.kop.autobackground.sources.SourceListFragment.java
/** * Starts (or stops) download and sets download icon appropriately */// ww w . ja v a2 s .co m private void startDownload() { listAdapter.saveData(); if (FileHandler.isDownloading) { DialogFactory.ActionDialogListener listener = new DialogFactory.ActionDialogListener() { @Override public void onClickRight(View v) { FileHandler.cancel(appContext); resetActionBarDownload(); dismissDialog(); } }; DialogFactory.showActionDialog(appContext, "", "Cancel download?", listener, -1, R.string.cancel_button, R.string.ok_button); } else if (FileHandler.download(appContext)) { Drawable drawable = getResources().getDrawable(R.drawable.ic_cancel_white_24dp); drawable.setColorFilter(AppSettings.getColorFilterInt(appContext), PorterDuff.Mode.MULTIPLY); toolbarMenu.getItem(1).setIcon(drawable); if (AppSettings.resetOnManualDownload() && AppSettings.useTimer() && AppSettings.getTimerDuration() > 0) { Intent intent = new Intent(); intent.setAction(LiveWallpaperService.DOWNLOAD_WALLPAPER); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); PendingIntent pendingIntent = PendingIntent.getBroadcast(appContext, 0, intent, 0); AlarmManager alarmManager = (AlarmManager) appContext.getSystemService(Context.ALARM_SERVICE); alarmManager.cancel(pendingIntent); alarmManager.setInexactRepeating(AlarmManager.RTC, System.currentTimeMillis() + AppSettings.getTimerDuration(), AppSettings.getTimerDuration(), pendingIntent); } } }
From source file:com.xgf.inspection.qrcode.google.zxing.client.CaptureActivity.java
private void handleDecodeExternally(Result rawResult, ResultHandler resultHandler, Bitmap barcode) { if (barcode != null) { viewfinderView.drawResultBitmap(barcode); }// w w w .j ava 2 s. com long resultDurationMS; if (getIntent() == null) { resultDurationMS = DEFAULT_INTENT_RESULT_DURATION_MS; } else { resultDurationMS = getIntent().getLongExtra(Intents.Scan.RESULT_DISPLAY_DURATION_MS, DEFAULT_INTENT_RESULT_DURATION_MS); } // Since this message will only be shown for a second, just tell the // user what kind of // barcode was found (e.g. contact info) rather than the full contents, // which they won't // have time to read. if (resultDurationMS > 0) { statusView.setText(getString(resultHandler.getDisplayTitle())); } if (copyToClipboard && !resultHandler.areContentsSecure()) { ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); CharSequence text = resultHandler.getDisplayContents(); if (text != null) { clipboard.setText(text); } } if (source == IntentSource.NATIVE_APP_INTENT) { // Hand back whatever action they requested - this can be changed to // Intents.Scan.ACTION when // the deprecated intent is retired. Intent intent = new Intent(getIntent().getAction()); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); intent.putExtra(Intents.Scan.RESULT, rawResult.toString()); intent.putExtra(Intents.Scan.RESULT_FORMAT, rawResult.getBarcodeFormat().toString()); byte[] rawBytes = rawResult.getRawBytes(); if (rawBytes != null && rawBytes.length > 0) { intent.putExtra(Intents.Scan.RESULT_BYTES, rawBytes); } Map<ResultMetadataType, ?> metadata = rawResult.getResultMetadata(); if (metadata != null) { if (metadata.containsKey(ResultMetadataType.UPC_EAN_EXTENSION)) { intent.putExtra(Intents.Scan.RESULT_UPC_EAN_EXTENSION, metadata.get(ResultMetadataType.UPC_EAN_EXTENSION).toString()); } Integer orientation = (Integer) metadata.get(ResultMetadataType.ORIENTATION); if (orientation != null) { intent.putExtra(Intents.Scan.RESULT_ORIENTATION, orientation.intValue()); } String ecLevel = (String) metadata.get(ResultMetadataType.ERROR_CORRECTION_LEVEL); if (ecLevel != null) { intent.putExtra(Intents.Scan.RESULT_ERROR_CORRECTION_LEVEL, ecLevel); } Iterable<byte[]> byteSegments = (Iterable<byte[]>) metadata.get(ResultMetadataType.BYTE_SEGMENTS); if (byteSegments != null) { int i = 0; for (byte[] byteSegment : byteSegments) { intent.putExtra(Intents.Scan.RESULT_BYTE_SEGMENTS_PREFIX + i, byteSegment); i++; } } } sendReplyMessage(R.id.return_scan_result, intent, resultDurationMS); } else if (source == IntentSource.PRODUCT_SEARCH_LINK) { // Reformulate the URL which triggered us into a query, so that the // request goes to the same // TLD as the scan URL. int end = sourceUrl.lastIndexOf("/scan"); String replyURL = sourceUrl.substring(0, end) + "?q=" + resultHandler.getDisplayContents() + "&source=zxing"; sendReplyMessage(R.id.launch_product_query, replyURL, resultDurationMS); } else if (source == IntentSource.ZXING_LINK) { // Replace each occurrence of RETURN_CODE_PLACEHOLDER in the // returnUrlTemplate // with the scanned code. This allows both queries and REST-style // URLs to work. if (returnUrlTemplate != null) { CharSequence codeReplacement = returnRaw ? rawResult.getText() : resultHandler.getDisplayContents(); try { codeReplacement = URLEncoder.encode(codeReplacement.toString(), "UTF-8"); } catch (UnsupportedEncodingException e) { // can't happen; UTF-8 is always supported. Continue, I // guess, without encoding } String replyURL = returnUrlTemplate.replace(RETURN_CODE_PLACEHOLDER, codeReplacement); sendReplyMessage(R.id.launch_product_query, replyURL, resultDurationMS); } } }
From source file:com.intel.xdk.device.Device.java
public void sendSMS(String body, String to) { Uri uri = Uri.parse("smsto:" + to); Intent intent = new Intent(Intent.ACTION_SENDTO, uri); intent.putExtra("sms_body", body); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); activity.startActivity(intent);/*from ww w . j a v a 2s .co m*/ }
From source file:com.kncwallet.wallet.ui.WalletActivity.java
private void checkPin() { if (prefs.getBoolean(Constants.PREFS_KEY_APP_PIN_ENABLED, false)) { if (!prefs.getBoolean(Constants.PREFS_KEY_APP_PIN_AUTHORIZED, false)) { Intent pinIntent = new Intent(this, PinEntryActivity.class); pinIntent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); startActivity(pinIntent);/*from w ww . j a v a 2 s . co m*/ } } }
From source file:com.orange.labs.sdk.session.AuthSession.java
/** * Start authentication. If needed, launch {@code AuthActivity} * allowing an user authentication else wait to check authentication with refresh token * {@link #checkAuthentication(com.orange.labs.sdk.OrangeListener.Success, * com.orange.labs.sdk.OrangeListener.Error)} *//*w ww . ja v a 2s .c o m*/ public void startAuthentication() { String refreshToken = getRefreshToken(); // If refresh token exists, connect directly else // show web authent inside AuthActivity if (refreshToken == null || refreshToken.length() == 0) { // Start Orange auth activity. Intent intent = new Intent(context, AuthActivity.class); // Check if Oauth has to force user to enter login & password SharedPreferences sharedPref = context.getApplicationContext() .getSharedPreferences(SHARED_PREFERENCES_KEY, Context.MODE_PRIVATE); boolean forceLogin = sharedPref.getBoolean(SHARED_PREFERENCES_FORCE_LOGIN, false); intent.putExtra(AuthActivity.EXTRA_INTERNAL_APP_FORCE_LOGIN, forceLogin); intent.putExtra(AuthActivity.EXTRA_INTERNAL_APP_KEY, getAppkey()); intent.putExtra(AuthActivity.EXTRA_INTERNAL_APP_SCOPE, getScope()); intent.putExtra(AuthActivity.EXTRA_INTERNAL_APP_REDIRECT_URI, getRedirectUri()); if (!(context instanceof Activity)) { // If starting the intent outside of an Activity, must include // this. See startActivity(). Otherwise, we prefer to stay in // the same task. intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); } context.startActivity(intent); } }
From source file:de.appplant.cordova.emailcomposer.EmailComposerImpl.java
/** * The intent with the containing email properties. * * @param params// www . j a va2s . c o m * The email properties like subject or body * @param ctx * The context of the application. * @return * The resulting intent. * @throws JSONException */ public Intent getDraftWithProperties(JSONObject params, Context ctx) throws JSONException { Intent mail = new Intent(Intent.ACTION_SEND_MULTIPLE); String app = params.optString("app", null); if (params.has("subject")) setSubject(params.getString("subject"), mail); if (params.has("body")) setBody(params.getString("body"), params.optBoolean("isHtml"), mail); if (params.has("to")) setRecipients(params.getJSONArray("to"), mail); if (params.has("cc")) setCcRecipients(params.getJSONArray("cc"), mail); if (params.has("bcc")) setBccRecipients(params.getJSONArray("bcc"), mail); if (params.has("attachments")) setAttachments(params.getJSONArray("attachments"), mail, ctx); if (!app.equals(MAILTO_SCHEME) && isAppInstalled(app, ctx)) { mail.setPackage(app); } mail.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); return mail; }
From source file:com.irccloud.android.activity.LoginActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == REQUEST_RESOLVE_ERROR) { mResolvingError = false;/*from ww w.ja v a2 s . c o m*/ if (resultCode == RESULT_OK) { if (!mGoogleApiClient.isConnecting() && !mGoogleApiClient.isConnected()) { mGoogleApiClient.connect(); } } } else if (requestCode == REQUEST_RESOLVE_CREDENTIALS) { if (resultCode == RESULT_OK && data.hasExtra(Credential.EXTRA_KEY)) { Credential c = data.getParcelableExtra(Credential.EXTRA_KEY); name.setText(c.getName()); email.setText(c.getId()); password.setText(c.getPassword()); loading.setVisibility(View.GONE); login.setVisibility(View.VISIBLE); loginHintClickListener.onClick(null); new LoginTask().execute((Void) null); } else { loading.setVisibility(View.GONE); login.setVisibility(View.VISIBLE); } } else if (requestCode == REQUEST_RESOLVE_SAVE_CREDENTIALS) { if (resultCode == RESULT_OK) { Log.e("IRCCloud", "Credentials result: OK"); } Intent i = new Intent(LoginActivity.this, MainActivity.class); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) i.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); if (getIntent() != null) { if (getIntent().getData() != null) i.setData(getIntent().getData()); if (getIntent().getExtras() != null) i.putExtras(getIntent().getExtras()); } startActivity(i); finish(); } }