List of usage examples for android.content Intent hasExtra
public boolean hasExtra(String name)
From source file:ch.fixme.status.Widget.java
public void onReceive(Context ctxt, Intent intent) { String action = intent.getAction(); if (AppWidgetManager.ACTION_APPWIDGET_DELETED.equals(action)) { // Remove widget alarm int widgetId = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID); PendingIntent pi = PendingIntent.getService(ctxt, widgetId, getIntent(ctxt, widgetId), 0); AlarmManager am = (AlarmManager) ctxt.getSystemService(Context.ALARM_SERVICE); am.cancel(pi);/*from w w w . ja v a 2 s. co m*/ // remove preference SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ctxt); Editor edit = prefs.edit(); edit.remove(Main.PREF_API_URL_WIDGET + widgetId); edit.remove(Main.PREF_INIT_WIDGET + widgetId); edit.remove(Main.PREF_LAST_WIDGET + widgetId); edit.remove(Main.PREF_FORCE_WIDGET + widgetId); edit.commit(); // Log.i(Main.TAG, "Remove widget alarm for id=" + widgetId); } else if (intent.hasExtra(WIDGET_IDS) && AppWidgetManager.ACTION_APPWIDGET_UPDATE.equals(action)) { int[] ids = intent.getExtras().getIntArray(WIDGET_IDS); onUpdate(ctxt, AppWidgetManager.getInstance(ctxt), ids); } else super.onReceive(ctxt, intent); }
From source file:com.markupartist.sthlmtraveling.RoutesActivity.java
private JourneyQuery getJourneyQueryFromIntent(Intent intent) { JourneyQuery journeyQuery;//from w w w . ja v a 2s . c o m if (intent.hasExtra(EXTRA_JOURNEY_QUERY)) { journeyQuery = intent.getExtras().getParcelable(EXTRA_JOURNEY_QUERY); } else { journeyQuery = getJourneyQueryFromUri(intent.getData()); } return journeyQuery; }
From source file:org.openhab.habdroid.ui.OpenHABMainActivity.java
private void onNotificationSelected(Intent intent) { Log.d(TAG, "Notification was selected"); if (intent.hasExtra("notificationId")) { Log.d(TAG, String.format("Notification id = %d", intent.getExtras().getInt("notificationId"))); // Make a fake broadcast intent to hide intent on other devices Intent deleteIntent = new Intent(this, NotificationDeletedBroadcastReceiver.class); deleteIntent.setAction("org.openhab.notification.deleted"); deleteIntent.putExtra("notificationId", intent.getExtras().getInt("notificationId")); sendBroadcast(deleteIntent);//from www . ja va 2 s.c om } }
From source file:br.org.funcate.dynamicforms.views.GPictureView.java
@Override public void setOnActivityResult(Intent data) { Boolean hasPhoto = data.getBooleanExtra(LibraryConstants.OBJECT_EXISTS, false); String imgPath;/* ww w . ja v a2 s.c o m*/ if (hasPhoto) {// response of the CameraActivity with one image imgPath = data.getStringExtra(FormUtilities.PHOTO_COMPLETE_PATH); // TODO: save azimuth on database together with the picture. double azimuth = data.getDoubleExtra(LibraryConstants.AZIMUTH, 0); String uuid = java.util.UUID.randomUUID().toString(); newImagesFromCamera.put(uuid, imgPath); updateValueForm(); try { refresh(getContext()); } catch (Exception e) { e.printStackTrace(); Toast.makeText(getContext(), e.getMessage(), Toast.LENGTH_LONG).show(); } } if (data.hasExtra(FormUtilities.PICTURE_RESPONSE_REMOVE_VIEW)) { Boolean hasPictureRemoved = data.getBooleanExtra(FormUtilities.PICTURE_RESPONSE_REMOVE_VIEW, false); if (!hasPictureRemoved) {// response of the PictureActivity, used to remove image return; } String photoId = data.getStringExtra(FormUtilities.PICTURE_BITMAP_ID); if (addedIdsToImageViews.containsKey(photoId)) {// pictures on session addedIdsToImageViews.remove(photoId); newImagesFromCamera.remove(photoId); } else if (_pictures.containsKey(photoId)) {// pictures from database _pictures.remove(photoId); } updateValueForm(); try { refresh(getContext()); } catch (Exception e) { e.printStackTrace(); Toast.makeText(getContext(), e.getMessage(), Toast.LENGTH_LONG).show(); } } }
From source file:com.tct.email.activity.setup.EmailPreferenceActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final Intent i = getIntent(); if (savedInstanceState == null) { // If we are not restarting from a previous instance, we need to // figure out the initial prefs to show. (Otherwise, we want to // continue showing whatever the user last selected.) if (INTENT_ACCOUNT_MANAGER_ENTRY == null) { INTENT_ACCOUNT_MANAGER_ENTRY = getString(R.string.intent_account_manager_entry); }//from w ww. java2s . co m if (INTENT_ACCOUNT_MANAGER_ENTRY.equals(i.getAction())) { // This case occurs if we're changing account settings from Settings -> Accounts. // We get an account object in the intent, but it's not actually useful to us since // it's always just the first account of that type. The user can't specify which // account they wish to view from within the settings UI, so just dump them at the // main screen. // android.accounts.Account acct = i.getParcelableExtra("account"); } else if (i.hasExtra(EditSettingsExtras.EXTRA_FOLDER)) { throw new IllegalArgumentException("EXTRA_FOLDER is no longer supported"); } else { // Otherwise, we're called from within the Email app and look for our extras final long accountId = IntentUtilities.getAccountIdFromIntent(i); if (accountId != -1) { final Bundle args = AccountSettingsFragment.buildArguments(accountId); startPreferencePanel(AccountSettingsFragment.class.getName(), args, 0, null, null, 0); // TS: jin.dong 2015-08-07 EMAIL BUGFIX_989528 ADD_S finish(); return; // TS: jin.dong 2015-08-07 EMAIL BUGFIX_989528 ADD_E } } } mShowDebugMenu = i.getBooleanExtra(EXTRA_ENABLE_DEBUG, false); final ActionBar actionBar = getActionBar(); if (actionBar != null) { actionBar.setDisplayOptions(ActionBar.DISPLAY_HOME_AS_UP, ActionBar.DISPLAY_HOME_AS_UP); } ListView listView = getListView(); if (listView != null) { listView.setDivider(new ColorDrawable(Color.GRAY)); listView.setDividerHeight(1); } mFeedbackUri = Utils.getValidUri(getString(R.string.email_feedback_uri)); }
From source file:com.ichi2.anki2.CardBrowser.java
@Override protected void onCreate(Bundle savedInstanceState) { Themes.applyTheme(this); super.onCreate(savedInstanceState); View mainView = getLayoutInflater().inflate(R.layout.card_browser, null); setContentView(mainView);//from w ww . ja va2 s . c o m Themes.setContentStyle(mainView, Themes.CALLER_CARDBROWSER); mCol = AnkiDroidApp.getCol(); if (mCol == null) { reloadCollection(savedInstanceState); return; } mDeckNames = new HashMap<String, String>(); for (long did : mCol.getDecks().allIds()) { mDeckNames.put(String.valueOf(did), mCol.getDecks().name(did)); } registerExternalStorageListener(); Intent i = getIntent(); mWholeCollection = i.hasExtra("fromDeckpicker") && i.getBooleanExtra("fromDeckpicker", false); mBackground = Themes.getCardBrowserBackground(); SharedPreferences preferences = AnkiDroidApp.getSharedPrefs(getBaseContext()); int sflRelativeFontSize = preferences.getInt("relativeCardBrowserFontSize", DEFAULT_FONT_SIZE_RATIO); String sflCustomFont = preferences.getString("browserEditorFont", ""); mPrefFixArabic = preferences.getBoolean("fixArabicText", false); Resources res = getResources(); mOrderByFields = res.getStringArray(R.array.card_browser_order_labels); try { mOrder = CARD_ORDER_NONE; String colOrder = mCol.getConf().getString("sortType"); for (int c = 0; c < fSortTypes.length; ++c) { if (fSortTypes[c].equals(colOrder)) { mOrder = c; break; } } if (mOrder == 1 && preferences.getBoolean("cardBrowserNoSorting", false)) { mOrder = 0; } mOrderAsc = Upgrade.upgradeJSONIfNecessary(mCol, mCol.getConf(), "sortBackwards", false); // default to descending for non-text fields if (fSortTypes[mOrder].equals("noteFld")) { mOrderAsc = !mOrderAsc; } } catch (JSONException e) { throw new RuntimeException(e); } mCards = new ArrayList<HashMap<String, String>>(); mCardsListView = (ListView) findViewById(R.id.card_browser_list); mCardsAdapter = new SizeControlledListAdapter(this, mCards, R.layout.card_item, new String[] { "sfld", "deck", "flags" }, new int[] { R.id.card_sfld, R.id.card_deck, R.id.card_item }, sflRelativeFontSize, sflCustomFont); mCardsAdapter.setViewBinder(new SimpleAdapter.ViewBinder() { @Override public boolean setViewValue(View view, Object arg1, String text) { if (view.getId() == R.id.card_item) { int which = BACKGROUND_NORMAL; if (text.equals("1")) { which = BACKGROUND_SUSPENDED; } else if (text.equals("2")) { which = BACKGROUND_MARKED; } else if (text.equals("3")) { which = BACKGROUND_MARKED_SUSPENDED; } view.setBackgroundResource(mBackground[which]); return true; } else if (view.getId() == R.id.card_deck && text.length() > 0) { view.setVisibility(View.VISIBLE); } return false; } }); mCardsListView.setAdapter(mCardsAdapter); mCardsListView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Intent editCard = new Intent(CardBrowser.this, CardEditor.class); editCard.putExtra(CardEditor.EXTRA_CALLER, CardEditor.CALLER_CARDBROWSER_EDIT); mPositionInCardsList = position; long cardId = Long.parseLong(mCards.get(mPositionInCardsList).get("id")); sCardBrowserCard = mCol.getCard(cardId); startActivityForResult(editCard, EDIT_CARD); if (AnkiDroidApp.SDK_VERSION > 4) { ActivityTransitionAnimation.slide(CardBrowser.this, ActivityTransitionAnimation.LEFT); } } }); registerForContextMenu(mCardsListView); mSearchEditText = (EditText) findViewById(R.id.card_browser_search); mSearchEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView view, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_SEARCH) { onSearch(); return true; } return false; } }); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); mSearchButton = (ImageButton) findViewById(R.id.card_browser_search_button); mSearchButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onSearch(); } }); mSearchTerms = ""; if (mWholeCollection) { mRestrictOnDeck = ""; setTitle(res.getString(R.string.card_browser_all_decks)); } else { try { String deckName = mCol.getDecks().current().getString("name"); mRestrictOnDeck = "deck:'" + deckName + "' "; setTitle(deckName); } catch (JSONException e) { throw new RuntimeException(e); } } mSelectedTags = new HashSet<String>(); if (!preferences.getBoolean("cardBrowserNoSearchOnOpen", false)) { searchCards(); } }
From source file:com.hichinaschool.flashcards.anki.CardBrowser.java
@Override protected void onCreate(Bundle savedInstanceState) { Themes.applyTheme(this); super.onCreate(savedInstanceState); View mainView = getLayoutInflater().inflate(R.layout.card_browser, null); setContentView(mainView);/*from w w w. j a va 2 s . com*/ Themes.setContentStyle(mainView, Themes.CALLER_CARDBROWSER); mCol = AnkiDroidApp.getCol(); if (mCol == null) { reloadCollection(savedInstanceState); return; } mDeckNames = new HashMap<String, String>(); for (long did : mCol.getDecks().allIds()) { mDeckNames.put(String.valueOf(did), mCol.getDecks().name(did)); } registerExternalStorageListener(); Intent i = getIntent(); mWholeCollection = i.hasExtra("fromDeckpicker") && i.getBooleanExtra("fromDeckpicker", false); mBackground = Themes.getCardBrowserBackground(); SharedPreferences preferences = AnkiDroidApp.getSharedPrefs(getBaseContext()); int sflRelativeFontSize = preferences.getInt("relativeCardBrowserFontSize", DEFAULT_FONT_SIZE_RATIO); String sflCustomFont = preferences.getString("browserEditorFont", ""); mPrefFixArabic = preferences.getBoolean("fixArabicText", false); Resources res = getResources(); mOrderByFields = res.getStringArray(R.array.card_browser_order_labels); try { mOrder = CARD_ORDER_NONE; String colOrder = mCol.getConf().getString("sortType"); for (int c = 0; c < fSortTypes.length; ++c) { if (fSortTypes[c].equals(colOrder)) { mOrder = c; break; } } if (mOrder == 1 && preferences.getBoolean("cardBrowserNoSorting", false)) { mOrder = 0; } mOrderAsc = Upgrade.upgradeJSONIfNecessary(mCol, mCol.getConf(), "sortBackwards", false); // default to descending for non-text fields if (fSortTypes[mOrder].equals("noteFld")) { mOrderAsc = !mOrderAsc; } } catch (JSONException e) { throw new RuntimeException(e); } mCards = new ArrayList<HashMap<String, String>>(); mCardsListView = (ListView) findViewById(R.id.card_browser_list); mCardsAdapter = new SizeControlledListAdapter(this, mCards, R.layout.card_item, new String[] { "sfld", "deck", "flags" }, new int[] { R.id.card_sfld, R.id.card_deck, R.id.card_item }, sflRelativeFontSize, sflCustomFont); mCardsAdapter.setViewBinder(new SimpleAdapter.ViewBinder() { @Override public boolean setViewValue(View view, Object arg1, String text) { if (view.getId() == R.id.card_item) { int which = BACKGROUND_NORMAL; if (text.equals("1")) { which = BACKGROUND_SUSPENDED; } else if (text.equals("2")) { which = BACKGROUND_MARKED; } else if (text.equals("3")) { which = BACKGROUND_MARKED_SUSPENDED; } view.setBackgroundResource(mBackground[which]); return true; } else if (view.getId() == R.id.card_deck && text.length() > 0) { view.setVisibility(View.VISIBLE); } return false; } }); mCardsListView.setAdapter(mCardsAdapter); mCardsListView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { mPositionInCardsList = position; long cardId = Long.parseLong(mCards.get(mPositionInCardsList).get("id")); sCardBrowserCard = mCol.getCard(cardId); Intent editCard = new Intent(CardBrowser.this, CardEditor.class); editCard.putExtra(CardEditor.EXTRA_CALLER, CardEditor.CALLER_CARDBROWSER_EDIT); editCard.putExtra(CardEditor.EXTRA_CARD_ID, sCardBrowserCard.getId()); startActivityForResult(editCard, EDIT_CARD); if (AnkiDroidApp.SDK_VERSION > 4) { ActivityTransitionAnimation.slide(CardBrowser.this, ActivityTransitionAnimation.LEFT); } } }); registerForContextMenu(mCardsListView); mSearchEditText = (EditText) findViewById(R.id.card_browser_search); mSearchEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView view, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_SEARCH) { onSearch(); return true; } return false; } }); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); mSearchButton = (ImageButton) findViewById(R.id.card_browser_search_button); mSearchButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onSearch(); } }); mSearchTerms = ""; if (mWholeCollection) { mRestrictOnDeck = ""; setTitle(res.getString(R.string.card_browser_all_decks)); } else { try { String deckName = mCol.getDecks().current().getString("name"); mRestrictOnDeck = "deck:'" + deckName + "' "; setTitle(deckName); } catch (JSONException e) { throw new RuntimeException(e); } } mSelectedTags = new HashSet<String>(); if (!preferences.getBoolean("cardBrowserNoSearchOnOpen", false)) { searchCards(); } }
From source file:com.musenkishi.wally.activities.ImageDetailsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_image_details); setToolbar((Toolbar) findViewById(R.id.toolbar)); if (getToolbar() != null) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { getWindow().setStatusBarColor(Color.TRANSPARENT); getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); }//from w w w .j a v a 2 s .com if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { getToolbar().setPadding(0, getStatusBarHeight(), 0, 0); } getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setTitle(""); } final Intent intent = getIntent(); String action = intent.getAction(); if (Intent.ACTION_VIEW.equals(action)) { pageUri = Uri.parse(intent.getDataString()); if ("wally".equalsIgnoreCase(pageUri.getScheme())) { pageUri = pageUri.buildUpon().scheme("http").build(); } } setupViews(); setupHandlers(); Size size = new Size(16, 9); if (intent.hasExtra(INTENT_EXTRA_IMAGE)) { final Image image = intent.getParcelableExtra(INTENT_EXTRA_IMAGE); final Bitmap thumbBitmap = WallyApplication.getBitmapThumb(); if (thumbBitmap != null) { size = fitToWidthAndKeepRatio(image.getWidth(), image.getHeight()); photoView.getLayoutParams().width = size.getWidth(); photoView.getLayoutParams().height = size.getHeight(); Bitmap blurBitMap; try { blurBitMap = Blur.apply(imageHolder.getContext(), thumbBitmap); } catch (ArrayIndexOutOfBoundsException e) { //Blur couldn't be applied. Show regular thumbnail instead. blurBitMap = thumbBitmap; } photoView.setImageBitmap(blurBitMap); } } setupPaddings(size, false); if (savedInstanceState == null) { getPage(pageUri.toString()); } else if (savedInstanceState.containsKey(STATE_IMAGE_PAGE)) { imagePage = savedInstanceState.getParcelable(STATE_IMAGE_PAGE); } if (imagePage != null) { Message msgObj = uiHandler.obtainMessage(); msgObj.what = MSG_PAGE_FETCHED; msgObj.obj = imagePage; uiHandler.sendMessage(msgObj); } else { getPage(pageUri.toString()); } }
From source file:com.meiste.greg.ptw.gcm.GcmIntentService.java
@Override protected void onHandleIntent(final Intent intent) { final Bundle extras = intent.getExtras(); final GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); final String messageType = gcm.getMessageType(intent); synchronized (mSync) { if (mContainer == null) { try { mSync.wait();/*from w w w. ja v a 2 s . co m*/ } catch (final InterruptedException e) { } } } if (!extras.isEmpty()) { /* * Filter messages based on message type. Since it is likely that GCM will be * extended in the future with new message types, just ignore any message types * not recognized. */ if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) { Util.log("GCM send error: " + extras.toString()); } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { Util.log("GCM deleted messages on server: " + extras.toString()); } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { if (intent.hasExtra(MSG_KEY)) { final String message = intent.getStringExtra(MSG_KEY); Util.log("Received " + message + " message from GCM"); if (MSG_KEY_SYNC.equals(message)) { getFromServer("schedule", scheduleListener, false); getFromServer("standings", standingsListener, true); } else if (MSG_KEY_HISTORY.equals(message)) { getFromServer("history", historyListener, true); } else if (MSG_KEY_RULES.equals(message)) { getFromServer("rule_book", rulesListener, false); } else { Util.log("Message type unknown. Ignoring..."); } } } } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); }
From source file:com.haibison.android.anhuu.FragmentFiles.java
/** * Creates new instance with {@link FileChooserActivity#ACTION_CHOOSE}. * /*from ww w .j a v a2 s . c om*/ * @param intent * the intent you got from {@link FileChooserActivity}. * @return the new instance of this fragment. */ public static FragmentFiles newInstance(Intent intent) { /* * Load the extras. */ final Bundle args = new Bundle(); for (String ex : EXTRAS_BOOLEAN) if (intent.hasExtra(ex)) args.putBoolean(ex, intent.getBooleanExtra(ex, false)); for (String ex : EXTRAS_INTEGER) if (intent.hasExtra(ex)) args.putInt(ex, intent.getIntExtra(ex, 0)); for (String ex : EXTRAS_PARCELABLE) if (intent.hasExtra(ex)) args.putParcelable(ex, intent.getParcelableExtra(ex)); for (String ex : EXTRAS_STRING) if (intent.hasExtra(ex)) args.putString(ex, intent.getStringExtra(ex)); return newInstance(args); }