List of usage examples for android.content Intent removeExtra
public void removeExtra(String name)
From source file:io.nuclei.cyto.share.PackageTargetManager.java
/** * WeChat and on some android versions Instagram doesn't seem to handle file providers very well, so instead of those we move the * file to external storage and startActivityForResult with the actual file. *///w ww . j a va 2 s . c o m protected Intent onExternalStorage(Activity activity, Intent intent, int permissionRequestCode) { if (mFile != null) { if (ContextCompat.checkSelfPermission(activity, android.Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) { File file = ShareUtil.newShareFile(new File(Environment.getExternalStorageDirectory(), ".cyto"), mFile.getName()); try { onCopyFile(mFile, file); mFile.delete(); mFile = file; } catch (IOException err) { LOG.e("Error copying file for sharing", err); } intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(mFile)); } else { ActivityCompat.requestPermissions(activity, new String[] { android.Manifest.permission.WRITE_EXTERNAL_STORAGE }, permissionRequestCode); return null; } if (intent.hasExtra(Intent.EXTRA_STREAM) && intent.hasExtra(Intent.EXTRA_TEXT)) intent.removeExtra(Intent.EXTRA_TEXT); } return intent; }
From source file:br.com.arlsoft.pushclient.PushClientModule.java
private void checkForExtras() { Activity activity = TiApplication.getAppRootOrCurrentActivity(); if (activity != null) { Intent intent = activity.getIntent(); if (intent != null) { Bundle extras = intent.getExtras(); if (extras != null && !extras.isEmpty() && extras.containsKey(PROPERTY_EXTRAS)) { extras = extras.getBundle(PROPERTY_EXTRAS); HashMap data = PushClientModule.convertBundleToHashMap(extras); data.put("prev_state", "stopped"); PushClientModule.sendMessage(data, PushClientModule.MODE_CLICK); intent.removeExtra(PROPERTY_EXTRAS); }// w w w .j a va 2 s.c o m } } }
From source file:com.pushwoosh.plugin.pushnotifications.PushNotifications.java
private void checkMessage(Intent intent) { if (null != intent) { if (intent.hasExtra(PushManager.PUSH_RECEIVE_EVENT)) { doOnMessageReceive(intent.getExtras().getString(PushManager.PUSH_RECEIVE_EVENT)); } else if (intent.hasExtra(PushManager.REGISTER_EVENT)) { doOnRegistered(intent.getExtras().getString(PushManager.REGISTER_EVENT)); } else if (intent.hasExtra(PushManager.UNREGISTER_EVENT)) { doOnUnregistered(intent.getExtras().getString(PushManager.UNREGISTER_EVENT)); } else if (intent.hasExtra(PushManager.REGISTER_ERROR_EVENT)) { doOnRegisteredError(intent.getExtras().getString(PushManager.REGISTER_ERROR_EVENT)); } else if (intent.hasExtra(PushManager.UNREGISTER_ERROR_EVENT)) { doOnUnregisteredError(intent.getExtras().getString(PushManager.UNREGISTER_ERROR_EVENT)); }//from w ww .j av a 2 s. c om intent.removeExtra(PushManager.PUSH_RECEIVE_EVENT); intent.removeExtra(PushManager.REGISTER_EVENT); intent.removeExtra(PushManager.UNREGISTER_EVENT); intent.removeExtra(PushManager.REGISTER_ERROR_EVENT); intent.removeExtra(PushManager.UNREGISTER_ERROR_EVENT); cordova.getActivity().setIntent(intent); } }
From source file:de.gebatzens.sia.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { setTheme(SIAApp.SIA_APP.school.getTheme()); super.onCreate(savedInstanceState); Log.w("ggvp", "CREATE NEW MAINACTIVITY"); //Debug.startMethodTracing("sia3"); SIAApp.SIA_APP.activity = this; savedState = savedInstanceState;//from w w w .j a va 2s . com final FragmentData.FragmentList fragments = SIAApp.SIA_APP.school.fragments; Intent intent = getIntent(); if (intent != null && intent.getStringExtra("fragment") != null) { FragmentData frag = fragments .getByType(FragmentData.FragmentType.valueOf(intent.getStringExtra("fragment"))).get(0); SIAApp.SIA_APP.setFragmentIndex(fragments.indexOf(frag)); } if (intent != null && intent.getBooleanExtra("reload", false)) { SIAApp.SIA_APP.refreshAsync(null, true, fragments.get(SIAApp.SIA_APP.getFragmentIndex())); intent.removeExtra("reload"); } setContentView(R.layout.activity_main); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); mContent = getFragment(); transaction.replace(R.id.content_fragment, mContent, "gg_content_fragment"); transaction.commit(); Log.d("ggvp", "DATA: " + fragments.get(SIAApp.SIA_APP.getFragmentIndex()).getData()); if (fragments.get(SIAApp.SIA_APP.getFragmentIndex()).getData() == null) SIAApp.SIA_APP.refreshAsync(null, true, fragments.get(SIAApp.SIA_APP.getFragmentIndex())); if ("Summer".equals(SIAApp.SIA_APP.getCurrentThemeName())) { ImageView summerNavigationPalm = (ImageView) findViewById(R.id.summer_navigation_palm); summerNavigationPalm.setImageResource(R.drawable.summer_palm); ImageView summerBackgroundImage = (ImageView) findViewById(R.id.summer_background_image); summerBackgroundImage.setImageResource(R.drawable.summer_background); } mToolBar = (Toolbar) findViewById(R.id.toolbar); mToolBar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { switch (menuItem.getItemId()) { case R.id.action_refresh: ((SwipeRefreshLayout) mContent.getView().findViewById(R.id.refresh)).setRefreshing(true); SIAApp.SIA_APP.refreshAsync(new Runnable() { @Override public void run() { ((SwipeRefreshLayout) mContent.getView().findViewById(R.id.refresh)) .setRefreshing(false); } }, true, fragments.get(SIAApp.SIA_APP.getFragmentIndex())); return true; case R.id.action_settings: Intent i = new Intent(MainActivity.this, SettingsActivity.class); startActivityForResult(i, 1); return true; case R.id.action_addToCalendar: showExamDialog(); return true; case R.id.action_help: AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this); builder.setTitle(getApplication().getString(R.string.help)); builder.setMessage(getApplication().getString(R.string.exam_explain)); builder.setPositiveButton(getApplication().getString(R.string.close), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builder.create().show(); return true; } return false; } }); updateToolbar(SIAApp.SIA_APP.school.name, fragments.get(SIAApp.SIA_APP.getFragmentIndex()).name); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { SIAApp.SIA_APP.setStatusBarColorTransparent(getWindow()); // because of the navigation drawer } mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, mToolBar, R.string.drawer_open, R.string.drawer_close) { /** Called when a drawer has settled in a completely closed state. */ public void onDrawerClosed(View view) { super.onDrawerClosed(view); invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } /** Called when a drawer has settled in a completely open state. */ public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } }; mDrawerLayout.addDrawerListener(mDrawerToggle); navigationView = (NavigationView) findViewById(R.id.navigation_view); mNavigationHeader = navigationView.getHeaderView(0); mNavigationSchoolpictureText = (TextView) mNavigationHeader.findViewById(R.id.drawer_image_text); mNavigationSchoolpictureText.setText(SIAApp.SIA_APP.school.name); mNavigationSchoolpicture = (ImageView) mNavigationHeader.findViewById(R.id.navigation_schoolpicture); mNavigationSchoolpicture.setImageBitmap(SIAApp.SIA_APP.school.loadImage()); mNavigationSchoolpictureLink = mNavigationHeader.findViewById(R.id.navigation_schoolpicture_link); mNavigationSchoolpictureLink.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View viewIn) { mDrawerLayout.closeDrawers(); Intent linkIntent = new Intent(Intent.ACTION_VIEW); linkIntent.setData(Uri.parse(SIAApp.SIA_APP.school.website)); startActivity(linkIntent); } }); final Menu menu = navigationView.getMenu(); menu.clear(); for (int i = 0; i < fragments.size(); i++) { MenuItem item = menu.add(R.id.fragments, Menu.NONE, i, fragments.get(i).name); item.setIcon(fragments.get(i).getIconRes()); } menu.add(R.id.settings, R.id.settings_item, fragments.size(), R.string.settings); menu.setGroupCheckable(R.id.fragments, true, true); menu.setGroupCheckable(R.id.settings, false, false); final Menu navMenu = navigationView.getMenu(); selectedItem = SIAApp.SIA_APP.getFragmentIndex(); if (selectedItem != -1) navMenu.getItem(selectedItem).setChecked(true); navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() { @Override public boolean onNavigationItemSelected(MenuItem menuItem) { if (menuItem.getItemId() == R.id.settings_item) { mDrawerLayout.closeDrawers(); Intent i = new Intent(MainActivity.this, SettingsActivity.class); startActivityForResult(i, 1); } else { final int index = menuItem.getOrder(); if (SIAApp.SIA_APP.getFragmentIndex() != index) { SIAApp.SIA_APP.setFragmentIndex(index); menuItem.setChecked(true); updateToolbar(SIAApp.SIA_APP.school.name, menuItem.getTitle().toString()); mContent = getFragment(); Animation fadeOut = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.fade_out); fadeOut.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { FrameLayout contentFrame = (FrameLayout) findViewById(R.id.content_fragment); contentFrame.setVisibility(View.INVISIBLE); if (fragments.get(index).getData() == null) SIAApp.SIA_APP.refreshAsync(null, true, fragments.get(index)); //removeAllFragments(); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.replace(R.id.content_fragment, mContent, "gg_content_fragment"); transaction.commit(); snowView.updateSnow(); } @Override public void onAnimationRepeat(Animation animation) { } }); FrameLayout contentFrame = (FrameLayout) findViewById(R.id.content_fragment); contentFrame.startAnimation(fadeOut); mDrawerLayout.closeDrawers(); } else { mDrawerLayout.closeDrawers(); } } return true; } }); if (Build.VERSION.SDK_INT >= 25) { ShortcutManager shortcutManager = getSystemService(ShortcutManager.class); shortcutManager.removeAllDynamicShortcuts(); for (int i = 0; i < fragments.size(); i++) { Drawable drawable = getDrawable(fragments.get(i).getIconRes()); Bitmap icon; if (drawable instanceof VectorDrawable) { icon = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(icon); drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); drawable.draw(canvas); } else { icon = BitmapFactory.decodeResource(getResources(), fragments.get(i).getIconRes()); } Bitmap connectedIcon = Bitmap.createBitmap(icon.getWidth(), icon.getHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(connectedIcon); Paint paint = new Paint(); paint.setAntiAlias(true); paint.setColor(Color.parseColor("#f5f5f5")); canvas.drawCircle(icon.getWidth() / 2, icon.getHeight() / 2, icon.getWidth() / 2, paint); paint.setColorFilter( new PorterDuffColorFilter(SIAApp.SIA_APP.school.getColor(), PorterDuff.Mode.SRC_ATOP)); canvas.drawBitmap(icon, null, new RectF(icon.getHeight() / 4.0f, icon.getHeight() / 4.0f, icon.getHeight() - icon.getHeight() / 4.0f, icon.getHeight() - icon.getHeight() / 4.0f), paint); Intent newTaskIntent = new Intent(this, MainActivity.class); newTaskIntent.setAction(Intent.ACTION_MAIN); newTaskIntent.putExtra("fragment", fragments.get(i).type.toString()); ShortcutInfo shortcut = new ShortcutInfo.Builder(this, fragments.get(i).name) .setShortLabel(fragments.get(i).name).setLongLabel(fragments.get(i).name) .setIcon(Icon.createWithBitmap(connectedIcon)).setIntent(newTaskIntent).build(); shortcutManager.addDynamicShortcuts(Arrays.asList(shortcut)); } } if (SIAApp.SIA_APP.preferences.getBoolean("app_130_upgrade", true)) { if (!SIAApp.SIA_APP.preferences.getBoolean("first_use_filter", true)) { TextDialog.newInstance(R.string.upgrade1_3title, R.string.upgrade1_3) .show(getSupportFragmentManager(), "upgrade_dialog"); } SIAApp.SIA_APP.preferences.edit().putBoolean("app_130_upgrade", false).apply(); } snowView = (SnowView) findViewById(R.id.snow_view); shareToolbar = (Toolbar) findViewById(R.id.share_toolbar); shareToolbar.getMenu().clear(); shareToolbar.inflateMenu(R.menu.share_toolbar_menu); shareToolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { toggleShareToolbar(false); for (Shareable s : MainActivity.this.shared) { s.setMarked(false); } MainActivity.this.shared.clear(); mContent.updateFragment(); } }); shareToolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { toggleShareToolbar(false); HashMap<Date, ArrayList<Shareable>> dates = new HashMap<Date, ArrayList<Shareable>>(); for (Shareable s : MainActivity.this.shared) { ArrayList<Shareable> list = dates.get(s.getDate()); if (list == null) { list = new ArrayList<Shareable>(); dates.put(s.getDate(), list); } list.add(s); s.setMarked(false); } MainActivity.this.shared.clear(); List<Date> dateList = new ArrayList<Date>(dates.keySet()); Collections.sort(dateList); String content = ""; for (Date key : dateList) { content += SubstListAdapter.translateDay(key) + "\n\n"; Collections.sort(dates.get(key)); for (Shareable s : dates.get(key)) { content += s.getShareContent() + "\n"; } content += "\n"; } content = content.substring(0, content.length() - 1); mContent.updateFragment(); if (item.getItemId() == R.id.action_copy) { ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); ClipData clip = ClipData.newPlainText(getString(R.string.entries), content); clipboard.setPrimaryClip(clip); } else if (item.getItemId() == R.id.action_share) { Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_TEXT, content); sendIntent.setType("text/plain"); startActivity(Intent.createChooser(sendIntent, getResources().getText(R.string.send_to))); } return true; } }); if (shared.size() > 0) { shareToolbar.setVisibility(View.VISIBLE); updateShareToolbarText(); } // if a fragment is opened via a notification or a shortcut reset the shared entries // delete extra fragment because the same intent is used when the device gets rotated and the user could have opened a new fragment if (intent != null && intent.hasExtra("fragment")) { resetShareToolbar(); intent.removeExtra("fragment"); } }
From source file:com.transistorsoft.cordova.bggeo.CDVBackgroundGeolocation.java
private void addMotionChangeListener(CallbackContext callbackContext) { motionChangeCallbacks.add(callbackContext); Activity activity = this.cordova.getActivity(); Intent launchIntent = activity.getIntent(); if (launchIntent.hasExtra("forceReload")) { if (launchIntent.getStringExtra("name") .equalsIgnoreCase(BackgroundGeolocationService.ACTION_ON_MOTION_CHANGE)) { Bundle event = launchIntent.getExtras(); this.onEventMainThread(event); }/*w w w . j a v a 2s. c o m*/ launchIntent.removeExtra("forceReload"); launchIntent.removeExtra("location"); } }
From source file:com.android.mail.utils.NotificationUtils.java
private static PendingIntent createClickPendingIntent(Context context, Intent notificationIntent) { // Amend the click intent with a hint that its source was a notification, // but remove the hint before it's used to generate notification action // intents. This prevents the following sequence: // 1. generate single notification // 2. user clicks reply, then completes Compose activity // 3. main activity launches, gets FROM_NOTIFICATION hint in intent notificationIntent.putExtra(Utils.EXTRA_FROM_NOTIFICATION, true); PendingIntent clickIntent = PendingIntent.getActivity(context, -1, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); notificationIntent.removeExtra(Utils.EXTRA_FROM_NOTIFICATION); return clickIntent; }
From source file:org.smssecure.smssecure.ConversationActivity.java
@Override public void startActivity(Intent intent) { try {//w w w. ja va2s. c o m if (intent.getStringExtra(Browser.EXTRA_APPLICATION_ID) != null) { intent.removeExtra(Browser.EXTRA_APPLICATION_ID); } super.startActivity(intent); Log.d(TAG, "Opened link: " + intent.getDataString()); } catch (ActivityNotFoundException anfe) { Log.w(TAG, "No app found to view the link '" + intent.getDataString() + "', ignoring..."); Toast.makeText(this, R.string.ConversationActivity_cant_open_link, Toast.LENGTH_SHORT).show(); } }
From source file:de.da_sense.moses.client.FormFragment.java
@Override public void setUserVisibleHint(boolean isVisibleToUser) { super.setUserVisibleHint(isVisibleToUser); if (isVisibleToUser) { // oh I got selected, check if there is a message for me Intent activityIntent = getActivity().getIntent(); int fragmentWhichShouldScroll = activityIntent.getIntExtra(KEY_POSITION_OF_FRAGMENT_WHICH_SHOULD_SCROLL, -1);//from w ww. ja v a 2 s.c om if (fragmentWhichShouldScroll == mPosition) { // it is me who should scroll, get that question id int questionId = activityIntent.getIntExtra(KEY_QUESTION_TO_SCROLL_TO, -1); // find the question instance for (Question aQuestion : mQuestionTitleMappings.keySet()) if (aQuestion.getId() == questionId) { // we have found the question, now scroll to it scrollToQuestion(aQuestion); break; } // remove the information from the intent, because consumed by this FormFragment activityIntent.removeExtra(KEY_POSITION_OF_FRAGMENT_WHICH_SHOULD_SCROLL); activityIntent.removeExtra(KEY_QUESTION_TO_SCROLL_TO); } } }
From source file:com.weebly.opus1269.copyeverywhere.ui.main.MainActivity.java
/** * Process intents we know about// w ww . ja v a 2 s .c om */ @SuppressWarnings("CallToStringEquals") private void handleIntent() { final Intent intent = getIntent(); final String action = intent.getAction(); final String type = intent.getType(); if (Intent.ACTION_SEND.equals(action) && (type != null)) { if (ClipItem.TEXT_PLAIN.equals(type)) { final String sharedText = intent.getStringExtra(Intent.EXTRA_TEXT); if (sharedText != null) { final ClipItem item = new ClipItem(sharedText); ClipContentProvider.insert(this, item); showClipViewer(item); } } } else if (intent.hasExtra(ClipItem.INTENT_EXTRA_CLIP_ITEM)) { final ClipItem item = (ClipItem) intent.getSerializableExtra(ClipItem.INTENT_EXTRA_CLIP_ITEM); intent.removeExtra(ClipItem.INTENT_EXTRA_CLIP_ITEM); showClipViewer(item); } else if (intent.hasExtra(Devices.INTENT_FILTER)) { showDevices(); } }
From source file:im.neon.activity.VectorHomeActivity.java
@Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); mAutomaticallyOpenedRoomParams = (Map<String, Object>) intent .getSerializableExtra(EXTRA_JUMP_TO_ROOM_PARAMS); intent.removeExtra(EXTRA_JUMP_TO_ROOM_PARAMS); mUniversalLinkToOpen = intent.getParcelableExtra(EXTRA_JUMP_TO_UNIVERSAL_LINK); intent.removeExtra(EXTRA_JUMP_TO_UNIVERSAL_LINK); mMemberIdToOpen = intent.getStringExtra(EXTRA_MEMBER_ID); intent.removeExtra(EXTRA_MEMBER_ID); // start waiting view if (intent.getBooleanExtra(EXTRA_WAITING_VIEW_STATUS, VectorHomeActivity.WAITING_VIEW_STOP)) { showWaitingView();/*from www . jav a2 s. c o m*/ } else { stopWaitingView(); } intent.removeExtra(EXTRA_WAITING_VIEW_STATUS); }