List of usage examples for android.content Intent hasExtra
public boolean hasExtra(String name)
From source file:com.hybris.mobile.app.commerce.fragment.CatalogContentFragmentBase.java
/** * Return true if we come from a search request * * @return// ww w . j a v a 2 s . c o m */ protected boolean isSearchRequest() { Intent intent = getActivity().getIntent(); return (intent != null && StringUtils.equals(Intent.ACTION_SEARCH, intent.getAction()) && intent.hasExtra(SearchManager.QUERY)) || StringUtils.isNotBlank(mCurrentSearchText); }
From source file:com.granita.tasks.TaskListActivity.java
private void resolveIntentAction(Intent intent) { // check which task should be selected if (intent.hasExtra(EXTRA_DISPLAY_TASK)) {/*from w w w. j ava 2 s .co m*/ mShouldSwitchToDetail = true; mSelectedTaskUri = intent.getData(); } if (intent != null && intent.hasExtra(EXTRA_DISPLAY_TASK) && intent.getBooleanExtra(EXTRA_FORCE_LIST_SELECTION, true) && mTwoPane) { mShouldSwitchToDetail = true; Uri newSelection = intent.getData(); mSelectedTaskUriOnLaunch = newSelection; mShouldSelectTaskListItem = true; mPagerAdapter.notifyDataSetChanged(); } else { mSelectedTaskUriOnLaunch = null; mShouldSelectTaskListItem = false; } }
From source file:com.example.android.bluetoothlegatt.DeviceControlActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final Intent intent = getIntent(); if (intent.hasExtra(EXTRAS_DEVICE_NAME)) { mDeviceName = intent.getStringExtra(EXTRAS_DEVICE_NAME); } else {/* w w w .ja v a2 s .c om*/ Log.d(TAG, "No device name"); finish(); } if (intent.hasExtra(EXTRAS_DEVICE_ADDRESS)) { mDeviceAddress = intent.getStringExtra(EXTRAS_DEVICE_ADDRESS); } else { Log.d(TAG, "No device address"); finish(); } if (intent.hasExtra(EXTRAS_CONNECTION_METHOD)) { String connectionMethod = intent.getStringExtra(EXTRAS_CONNECTION_METHOD); isBluetoothConnection = connectionMethod.equalsIgnoreCase(BLUETOOTH_METHOD); } else { Log.d(TAG, "No connection method."); finish(); } try { getActionBar().setTitle(mDeviceName); getActionBar().setHomeButtonEnabled(true); getActionBar().setDisplayHomeAsUpEnabled(true); } catch (NullPointerException e) { Log.w(TAG, "NullPointerException when trying to getActionBar()."); } // Setup HTTP API for both cases // if (isBluetoothConnection): // send responses to server's requests. // else: send instructions to server. mRestAdapter = new RestAdapter.Builder().setEndpoint(RETROFIT_API_ENDPOINT) .setLogLevel(RestAdapter.LogLevel.FULL).build(); mClient = mRestAdapter.create(RetrofitResponseApi.class); if (isBluetoothConnection) { // Bind BluetoothLeService to this activity Intent gattServiceIntent = new Intent(this, BluetoothLeService.class); bindService(gattServiceIntent, mServiceConnection, BIND_AUTO_CREATE); mProgressBar = Util.setProgressBar(this); } else { setControlView(); } }
From source file:my.home.lehome.service.SendMsgIntentService.java
private void saveAndNotify(Intent intent, String result) { Context context = getApplicationContext(); int rep_code = -1; String desc;/*from ww w . j a v a 2s .c om*/ try { JSONObject jsonObject = new JSONObject(result); rep_code = jsonObject.getInt("code"); desc = jsonObject.getString("desc"); } catch (JSONException e) { e.printStackTrace(); desc = context.getString(R.string.chat_error_json); } Messenger messenger; if (intent.hasExtra("messenger")) messenger = (Messenger) intent.getExtras().get("messenger"); else messenger = null; Message repMsg = Message.obtain(); repMsg.what = MSG_END_SENDING; ChatItem item = intent.getParcelableExtra("pass_item"); ChatItem newItem = null; if (item != null) { if (rep_code == 200) { item.setState(Constants.CHATITEM_STATE_SUCCESS); DBStaticManager.updateChatItem(context, item); } else { if (rep_code == 415) { item.setState(Constants.CHATITEM_STATE_SUCCESS); } else { item.setState(Constants.CHATITEM_STATE_ERROR); } DBStaticManager.updateChatItem(context, item); newItem = new ChatItem(); newItem.setContent(desc); newItem.setType(ChatItemConstants.TYPE_SERVER); newItem.setState(Constants.CHATITEM_STATE_ERROR); // always set true newItem.setDate(new Date()); DBStaticManager.addChatItem(context, newItem); } } else { if (rep_code != 200) { Log.d(TAG, result); newItem = new ChatItem(); newItem.setContent(getString(R.string.loc_send_error) + ":" + desc); // TODO - not only loc report newItem.setType(ChatItemConstants.TYPE_SERVER); newItem.setState(Constants.CHATITEM_STATE_SUCCESS); // always set true newItem.setDate(new Date()); DBStaticManager.addChatItem(context, newItem); } } Log.d(TAG, "dequeue item: " + item); if (item == null) return; Bundle bundle = new Bundle(); bundle.putParcelable("item", item); if (newItem != null) bundle.putParcelable("new_item", newItem); bundle.putInt("rep_code", rep_code); if (messenger != null) { repMsg.setData(bundle); try { messenger.send(repMsg); } catch (RemoteException e) { e.printStackTrace(); } } else { Log.d(TAG, "messager is null, send broadcast instead:" + ACTION_SEND_MSG_END); Intent newIntent = new Intent(ACTION_SEND_MSG_END); newIntent.putExtras(bundle); sendBroadcast(newIntent); } }
From source file:com.tct.mail.ui.OnePaneController.java
@Override protected void initializeActionBar() { final ActionBar actionBar = mActivity.getSupportActionBar(); if (actionBar == null) { return;/*from ww w . j av a 2 s. c o m*/ } Intent intent = mActivity.getIntent(); /// TCT: Action is search but no extra account means a global search final boolean isSearch = intent != null && Intent.ACTION_SEARCH.equals(intent.getAction()) && intent.hasExtra(Utils.EXTRA_ACCOUNT); mActionBarController = isSearch ? new SearchActionBarController(mContext) : new EmailActionBarController(mContext); mActionBarController.initialize(mActivity, this, actionBar); // init the action bar to allow the 'up' affordance. // any configurations that disallow 'up' should do that later. mActionBarController.setBackButton(); }
From source file:com.androidinspain.deskclock.timer.TimerFragment.java
@Override public void onResume() { super.onResume(); // We may have received a new intent while paused. final Intent intent = getActivity().getIntent(); if (intent != null && intent.hasExtra(TimerService.EXTRA_TIMER_ID)) { // This extra is single-use; remove after honoring it. final int showTimerId = intent.getIntExtra(TimerService.EXTRA_TIMER_ID, -1); intent.removeExtra(TimerService.EXTRA_TIMER_ID); final Timer timer = DataModel.getDataModel().getTimer(showTimerId); if (timer != null) { // A specific timer must be shown; show the list of timers. final int index = DataModel.getDataModel().getTimers().indexOf(timer); mViewPager.setCurrentItem(index); animateToView(mTimersView, null, false); }//from w ww .j a v a 2 s.c om } }
From source file:com.barion.example.app2app.libraryintegration.fragments.ShopFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == Barion.REQUEST_CODE) { if (resultCode == Activity.RESULT_OK) { BarionGetPaymentStateResponse response = (BarionGetPaymentStateResponse) data .getSerializableExtra(Barion.BARION_PAYMENT_STATE_RESPONSE); if (response != null && getActivity() != null) { Intent intent = new Intent(getActivity(), PaymentResultActivity.class); intent.putExtra(Globals.KEY_PAYMENTSTATE, response); startActivity(intent);/*from w w w . j a v a2 s. c o m*/ getActivity().finish(); } } else if (resultCode == Activity.RESULT_CANCELED) { if (data.hasExtra(Barion.ERROR)) { ArrayList<BarionError> errors = (ArrayList<BarionError>) data .getSerializableExtra(Barion.ERROR); processBarionErrors(errors); } else if (data.hasExtra(Barion.BARION_PAYMENT_STATE_RESPONSE)) { BarionGetPaymentStateResponse response = (BarionGetPaymentStateResponse) data .getSerializableExtra(Barion.BARION_PAYMENT_STATE_RESPONSE); if (response != null) { Log.d(TAG, "Response: " + response.getPaymentState().getStatus()); } } } } }
From source file:com.shearosario.tothepathandback.DisplayDirectionsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_display_directions); getActionBar().setDisplayHomeAsUpEnabled(true); Intent intent = getIntent(); /*if(intent.hasExtra("origin")) {/*from ww w .j ava 2 s . c o m*/ double[] temp = intent.getDoubleArrayExtra("origin"); origin = new LatLng (temp[0], temp[1]); } if (intent.hasExtra("destination")) { double[] temp = intent.getDoubleArrayExtra("destination"); destination = new LatLng (temp[0], temp[1]); }*/ String linkCollection = null; String nodeCollection = null; String points = null; if (intent.hasExtra("GuidanceLinkCollection")) linkCollection = intent.getStringExtra("GuidanceLinkCollection"); if (intent.hasExtra("GuidanceNodeCollection")) nodeCollection = intent.getStringExtra("GuidanceNodeCollection"); if (intent.hasExtra("shapePoints")) points = intent.getStringExtra("shapePoints"); gMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.directionsView)).getMap(); gMap.setMyLocationEnabled(false); gMap.setBuildingsEnabled(false); gMap.getUiSettings().setZoomControlsEnabled(false); TextView textView = (TextView) findViewById(R.id.osm_guidance); textView.setText(Html.fromHtml("Data provided by OpenStreetMap contributors " + "<a href=\"http://www.openstreetmap.org/copyright\">License</a>")); textView.setMovementMethod(LinkMovementMethod.getInstance()); textView = (TextView) findViewById(R.id.guidance_text); textView.setText( Html.fromHtml("Guidance Courtesy of " + "<a href=\"http://www.mapquest.com\">MapQuest</a>")); textView.setMovementMethod(LinkMovementMethod.getInstance()); PolylineOptions rectOptions = new PolylineOptions(); markers = new ArrayList<Marker>(); try { JSONArray jGuidanceLinkCollection = new JSONArray(linkCollection); JSONArray jGuidanceNodeCollection = new JSONArray(nodeCollection); JSONArray jShapePoints = new JSONArray(points); int lastIndex = 0; for (int i = 0; i < jGuidanceNodeCollection.length(); i++) { JSONObject nodeObject = jGuidanceNodeCollection.getJSONObject(i); JSONArray linkIds = nodeObject.getJSONArray("linkIds"); int linkIndex = 0; if (linkIds.length() != 0) linkIndex = linkIds.getInt(0); else continue; JSONObject linkObject = jGuidanceLinkCollection.getJSONObject(linkIndex); int shapeIndex = linkObject.getInt("shapeIndex"); // The index of a specific shape point is i/2, so multiply by 2 to get the beginning index in shapePoints // evens are lat and odds are lng double lat = jShapePoints.getDouble((shapeIndex * 2)); double lng = jShapePoints.getDouble((shapeIndex * 2) + 1); lastIndex = ((shapeIndex * 2) + 1); if (i == 0) { Marker temp = gMap .addMarker(new MarkerOptions().position(new LatLng(lat, lng)).title("Origin")); markers.add(temp); } else if (nodeObject.isNull("infoCollection") == false) { Marker temp = gMap.addMarker(new MarkerOptions().position(new LatLng(lat, lng)) .title(nodeObject.getJSONArray("infoCollection").getString(0))); markers.add(temp); } } for (int i = 0; i < lastIndex; i++) { double lat = jShapePoints.getDouble(i); i++; double lng = jShapePoints.getDouble(i); rectOptions.add(new LatLng(lat, lng)); } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } gMap.addPolyline(rectOptions); markersIndex = 0; gMap.moveCamera(CameraUpdateFactory.newLatLngZoom(markers.get(markersIndex).getPosition(), 17)); markers.get(markersIndex).showInfoWindow(); gMap.setOnMarkerClickListener(new OnMarkerClickListener() { @Override public boolean onMarkerClick(Marker arg0) { if (arg0 != null) { for (int i = 0; i < markers.size(); i++) { if (markers.get(i).equals(arg0)) { markersIndex = i; break; } } if (markersIndex == 0) { findViewById(R.id.button_nextStep).setEnabled(true); findViewById(R.id.button_previousStep).setEnabled(false); } else if (markersIndex == (markers.size() - 1)) { findViewById(R.id.button_nextStep).setEnabled(false); findViewById(R.id.button_previousStep).setEnabled(true); } else { findViewById(R.id.button_nextStep).setEnabled(true); findViewById(R.id.button_previousStep).setEnabled(true); } gMap.moveCamera(CameraUpdateFactory.newLatLngZoom(arg0.getPosition(), 17)); arg0.showInfoWindow(); return true; } return false; } }); }
From source file:com.android.ex.photo.PhotoViewActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final ActivityManager mgr = (ActivityManager) getApplicationContext() .getSystemService(Activity.ACTIVITY_SERVICE); sMemoryClass = mgr.getMemoryClass(); Intent mIntent = getIntent(); int currentItem = -1; if (savedInstanceState != null) { currentItem = savedInstanceState.getInt(STATE_ITEM_KEY, -1); mFullScreen = savedInstanceState.getBoolean(STATE_FULLSCREEN_KEY, false); }/*from w w w . j a va2 s .c om*/ // uri of the photos to view; optional if (mIntent.hasExtra(Intents.EXTRA_PHOTOS_URI)) { mPhotosUri = mIntent.getStringExtra(Intents.EXTRA_PHOTOS_URI); } // projection for the query; optional // I.f not set, the default projection is used. // This projection must include the columns from the default projection. if (mIntent.hasExtra(Intents.EXTRA_PROJECTION)) { mProjection = mIntent.getStringArrayExtra(Intents.EXTRA_PROJECTION); } else { mProjection = null; } // Set the current item from the intent if wasn't in the saved instance if (mIntent.hasExtra(Intents.EXTRA_PHOTO_INDEX) && currentItem < 0) { currentItem = mIntent.getIntExtra(Intents.EXTRA_PHOTO_INDEX, -1); } mPhotoIndex = currentItem; setContentView(R.layout.photo_activity_view); // Create the adapter and add the view pager mAdapter = new PhotoPagerAdapter(this, getFragmentManager(), null); mViewPager = (PhotoViewPager) findViewById(R.id.photo_view_pager); mViewPager.setAdapter(mAdapter); mViewPager.setOnPageChangeListener(this); mViewPager.setOnInterceptTouchListener(this); // Kick off the loader getLoaderManager().initLoader(LOADER_PHOTO_LIST, null, this); final ActionBar actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); mActionBarHideDelayTime = getResources().getInteger(R.integer.action_bar_delay_time_in_millis); actionBar.addOnMenuVisibilityListener(this); actionBar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE); }
From source file:com.yeldi.yeldibazaar.FDroid.java
@Override protected void onCreate(Bundle savedInstanceState) { if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("lightTheme", false)) setTheme(R.style.AppThemeLight); super.onCreate(savedInstanceState); manager = new AppListManager(this); setContentView(R.layout.fdroid);/*from w ww . j a va2s .c o m*/ createViews(); // getTabManager().createTabs(); // Start a search by just typing setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL); Intent i = getIntent(); Uri data = getIntent().getData(); if (data != null) { String appid = data.getQueryParameter("fdid"); // If appid == null, we just browse all the apps. // If appid != null, we browse the app specified. if (appid != null) { Intent call = new Intent(this, AppDetails.class); call.putExtra("appid", appid); startActivityForResult(call, REQUEST_APPDETAILS); } } else if (i.hasExtra("uri")) { Intent call = new Intent(this, ManageRepo.class); call.putExtra("uri", i.getStringExtra("uri")); startActivityForResult(call, REQUEST_MANAGEREPOS); } else if (i.hasExtra(EXTRA_TAB_UPDATE)) { boolean showUpdateTab = i.getBooleanExtra(EXTRA_TAB_UPDATE, false); if (showUpdateTab) { getTabManager().selectTab(2); } } }