List of usage examples for android.content Intent setFlags
public @NonNull Intent setFlags(@Flags int flags)
From source file:com.mikecorrigan.bohrium.pubsub.RegistrationClient.java
@SafeVarargs private final void handleAuthToken(AccountManagerFuture<Bundle>... tokens) { Log.v(TAG, "handleAuthToken"); try {/* w w w .ja v a 2 s.c om*/ Bundle result = tokens[0].getResult(); Intent intent = (Intent) result.get(AccountManager.KEY_INTENT); if (intent != null) { Log.i(TAG, "Launch activity before getting authToken: intent=" + intent); setStateAndNotify(REGISTRATION_STATE_REGISTERING, REGISTRATION_SUBSTATE_PROMPTING_USER); intent.setFlags(intent.getFlags() & ~Intent.FLAG_ACTIVITY_NEW_TASK); notifyLaunchIntent(intent); return; } String authToken = result.getString(AccountManager.KEY_AUTHTOKEN); if (mNeedInvalidate) { mNeedInvalidate = false; Log.i(TAG, "Invalidating token and starting over."); // Invalidate auth token. AccountManager mgr = AccountManager.get(this); mgr.invalidateAuthToken(mConfiguration.getString(ACCOUNT_TYPE, DEFAULT_ACCOUNT_TYPE), authToken); setStateAndNotify(REGISTRATION_STATE_REGISTERING, REGISTRATION_SUBSTATE_INVALIDATED_AUTH_TOKEN); // Initiate the request again. requestAuthToken(); return; } else { Log.i(TAG, "Received authToken=" + authToken); mConfiguration.putString(AUTH_TOKEN, authToken); setStateAndNotify(REGISTRATION_STATE_REGISTERING, REGISTRATION_SUBSTATE_HAVE_AUTH_TOKEN); // Move on to the next step, request auth cookie. requestAuthCookie(); return; } } catch (Exception e) { Log.e(TAG, "Exception " + e); Log.e(TAG, Log.getStackTraceString(e)); } setStateAndNotify(REGISTRATION_STATE_ERROR, REGISTRATION_SUBSTATE_ERROR_AUTH_TOKEN); }
From source file:com.bonsai.wallet32.WalletService.java
private void showStatusNotification() { CharSequence started_txt = getText(R.string.wallet_service_started); CharSequence info_txt = getText(R.string.wallet_service_info); Notification note = new Notification(R.drawable.ic_stat_notify, started_txt, System.currentTimeMillis()); Intent intent = new Intent(this, MainActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, intent, 0); // Set the info for the views that show in the notification panel. note.setLatestEventInfo(this, getText(R.string.wallet_service_label), info_txt, contentIntent); note.flags |= Notification.FLAG_NO_CLEAR; startForeground(NOTIFICATION, note); }
From source file:fr.cph.chicago.activity.BusBoundActivity.java
@Override public final void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); ChicagoTracker.checkBusData(this); if (!this.isFinishing()) { setContentView(R.layout.activity_bus_bound); if (mBusRouteId == null && mBusRouteName == null && mBound == null) { mBusRouteId = getIntent().getExtras().getString("busRouteId"); mBusRouteName = getIntent().getExtras().getString("busRouteName"); mBound = getIntent().getExtras().getString("bound"); }//w ww. ja v a2 s . c o m mAdapter = new BusBoundAdapter(mBusRouteId); setListAdapter(mAdapter); getListView().setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) { BusStop busStop = (BusStop) mAdapter.getItem(position); Intent intent = new Intent(ChicagoTracker.getAppContext(), BusActivity.class); Bundle extras = new Bundle(); extras.putInt("busStopId", busStop.getId()); extras.putString("busStopName", busStop.getName()); extras.putString("busRouteId", mBusRouteId); extras.putString("busRouteName", mBusRouteName); extras.putString("bound", mBound); extras.putDouble("latitude", busStop.getPosition().getLatitude()); extras.putDouble("longitude", busStop.getPosition().getLongitude()); intent.putExtras(extras); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); overridePendingTransition(R.anim.slide_in, R.anim.slide_out); } }); EditText filter = (EditText) findViewById(R.id.bus_filter); filter.addTextChangedListener(new TextWatcher() { List<BusStop> busStopsFiltered; @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { busStopsFiltered = new ArrayList<BusStop>(); } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { for (BusStop busStop : mBusStops) { if (StringUtils.containsIgnoreCase(busStop.getName(), s)) { this.busStopsFiltered.add(busStop); } } } @Override public void afterTextChanged(Editable s) { mAdapter.update(busStopsFiltered); mAdapter.notifyDataSetChanged(); } }); getActionBar().setDisplayHomeAsUpEnabled(true); new BusBoundAsyncTask().execute(); // Preventing keyboard from moving background when showing up getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); } }
From source file:com.amazonaws.mobileconnectors.pinpoint.targeting.notification.NotificationClient.java
private boolean openApp() { final Intent launchIntent = pinpointContext.getApplicationContext().getPackageManager() .getLaunchIntentForPackage(pinpointContext.getApplicationContext().getPackageName()); if (launchIntent == null) { log.error("Couldn't get app launch intent for campaign notification."); return false; }/*from w ww . j a v a2 s. co m*/ launchIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); launchIntent.setPackage(null); pinpointContext.getApplicationContext().startActivity(launchIntent); return true; }
From source file:com.aware.Aware.java
/** * Given a plugin's package name, fetch the context card for reuse. * @param context: application context/*from ww w. j av a2s .c o m*/ * @param package_name: plugin's package name * @return View for reuse (instance of LinearLayout) */ public static View getContextCard(final Context context, final String package_name) { if (!isClassAvailable(context, package_name, "ContextCard")) { return null; } String ui_class = package_name + ".ContextCard"; LinearLayout card = new LinearLayout(context); LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); card.setLayoutParams(params); card.setOrientation(LinearLayout.VERTICAL); try { Context packageContext = context.createPackageContext(package_name, Context.CONTEXT_INCLUDE_CODE | Context.CONTEXT_IGNORE_SECURITY); Class<?> fragment_loader = packageContext.getClassLoader().loadClass(ui_class); Object fragment = fragment_loader.newInstance(); Method[] allMethods = fragment_loader.getDeclaredMethods(); Method m = null; for (Method mItem : allMethods) { String mName = mItem.getName(); if (mName.contains("getContextCard")) { mItem.setAccessible(true); m = mItem; break; } } View ui = (View) m.invoke(fragment, packageContext); if (ui != null) { //Check if plugin has settings. If it does, tapping the card shows the settings if (isClassAvailable(context, package_name, "Settings")) { ui.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent open_settings = new Intent(); open_settings.setClassName(package_name, package_name + ".Settings"); open_settings.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(open_settings); } }); } //Set card look-n-feel ui.setBackgroundColor(Color.WHITE); ui.setPadding(20, 20, 20, 20); card.addView(ui); LinearLayout shadow = new LinearLayout(context); LayoutParams params_shadow = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); params_shadow.setMargins(0, 0, 0, 10); shadow.setBackgroundColor(context.getResources().getColor(R.color.card_shadow)); shadow.setMinimumHeight(5); shadow.setLayoutParams(params_shadow); card.addView(shadow); return card; } else { return null; } } catch (NameNotFoundException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (NullPointerException e) { e.printStackTrace(); } catch (InstantiationException e) { e.printStackTrace(); } return null; }
From source file:com.onesignal.OneSignal.java
private static void fireIntentFromNotificationOpen(Context inContext, JSONArray data) { PackageManager packageManager = inContext.getPackageManager(); boolean isCustom = false; Intent intent = new Intent().setAction("com.onesignal.NotificationOpened.RECEIVE") .setPackage(inContext.getPackageName()); List<ResolveInfo> resolveInfo = packageManager.queryBroadcastReceivers(intent, PackageManager.GET_INTENT_FILTERS); if (resolveInfo.size() > 0) { intent.putExtra("onesignal_data", data.toString()); inContext.sendBroadcast(intent); isCustom = true;/* w w w . j a v a 2 s . c o m*/ } // Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. resolveInfo = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); if (resolveInfo.size() > 0) { if (!isCustom) intent.putExtra("onesignal_data", data.toString()); isCustom = true; intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_NEW_TASK); inContext.startActivity(intent); } if (!isCustom) { try { ApplicationInfo ai = inContext.getPackageManager().getApplicationInfo(inContext.getPackageName(), PackageManager.GET_META_DATA); Bundle bundle = ai.metaData; String defaultStr = bundle.getString("com.onesignal.NotificationOpened.DEFAULT"); isCustom = "DISABLE".equals(defaultStr); } catch (Throwable t) { Log(LOG_LEVEL.ERROR, "", t); } } if (!isCustom) { Intent launchIntent = inContext.getPackageManager() .getLaunchIntentForPackage(inContext.getPackageName()); if (launchIntent != null) { launchIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_NEW_TASK); inContext.startActivity(launchIntent); } } }
From source file:eu.alefzero.owncloud.ui.fragment.FileDetailFragment.java
/** * Updates the view with all relevant details about that file. *///from w w w. j a va 2 s. c o m public void updateFileDetails() { if (mFile != null && mAccount != null && mLayout == R.layout.file_details_fragment) { Button downloadButton = (Button) getView().findViewById(R.id.fdDownloadBtn); // set file details setFilename(mFile.getFileName()); setFiletype(DisplayUtils.convertMIMEtoPrettyPrint(mFile.getMimetype())); setFilesize(mFile.getFileLength()); if (ocVersionSupportsTimeCreated()) { setTimeCreated(mFile.getCreationTimestamp()); } setTimeModified(mFile.getModificationTimestamp()); CheckBox cb = (CheckBox) getView().findViewById(R.id.fdKeepInSync); cb.setChecked(mFile.keepInSync()); if (mFile.getStoragePath() != null) { // Update preview if (mFile.getMimetype().startsWith("image/")) { BitmapLoader bl = new BitmapLoader(); bl.execute(new String[] { mFile.getStoragePath() }); } // Change download button to open button downloadButton.setText(R.string.filedetails_open); downloadButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { String storagePath = mFile.getStoragePath(); String encodedStoragePath = WebdavUtils.encodePath(storagePath); try { Intent i = new Intent(Intent.ACTION_VIEW); i.setDataAndType(Uri.parse("file://" + encodedStoragePath), mFile.getMimetype()); i.setFlags( Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); startActivity(i); } catch (Throwable t) { Log.e(TAG, "Fail when trying to open with the mimeType provided from the ownCloud server: " + mFile.getMimetype()); boolean toastIt = true; String mimeType = ""; try { Intent i = new Intent(Intent.ACTION_VIEW); mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension( storagePath.substring(storagePath.lastIndexOf('.') + 1)); if (mimeType != null && !mimeType.equals(mFile.getMimetype())) { i.setDataAndType(Uri.parse("file://" + encodedStoragePath), mimeType); i.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); startActivity(i); toastIt = false; } } catch (IndexOutOfBoundsException e) { Log.e(TAG, "Trying to find out MIME type of a file without extension: " + storagePath); } catch (ActivityNotFoundException e) { Log.e(TAG, "No activity found to handle: " + storagePath + " with MIME type " + mimeType + " obtained from extension"); } catch (Throwable th) { Log.e(TAG, "Unexpected problem when opening: " + storagePath, th); } finally { if (toastIt) { Toast.makeText(getActivity(), "There is no application to handle file " + mFile.getFileName(), Toast.LENGTH_SHORT).show(); } } } } }); } else { // Make download button effective downloadButton.setOnClickListener(this); } } }
From source file:com.ubuntuone.android.files.service.UpDownService.java
public void notifyRoamingSoAutoUploadDisabled() { final String title = "Roaming, Auto Upload disabled"; final String text = "To enable, change your settings."; Notification notification = new NotificationCompat.Builder(this).setOngoing(false) .setTicker("Roaming, Auto Upload disabled").setSmallIcon(R.drawable.stat_sys_upload_anim0) .setOnlyAlertOnce(true).setAutoCancel(true).getNotification(); final Intent intent = new Intent(UpDownService.this, PreferencesActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.putExtra(PreferencesActivity.AUTOUPLOAD_SCREEN, 1); final PendingIntent pi = PendingIntent.getActivity(getApplicationContext(), REQUEST_AUTOUPLOAD_SCREEN, intent, 0);/*from w w w. jav a 2 s . c o m*/ notification.setLatestEventInfo(UpDownService.this, title, text, pi); notificationManager.notify(R.id.stat_roaming_autoupload_off_id, notification); }
From source file:com.ubuntuone.android.files.service.UpDownService.java
private synchronized void showFailedTransfersNotification(int failed) { String title = "Ubuntu One"; Resources r = getResources(); String text = r.getQuantityString(R.plurals.failed_to_upload_n_files, failed, failed); final Intent intent = new Intent(UpDownService.this, PreferencesActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.putExtra(PreferencesActivity.SHOW_RETRY_FAILED, 1); final PendingIntent pi = PendingIntent.getActivity(getApplicationContext(), REQUEST_RETRY_SCREEN, intent, 0);/*from ww w.j a v a 2s .c om*/ Notification notification = new NotificationCompat.Builder(this).setOngoing(false).setTicker(title) .setSmallIcon(R.drawable.stat_u1_logo).setOnlyAlertOnce(true).setAutoCancel(true).getNotification(); notification.setLatestEventInfo(this, title, text, pi); notificationManager.notify(R.id.stat_failed_upload_id, notification); }
From source file:id.zelory.tanipedia.activity.CuacaActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_cuaca); toolbar = (Toolbar) findViewById(R.id.anim_toolbar); setSupportActionBar(toolbar);/*from w ww . j a va 2 s .c o m*/ getSupportActionBar().setDisplayHomeAsUpEnabled(true); collapsingToolbar = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar); animation = AnimationUtils.loadAnimation(this, R.anim.simple_grow); drawerLayout = (DrawerLayout) findViewById(R.id.nav_drawer); setUpNavDrawer(); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); TextView nama = (TextView) navigationView.findViewById(R.id.nama); nama.setText(PrefUtils.ambilString(this, "nama")); TextView email = (TextView) navigationView.findViewById(R.id.email); email.setText(PrefUtils.ambilString(this, "email")); navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() { @Override public boolean onNavigationItemSelected(MenuItem menuItem) { menuItem.setChecked(true); drawerLayout.closeDrawers(); Intent intent; switch (menuItem.getItemId()) { case R.id.cuaca: return true; case R.id.berita: intent = new Intent(CuacaActivity.this, BeritaActivity.class); break; case R.id.tanya: intent = new Intent(CuacaActivity.this, TanyaActivity.class); break; case R.id.harga: intent = new Intent(CuacaActivity.this, KomoditasActivity.class); break; case R.id.logout: PrefUtils.simpanString(CuacaActivity.this, "nama", null); intent = new Intent(CuacaActivity.this, LoginActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); startActivity(intent); return true; case R.id.tentang: intent = new Intent(CuacaActivity.this, TentangActivity.class); startActivity(intent); return true; default: return true; } startActivity(intent); finish(); return true; } }); recyclerView = (RecyclerView) findViewById(R.id.scrollableview); recyclerView.setHasFixedSize(true); LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this); recyclerView.setLayoutManager(linearLayoutManager); fabButton = (FabButton) findViewById(R.id.determinate); fabButton.showProgress(true); fabButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { fabButton.showProgress(true); new DownloadData().execute(); } }); cuacaText = (TextView) findViewById(R.id.cuaca); suhu = (TextView) findViewById(R.id.suhu); minmax = (TextView) findViewById(R.id.minmax); iconCuaca = (ImageView) findViewById(R.id.icon_cuaca); kegiatan = (TextView) findViewById(R.id.kegiatan); background = (LinearLayout) findViewById(R.id.background); cuacaText.setVisibility(View.GONE); suhu.setVisibility(View.GONE); minmax.setVisibility(View.GONE); iconCuaca.setVisibility(View.GONE); kegiatan.setVisibility(View.GONE); if (checkPlayServices()) { buildGoogleApiClient(); } }