List of usage examples for android.content Intent hasExtra
public boolean hasExtra(String name)
From source file:br.com.brolam.cloudvision.ui.NoteVisionDetailsActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); /**/*from ww w.j ava 2s . c o m*/ * Validar se o login do usurio foi realizado com sucess. * Sendo importante destacar, se o login for cancelado a atividade ser encerrada! */ if (loginHelper.checkLogin(requestCode, resultCode)) { //Verificar se exitem algum requiso para salvar uma imagem. //Observao: Se ocorrer a rotao da tela essa verificao ser cancelada, // sendo assim, essa verificar tambm deve ocorrer novamente na // reconstruo da tela, {@link ImagesHelper.restoreStorageReference } if (this.imagesHelper != null) { this.imagesHelper.onActivityResult(requestCode, resultCode, data); } if ((data != null) && (data.hasExtra(NoteVisionActivity.NOTE_VISION_ITEM_KEY))) { String noteVisionItemKey = data.getStringExtra(NoteVisionActivity.NOTE_VISION_ITEM_KEY); setItemSelectedKey(noteVisionItemKey); } } }
From source file:com.cattle.PhotoViewerActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_photo_viewer); mContentView = (ViewGroup) findViewById(R.id.fl_root); mController = PhotoUploadController.getFromContext(this); EventBus.getDefault().register(this); final Intent intent = getIntent(); mMode = intent.getIntExtra(EXTRA_MODE, MODE_ALL_VALUE); if (mMode == MODE_ALL_VALUE) { mBucketId = intent.getStringExtra(EXTRA_BUCKET_ID); }//from ww w . j av a 2 s . com mViewPager = (ViewPager) findViewById(R.id.vp_photos); mViewPager.setOffscreenPageLimit(2); mViewPager.setPageMargin(getResources().getDimensionPixelSize(R.dimen.viewpager_margin)); mViewPager.setOnPageChangeListener(this); if (mMode == MODE_ALL_VALUE) { mAdapter = new UserPhotosViewPagerAdapter(this, this, this); getSupportLoaderManager().initLoader(0, null, this); } else { mAdapter = new SelectedPhotosViewPagerAdapter(this, this, this); } mViewPager.setAdapter(mAdapter); if (intent.hasExtra(EXTRA_POSITION)) { mRequestedPosition = intent.getIntExtra(EXTRA_POSITION, 0); mViewPager.setCurrentItem(mRequestedPosition); } mFadeOutAnimation = AnimationUtils.loadAnimation(this, R.anim.photo_fade_out); mFriendsFragment = new FriendsListFragment(); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setTitle(" "); /** * Nasty hack, basically we need to know when the ViewPager is laid out, * we then manually call onPageSelected. This is to fix onPageSelected * not being called on the first item. */ mViewPager.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() { @SuppressWarnings("deprecation") public void onGlobalLayout() { mViewPager.getViewTreeObserver().removeGlobalOnLayoutListener(this); onPageSelected(mViewPager.getCurrentItem()); showTapToTagPrompt(); } }); }
From source file:com.transistorsoft.cordova.bggeo.CDVBackgroundGeolocation.java
private void setEnabled(boolean value) { // Don't set a state that we're already in. Log.i(TAG, "- Enable: " + isEnabled + " " + value); Activity activity = cordova.getActivity(); boolean wasEnabled = isEnabled; isEnabled = value;/*from w w w . j a v a 2 s . co m*/ isMoving = null; Intent launchIntent = activity.getIntent(); if (launchIntent.hasExtra("forceReload")) { if (launchIntent.hasExtra("location")) { try { JSONObject location = new JSONObject(launchIntent.getStringExtra("location")); onLocationChange(location); } catch (JSONException e) { Log.w(TAG, e); } } } SharedPreferences.Editor editor = settings.edit(); editor.putBoolean("enabled", isEnabled); editor.apply(); EventBus eventBus = EventBus.getDefault(); if (isEnabled) { synchronized (eventBus) { if (!eventBus.isRegistered(this)) { eventBus.register(this); } } if (!BackgroundGeolocationService.isInstanceCreated()) { activity.startService(backgroundServiceIntent); } else { final Bundle event = new Bundle(); if (!wasEnabled) { event.putString("name", BackgroundGeolocationService.ACTION_START); } else { event.putString("name", BackgroundGeolocationService.ACTION_GET_CURRENT_POSITION); } event.putBoolean("request", true); postEvent(event); onStarted(event); } } else { Bundle event = new Bundle(); event.putString("name", BackgroundGeolocationService.ACTION_STOP); event.putBoolean("request", true); postEvent(event); synchronized (eventBus) { if (eventBus.isRegistered(this)) { eventBus.unregister(this); } } //activity.stopService(backgroundServiceIntent); backgroundServiceIntent = null; } }
From source file:com.shafiq.myfeedle.core.MyfeedleCreatePost.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case PHOTO:/*from w w w.j av a 2 s . c o m*/ if (resultCode == RESULT_OK) { getPhoto(data.getData()); } break; case TAGS: if ((resultCode == RESULT_OK) && data.hasExtra(Stags) && data.hasExtra(Accounts.SID)) mAccountsTags.put(data.getLongExtra(Accounts.SID, Myfeedle.INVALID_ACCOUNT_ID), data.getStringArrayExtra(Stags)); break; } }
From source file:com.pindroid.activity.BrowseBookmarks.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.browse_bookmarks); Intent intent = getIntent(); Uri data = intent.getData();//from www .j a va 2 s . c om FragmentManager fm = getSupportFragmentManager(); FragmentTransaction t = fm.beginTransaction(); if (fm.findFragmentById(R.id.listcontent) == null) { if (Intent.ACTION_SEARCH.equals(intent.getAction())) { Bundle searchData = intent.getBundleExtra(SearchManager.APP_DATA); if (searchData != null) { tagname = searchData.getString("tagname"); app.setUsername(searchData.getString("username")); unread = searchData.getBoolean("unread"); } query = intent.getStringExtra(SearchManager.QUERY); if (intent.hasExtra("username")) { app.setUsername(intent.getStringExtra("username")); } if (data != null) { feed = data.getQueryParameter("feed"); if (data.getUserInfo() != null) { app.setUsername(data.getUserInfo()); } } } else { if (data != null) { tagname = data.getQueryParameter("tagname"); feed = data.getQueryParameter("feed"); unread = data.getQueryParameter("unread") != null; path = data.getPath(); } } if (feed == null || feed.equals("")) { bookmarkFrag = new BrowseBookmarksFragment(); } else { bookmarkFrag = new BrowseBookmarkFeedFragment(); } t.add(R.id.listcontent, bookmarkFrag); } else { if (savedInstanceState != null) { tagname = savedInstanceState.getString(STATE_TAGNAME); unread = savedInstanceState.getBoolean(STATE_UNREAD); query = savedInstanceState.getString(STATE_QUERY); path = savedInstanceState.getString(STATE_PATH); feed = savedInstanceState.getString(STATE_FEED); } bookmarkFrag = fm.findFragmentById(R.id.listcontent); } if (feed == null || feed.equals("")) { if (query != null && !query.equals("")) { ((BrowseBookmarksFragment) bookmarkFrag).setSearchQuery(query, app.getUsername(), tagname, unread); } else { ((BookmarkBrowser) bookmarkFrag).setQuery(app.getUsername(), tagname, unread ? "unread" : null); } ((BrowseBookmarksFragment) bookmarkFrag).refresh(); } else { if (query == null || query.equals("")) { ((BookmarkBrowser) bookmarkFrag).setQuery(app.getUsername(), tagname, feed); } else { ((BookmarkBrowser) bookmarkFrag).setQuery(app.getUsername(), query, feed); } } BrowseTagsFragment tagFrag = (BrowseTagsFragment) fm.findFragmentById(R.id.tagcontent); if (tagFrag != null) { tagFrag.setAccount(app.getUsername()); } if (path != null && path.contains("tags")) { t.hide(fm.findFragmentById(R.id.maincontent)); findViewById(R.id.panel_collapse_button).setVisibility(View.GONE); } else { if (tagFrag != null) { t.hide(tagFrag); } } Fragment addFrag = fm.findFragmentById(R.id.addcontent); if (addFrag != null) { t.hide(addFrag); } t.commit(); }
From source file:com.scoreflex.Scoreflex.java
/** * Method to call on your onCreate method to handle the Scoreflex * notification, it must be added to the Activity implementation of the * class you gave to// www . j a v a 2s . c o m * {@link #onBroadcastReceived(Context, Intent, int, Class)} (must be called * after Scoreflex.initialize(). As follow: * * <pre> * <code> * protected void onCreate(Bundle savedInstance) { * Scoreflex.onCreateMainActivity(this, getIntent()); * } * </code> * </pre> * * @param activity * The current activity. * @param intent * The intent the activity received. * @param useActivityForViews * Set if scoreflex views should be presented as separate activities * * @return <code>true</code> if handled, <code>false</code> otherwise. */ public static boolean onCreateMainActivity(final Activity activity, Intent intent, final boolean useActivityForViews) { if (intent.hasExtra(Scoreflex.NOTIFICATION_EXTRA_KEY)) { String notificationString = intent.getStringExtra(Scoreflex.NOTIFICATION_EXTRA_KEY); try { JSONObject notification = new JSONObject(notificationString); JSONObject data = notification.getJSONObject("data"); String resource = null; Scoreflex.RequestParams parameters = null; int code = notification.getInt("code"); Scoreflex.RequestParams trackParams = new Scoreflex.RequestParams(); trackParams.put("code", Integer.toString(code)); Scoreflex.postEventually("/notifications/track", trackParams, null); if (NOTIFICATION_TYPE_CHALLENGE_INVITATION == code || NOTIFICATION_TYPE_YOUR_TURN_IN_CHALLENGE == code || NOTIFICATION_TYPE_CHALLENGE_ENDED == code) { resource = "/web/challenges/instances/" + data.getString("challengeInstanceId"); } else if (NOTIFICATION_TYPE_FRIEND_JOINED_GAME == code) { resource = "/web/players/" + data.getString("friendId"); } else if (NOTIFICATION_TYPE_FRIEND_BEAT_YOUR_HIGHSCORE == code) { parameters = new RequestParams(); parameters.put("friendsOnly", "true"); parameters.put("focus", data.getString("friendId")); resource = "/web/leaderboards/" + data.getString("leaderboardId"); } else if (NOTIFICATION_TYPE_PLAYER_LEVEL_CHANGED == code) { resource = "/web/players/me"; } if (isInitialized()) { showView(activity, resource, parameters, useActivityForViews); } else { final String finalResource = resource; final Scoreflex.RequestParams params = parameters; BroadcastReceiver receiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { showView(activity, finalResource, params, useActivityForViews); LocalBroadcastManager.getInstance(activity).unregisterReceiver(this); } }; IntentFilter filter = new IntentFilter(Scoreflex.INTENT_SCOREFLEX_INTIALIZED); LocalBroadcastManager.getInstance(activity).registerReceiver(receiver, filter); } return true; } catch (JSONException e) { e.printStackTrace(); } } return false; }
From source file:cn.edu.nju.dapenti.activity.EditFeedActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { UiUtils.setPreferenceTheme(this); super.onCreate(savedInstanceState); ActionBar actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); setContentView(R.layout.activity_feed_edit); setResult(RESULT_CANCELED);/* w w w . jav a2 s . com*/ Intent intent = getIntent(); mNameEditText = (EditText) findViewById(R.id.feed_title); mUrlEditText = (EditText) findViewById(R.id.feed_url); mRetrieveFulltextCb = (CheckBox) findViewById(R.id.retrieve_fulltext); mFiltersListView = (ListView) findViewById(android.R.id.list); View filtersLayout = findViewById(R.id.filters_layout); View buttonLayout = findViewById(R.id.button_layout); if (intent.getAction().equals(Intent.ACTION_INSERT) || intent.getAction().equals(Intent.ACTION_SEND)) { setTitle(R.string.new_feed_title); filtersLayout.setVisibility(View.GONE); if (intent.hasExtra(Intent.EXTRA_TEXT)) { mUrlEditText.setText(intent.getStringExtra(Intent.EXTRA_TEXT)); } restoreInstanceState(savedInstanceState); } else if (intent.getAction().equals(Intent.ACTION_EDIT)) { setTitle(R.string.edit_feed_title); buttonLayout.setVisibility(View.GONE); mFiltersCursorAdapter = new FiltersCursorAdapter(this, null); mFiltersListView.setAdapter(mFiltersCursorAdapter); mFiltersListView.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { startActionMode(mFilterActionModeCallback); mFiltersCursorAdapter.setSelectedFilter(position); mFiltersListView.invalidateViews(); return true; } }); getLoaderManager().initLoader(0, null, this); if (!restoreInstanceState(savedInstanceState)) { Cursor cursor = getContentResolver().query(intent.getData(), FEED_PROJECTION, null, null, null); if (cursor.moveToNext()) { mPreviousName = cursor.getString(0); mNameEditText.setText(mPreviousName); mUrlEditText.setText(cursor.getString(1)); mRetrieveFulltextCb.setChecked(cursor.getInt(2) == 1); cursor.close(); } else { cursor.close(); Toast.makeText(EditFeedActivity.this, R.string.error, Toast.LENGTH_SHORT).show(); finish(); } } } }
From source file:co.nerdart.ourss.activity.EditFeedActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { UiUtils.setPreferenceTheme(this); super.onCreate(savedInstanceState); ActionBar actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); setContentView(R.layout.feed_edit);/*from ww w . ja v a 2 s .c o m*/ setResult(RESULT_CANCELED); Intent intent = getIntent(); mNameEditText = (EditText) findViewById(R.id.feed_title); mUrlEditText = (EditText) findViewById(R.id.feed_url); mRetrieveFulltextCb = (CheckBox) findViewById(R.id.retrieve_fulltext); mFiltersListView = (ListView) findViewById(android.R.id.list); View filtersLayout = findViewById(R.id.filters_layout); View buttonLayout = findViewById(R.id.button_layout); if (intent.getAction().equals(Intent.ACTION_INSERT) || intent.getAction().equals(Intent.ACTION_SEND)) { setTitle(R.string.new_feed_title); filtersLayout.setVisibility(View.GONE); if (intent.hasExtra(Intent.EXTRA_TEXT)) { mUrlEditText.setText(intent.getStringExtra(Intent.EXTRA_TEXT)); } restoreInstanceState(savedInstanceState); } else if (intent.getAction().equals(Intent.ACTION_EDIT)) { setTitle(R.string.edit_feed_title); buttonLayout.setVisibility(View.GONE); mFiltersCursorAdapter = new FiltersCursorAdapter(this, null); mFiltersListView.setAdapter(mFiltersCursorAdapter); mFiltersListView.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { startActionMode(mFilterActionModeCallback); mFiltersCursorAdapter.setSelectedFilter(position); mFiltersListView.invalidateViews(); return true; } }); getLoaderManager().initLoader(0, null, this); if (!restoreInstanceState(savedInstanceState)) { Cursor cursor = getContentResolver().query(intent.getData(), FEED_PROJECTION, null, null, null); if (cursor.moveToNext()) { mPreviousName = cursor.getString(0); mNameEditText.setText(mPreviousName); mUrlEditText.setText(cursor.getString(1)); mRetrieveFulltextCb.setChecked(cursor.getInt(2) == 1); cursor.close(); } else { cursor.close(); Crouton.makeText(EditFeedActivity.this, R.string.error, Style.INFO); finish(); } } } }
From source file:com.example.angelina.travelapp.map.MapFragment.java
@Override @Nullable/*from w w w .j av a 2 s . c om*/ public final View onCreateView(final LayoutInflater layoutInflater, final ViewGroup container, final Bundle savedInstance) { final View root = layoutInflater.inflate(R.layout.map_fragment, container, false); final Intent intent = getActivity().getIntent(); // If any extra data was sent, store it. if (intent.getSerializableExtra("PLACE_DETAIL") != null) { centeredPlaceName = getActivity().getIntent().getStringExtra("PLACE_DETAIL"); } if (intent.hasExtra("MIN_X")) { final double minX = intent.getDoubleExtra("MIN_X", 0); final double minY = intent.getDoubleExtra("MIN_Y", 0); final double maxX = intent.getDoubleExtra("MAX_X", 0); final double maxY = intent.getDoubleExtra("MAX_Y", 0); final String spatRefStr = intent.getStringExtra("SR"); if (spatRefStr != null) { final Envelope envelope = new Envelope(minX, minY, maxX, maxY, SpatialReference.create(spatRefStr)); mViewpoint = new Viewpoint(envelope); } } showProgressIndicator("Loading map"); setUpMapView(root); return root; }
From source file:com.piusvelte.mosaic.android.MosaicMap.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); getActivity();// www . j av a2 s .c o m if ((requestCode == REQUEST_INSERT_MESSAGE) && (resultCode == Activity.RESULT_OK)) { try { iLocationService.insertMessage(data.getStringExtra(Mosaic.EXTRA_TITLE), data.getStringExtra(Mosaic.EXTRA_BODY), data.getIntExtra(Mosaic.EXTRA_LATITUDE, 0), data.getIntExtra(Mosaic.EXTRA_LONGITUDE, 0), data.getIntExtra(Mosaic.EXTRA_RADIUS, 0), data.getLongExtra(Mosaic.EXTRA_EXPIRY, Mosaic.NEVER_EXPIRES)); } catch (RemoteException e) { // TODO Auto-generated catch block e.printStackTrace(); } } else { getActivity(); if ((requestCode == REQUEST_UPDATE_MESSAGE) && (resultCode == Activity.RESULT_OK)) { if (data.hasExtra(Mosaic.EXTRA_TITLE)) { try { iLocationService.updateMessage(data.getLongExtra(Mosaic.EXTRA_ID, Mosaic.INVALID_ID), data.getStringExtra(Mosaic.EXTRA_TITLE), data.getStringExtra(Mosaic.EXTRA_BODY), data.getIntExtra(Mosaic.EXTRA_RADIUS, 0), data.getLongExtra(Mosaic.EXTRA_EXPIRY, Mosaic.NEVER_EXPIRES)); } catch (RemoteException e) { // TODO Auto-generated catch block e.printStackTrace(); } } else { Long id = data.getLongExtra(Mosaic.EXTRA_ID, Mosaic.INVALID_ID); if (markers.containsKey(id)) { messages.remove(markers.get(id).getId()); markers.remove(id).remove(); } if (polygons.containsKey(id)) polygons.remove(id).remove(); try { iLocationService.removeMessage(id); } catch (RemoteException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } else { if ((requestCode == REQUEST_VIEW_MESSAGE) && (resultCode == Activity.RESULT_OK)) { try { iLocationService.reportMessage(data.getLongExtra(Mosaic.EXTRA_ID, Mosaic.INVALID_ID)); } catch (RemoteException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } } }