List of usage examples for android.content Intent getBooleanExtra
public boolean getBooleanExtra(String name, boolean defaultValue)
From source file:gov.wa.wsdot.android.wsdot.service.CamerasSyncService.java
@Override protected void onHandleIntent(Intent intent) { ContentResolver resolver = getContentResolver(); Cursor cursor = null;//from w w w . j av a 2 s.c om long now = System.currentTimeMillis(); boolean shouldUpdate = true; String responseString = ""; /** * Check the cache table for the last time data was downloaded. If we are within * the allowed time period, don't sync, otherwise get fresh data from the server. */ try { cursor = resolver.query(Caches.CONTENT_URI, projection, Caches.CACHE_TABLE_NAME + " LIKE ?", new String[] { "cameras" }, null); if (cursor != null && cursor.moveToFirst()) { long lastUpdated = cursor.getLong(0); //long deltaDays = (now - lastUpdated) / DateUtils.DAY_IN_MILLIS; //Log.d(DEBUG_TAG, "Delta since last update is " + deltaDays + " day(s)"); shouldUpdate = (Math.abs(now - lastUpdated) > (7 * DateUtils.DAY_IN_MILLIS)); } } finally { if (cursor != null) { cursor.close(); } } // Ability to force a refresh of camera data. boolean forceUpdate = intent.getBooleanExtra("forceUpdate", false); if (shouldUpdate || forceUpdate) { List<Integer> starred = new ArrayList<Integer>(); starred = getStarred(); try { URL url = new URL(CAMERAS_URL); URLConnection urlConn = url.openConnection(); BufferedInputStream bis = new BufferedInputStream(urlConn.getInputStream()); GZIPInputStream gzin = new GZIPInputStream(bis); InputStreamReader is = new InputStreamReader(gzin); BufferedReader in = new BufferedReader(is); String jsonFile = ""; String line; while ((line = in.readLine()) != null) jsonFile += line; in.close(); JSONObject obj = new JSONObject(jsonFile); JSONObject result = obj.getJSONObject("cameras"); JSONArray items = result.getJSONArray("items"); List<ContentValues> cams = new ArrayList<ContentValues>(); int numItems = items.length(); for (int j = 0; j < numItems; j++) { JSONObject item = items.getJSONObject(j); ContentValues cameraData = new ContentValues(); cameraData.put(Cameras.CAMERA_ID, item.getString("id")); cameraData.put(Cameras.CAMERA_TITLE, item.getString("title")); cameraData.put(Cameras.CAMERA_URL, item.getString("url")); cameraData.put(Cameras.CAMERA_LATITUDE, item.getString("lat")); cameraData.put(Cameras.CAMERA_LONGITUDE, item.getString("lon")); cameraData.put(Cameras.CAMERA_HAS_VIDEO, item.getString("video")); cameraData.put(Cameras.CAMERA_ROAD_NAME, item.getString("roadName")); if (starred.contains(Integer.parseInt(item.getString("id")))) { cameraData.put(Cameras.CAMERA_IS_STARRED, 1); } cams.add(cameraData); } // Purge existing cameras covered by incoming data resolver.delete(Cameras.CONTENT_URI, null, null); // Bulk insert all the new cameras resolver.bulkInsert(Cameras.CONTENT_URI, cams.toArray(new ContentValues[cams.size()])); // Update the cache table with the time we did the update ContentValues values = new ContentValues(); values.put(Caches.CACHE_LAST_UPDATED, System.currentTimeMillis()); resolver.update(Caches.CONTENT_URI, values, Caches.CACHE_TABLE_NAME + " LIKE ?", new String[] { "cameras" }); responseString = "OK"; } catch (Exception e) { Log.e(DEBUG_TAG, "Error: " + e.getMessage()); responseString = e.getMessage(); } } else { responseString = "NOP"; } Intent broadcastIntent = new Intent(); broadcastIntent.setAction("gov.wa.wsdot.android.wsdot.intent.action.CAMERAS_RESPONSE"); broadcastIntent.addCategory(Intent.CATEGORY_DEFAULT); broadcastIntent.putExtra("responseString", responseString); sendBroadcast(broadcastIntent); }
From source file:com.nogago.android.tracks.services.TrackRecordingService.java
private void handleStartCommand(Intent intent, int startId) { Log.d(TAG, "TrackRecordingService.handleStartCommand: " + startId); if (intent == null) { return;/* www . ja v a 2 s . c om*/ } // Check if called on phone reboot with resume intent. if (intent.getBooleanExtra(RESUME_TRACK_EXTRA_NAME, false)) { resumeTrack(startId); } }
From source file:com.itime.team.itime.fragments.SettingsFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == ALERT_TIME_SETTINGS) { if (resultCode == AlertTimePreferenceFragment.RESULT_SET_DEFAULT_ALERT) { int position = data.getIntExtra(AlertTimePreferenceFragment.RETURN_TEXT_ID, 0); TextView textView = (TextView) mAlertTimeView.findViewById(R.id.setting_dft_alert_time_text); String alert = getResources().getStringArray(R.array.entry_default_alert_time)[position]; String alertText = getResources().getStringArray(R.array.entry_values_default_alert_time)[position]; textView.setText(alertText); UserTask task = UserTask.getInstance(getActivity()); mUser.defaultAlert = alert;//from w w w.j a v a 2s .c om task.updateUserInfo(mUserId, mUser, null); } } else if (requestCode == PROFILE_SETTINGS) { if (resultCode == ProfileFragment.RESULT_UPDATE_PROFILE) { if (data != null && data.getBooleanExtra(ProfileFragment.RESULT_UPDATE_PROFILE_DATA, false) == true) { loadProfileImage(); } } } }
From source file:gov.wa.wsdot.android.wsdot.service.BorderWaitSyncService.java
@Override protected void onHandleIntent(Intent intent) { ContentResolver resolver = getContentResolver(); Cursor cursor = null;//from w w w . java 2s .co m long now = System.currentTimeMillis(); boolean shouldUpdate = true; String responseString = ""; /** * Check the cache table for the last time data was downloaded. If we are within * the allowed time period, don't sync, otherwise get fresh data from the server. */ try { cursor = resolver.query(Caches.CONTENT_URI, new String[] { Caches.CACHE_LAST_UPDATED }, Caches.CACHE_TABLE_NAME + " LIKE ?", new String[] { "border_wait" }, null); if (cursor != null && cursor.moveToFirst()) { long lastUpdated = cursor.getLong(0); //long deltaMinutes = (now - lastUpdated) / DateUtils.MINUTE_IN_MILLIS; //Log.d(DEBUG_TAG, "Delta since last update is " + deltaMinutes + " min"); shouldUpdate = (Math.abs(now - lastUpdated) > (15 * DateUtils.MINUTE_IN_MILLIS)); } } finally { if (cursor != null) { cursor.close(); } } // Ability to force a refresh of camera data. boolean forceUpdate = intent.getBooleanExtra("forceUpdate", false); if (shouldUpdate || forceUpdate) { List<Integer> starred = new ArrayList<Integer>(); starred = getStarred(); try { URL url = new URL(BORDER_WAIT_URL); URLConnection urlConn = url.openConnection(); BufferedReader in = new BufferedReader(new InputStreamReader(urlConn.getInputStream())); String jsonFile = ""; String line; while ((line = in.readLine()) != null) jsonFile += line; in.close(); JSONObject obj = new JSONObject(jsonFile); JSONObject result = obj.getJSONObject("waittimes"); JSONArray items = result.getJSONArray("items"); List<ContentValues> times = new ArrayList<ContentValues>(); int numItems = items.length(); for (int j = 0; j < numItems; j++) { JSONObject item = items.getJSONObject(j); ContentValues timesValues = new ContentValues(); timesValues.put(BorderWait.BORDER_WAIT_ID, item.getInt("id")); timesValues.put(BorderWait.BORDER_WAIT_TITLE, item.getString("name")); timesValues.put(BorderWait.BORDER_WAIT_UPDATED, item.getString("updated")); timesValues.put(BorderWait.BORDER_WAIT_LANE, item.getString("lane")); timesValues.put(BorderWait.BORDER_WAIT_ROUTE, item.getInt("route")); timesValues.put(BorderWait.BORDER_WAIT_DIRECTION, item.getString("direction")); timesValues.put(BorderWait.BORDER_WAIT_TIME, item.getInt("wait")); if (starred.contains(item.getInt("id"))) { timesValues.put(BorderWait.BORDER_WAIT_IS_STARRED, 1); } times.add(timesValues); } // Purge existing border wait times covered by incoming data resolver.delete(BorderWait.CONTENT_URI, null, null); // Bulk insert all the new travel times resolver.bulkInsert(BorderWait.CONTENT_URI, times.toArray(new ContentValues[times.size()])); // Update the cache table with the time we did the update ContentValues values = new ContentValues(); values.put(Caches.CACHE_LAST_UPDATED, System.currentTimeMillis()); resolver.update(Caches.CONTENT_URI, values, Caches.CACHE_TABLE_NAME + "=?", new String[] { "border_wait" }); responseString = "OK"; } catch (Exception e) { Log.e(DEBUG_TAG, "Error: " + e.getMessage()); responseString = e.getMessage(); } } else { responseString = "NOP"; } Intent broadcastIntent = new Intent(); broadcastIntent.setAction("gov.wa.wsdot.android.wsdot.intent.action.BORDER_WAIT_RESPONSE"); broadcastIntent.addCategory(Intent.CATEGORY_DEFAULT); broadcastIntent.putExtra("responseString", responseString); sendBroadcast(broadcastIntent); }
From source file:com.klinker.android.twitter.activities.profile_viewer.ProfilePager.java
public void getFromIntent() { Intent from = getIntent(); name = from.getStringExtra("name"); screenName = from.getStringExtra("screenname"); proPic = from.getStringExtra("profilePicture"); tweetId = from.getLongExtra("tweetid", 0l); isRetweet = from.getBooleanExtra("retweet", false); if (screenName.equalsIgnoreCase(settings.myScreenName)) { isMyProfile = true;/*w ww. ja va 2s.com*/ } getUser(); }
From source file:gov.wa.wsdot.android.wsdot.service.TravelTimesSyncService.java
@Override protected void onHandleIntent(Intent intent) { ContentResolver resolver = getContentResolver(); Cursor cursor = null;/*from ww w. j a v a 2s . c o m*/ long now = System.currentTimeMillis(); boolean shouldUpdate = true; String responseString = ""; /** * Check the cache table for the last time data was downloaded. If we are within * the allowed time period, don't sync, otherwise get fresh data from the server. */ try { cursor = resolver.query(Caches.CONTENT_URI, new String[] { Caches.CACHE_LAST_UPDATED }, Caches.CACHE_TABLE_NAME + " LIKE ?", new String[] { "travel_times" }, null); if (cursor != null && cursor.moveToFirst()) { long lastUpdated = cursor.getLong(0); //long deltaMinutes = (now - lastUpdated) / DateUtils.MINUTE_IN_MILLIS; //Log.d(DEBUG_TAG, "Delta since last update is " + deltaMinutes + " min"); shouldUpdate = (Math.abs(now - lastUpdated) > (5 * DateUtils.MINUTE_IN_MILLIS)); } } finally { if (cursor != null) { cursor.close(); } } // Ability to force a refresh of camera data. boolean forceUpdate = intent.getBooleanExtra("forceUpdate", false); if (shouldUpdate || forceUpdate) { List<Integer> starred = new ArrayList<Integer>(); starred = getStarred(); try { URL url = new URL(TRAVEL_TIMES_URL); URLConnection urlConn = url.openConnection(); BufferedInputStream bis = new BufferedInputStream(urlConn.getInputStream()); GZIPInputStream gzin = new GZIPInputStream(bis); InputStreamReader is = new InputStreamReader(gzin); BufferedReader in = new BufferedReader(is); String jsonFile = ""; String line; while ((line = in.readLine()) != null) jsonFile += line; in.close(); JSONObject obj = new JSONObject(jsonFile); JSONObject result = obj.getJSONObject("traveltimes"); JSONArray items = result.getJSONArray("items"); List<ContentValues> times = new ArrayList<ContentValues>(); int numItems = items.length(); for (int j = 0; j < numItems; j++) { JSONObject item = items.getJSONObject(j); ContentValues timesValues = new ContentValues(); timesValues.put(TravelTimes.TRAVEL_TIMES_TITLE, item.getString("title")); timesValues.put(TravelTimes.TRAVEL_TIMES_CURRENT, item.getInt("current")); timesValues.put(TravelTimes.TRAVEL_TIMES_AVERAGE, item.getInt("average")); timesValues.put(TravelTimes.TRAVEL_TIMES_DISTANCE, item.getString("distance") + " miles"); timesValues.put(TravelTimes.TRAVEL_TIMES_ID, Integer.parseInt(item.getString("routeid"))); timesValues.put(TravelTimes.TRAVEL_TIMES_UPDATED, item.getString("updated")); if (starred.contains(Integer.parseInt(item.getString("routeid")))) { timesValues.put(TravelTimes.TRAVEL_TIMES_IS_STARRED, 1); } times.add(timesValues); } // Purge existing travel times covered by incoming data resolver.delete(TravelTimes.CONTENT_URI, null, null); // Bulk insert all the new travel times resolver.bulkInsert(TravelTimes.CONTENT_URI, times.toArray(new ContentValues[times.size()])); // Update the cache table with the time we did the update ContentValues values = new ContentValues(); values.put(Caches.CACHE_LAST_UPDATED, System.currentTimeMillis()); resolver.update(Caches.CONTENT_URI, values, Caches.CACHE_TABLE_NAME + "=?", new String[] { "travel_times" }); responseString = "OK"; } catch (Exception e) { Log.e(DEBUG_TAG, "Error: " + e.getMessage()); responseString = e.getMessage(); } } else { responseString = "NOP"; } Intent broadcastIntent = new Intent(); broadcastIntent.setAction("gov.wa.wsdot.android.wsdot.intent.action.TRAVEL_TIMES_RESPONSE"); broadcastIntent.addCategory(Intent.CATEGORY_DEFAULT); broadcastIntent.putExtra("responseString", responseString); sendBroadcast(broadcastIntent); }
From source file:com.ibuildapp.romanblack.MultiContactsPlugin.ContactDetailsActivity.java
@Override public void create() { try {/*from ww w .j a v a 2 s.c o m*/ setContentView(R.layout.grouped_contacts_details); Intent currentIntent = getIntent(); Bundle store = currentIntent.getExtras(); widget = (Widget) store.getSerializable("Widget"); if (widget == null) { handler.sendEmptyMessageDelayed(INITIALIZATION_FAILED, 100); return; } person = (Person) store.getSerializable("person"); if (person == null) { handler.sendEmptyMessageDelayed(INITIALIZATION_FAILED, 100); return; } setTopBarTitle(widget.getTitle()); Boolean single = currentIntent.getBooleanExtra("single", true); setTopBarLeftButtonTextAndColor( single ? getResources().getString(R.string.common_home_upper) : getResources().getString(R.string.common_back_upper), getResources().getColor(android.R.color.black), true, new View.OnClickListener() { @Override public void onClick(View view) { finish(); } }); setTopBarTitleColor(getResources().getColor(android.R.color.black)); setTopBarBackgroundColor(Statics.color1); if ((Boolean.TRUE.equals(widget.getParameter(PARAM_SEND_MAIL))) || (Boolean.TRUE.equals(widget.getParameter(PARAM_SEND_SMS))) || (Boolean.TRUE.equals(widget.getParameter(PARAM_SEND_SMS)))) { ImageView shareButton = (ImageView) getLayoutInflater() .inflate(R.layout.grouped_contacts_share_button, null); shareButton.setLayoutParams( new LinearLayout.LayoutParams((int) (29 * getResources().getDisplayMetrics().density), (int) (39 * getResources().getDisplayMetrics().density))); shareButton.setColorFilter(Color.BLACK); setTopBarRightButton(shareButton, getString(R.string.multicontacts_list_share), new View.OnClickListener() { @Override public void onClick(View v) { DialogSharing.Configuration.Builder sharingDialogBuilder = new DialogSharing.Configuration.Builder(); if (Boolean.TRUE.equals(widget.getParameter(PARAM_SEND_MAIL))) sharingDialogBuilder .setEmailSharingClickListener(new DialogSharing.Item.OnClickListener() { @Override public void onClick() { String message = getContactInfo(); Intent email = new Intent(Intent.ACTION_SEND); email.putExtra(Intent.EXTRA_TEXT, message); email.setType("message/rfc822"); startActivity(Intent.createChooser(email, getString(R.string.choose_email_client))); } }); if (Boolean.TRUE.equals(widget.getParameter(PARAM_SEND_SMS))) sharingDialogBuilder .setSmsSharingClickListener(new DialogSharing.Item.OnClickListener() { @Override public void onClick() { String message = getContactInfo(); try { Utils.sendSms(ContactDetailsActivity.this, message); } catch (ActivityNotFoundException e) { e.printStackTrace(); } } }); if (Boolean.TRUE.equals(widget.getParameter(PARAM_ADD_CONTACT))) sharingDialogBuilder.addCustomListener(R.string.multicontacts_add_to_phonebook, R.drawable.gc_add_to_contacts, true, new DialogSharing.Item.OnClickListener() { @Override public void onClick() { createNewContact(person.getName(), person.getPhone(), person.getEmail()); } }); showDialogSharing(sharingDialogBuilder.build()); } }); } boolean hasSchema = store.getBoolean("hasschema"); cachePath = widget.getCachePath() + "/contacts-" + widget.getOrder(); contacts = person.getContacts(); if (widget.getTitle().length() > 0) { setTitle(widget.getTitle()); } root = (LinearLayout) findViewById(R.id.grouped_contacts_details_root); if (hasSchema) { root.setBackgroundColor(Statics.color1); } else if (widget.isBackgroundURL()) { cacheBackgroundFile = cachePath + "/" + Utils.md5(widget.getBackgroundURL()); File backgroundFile = new File(cacheBackgroundFile); if (backgroundFile.exists()) { root.setBackgroundDrawable( new BitmapDrawable(BitmapFactory.decodeStream(new FileInputStream(backgroundFile)))); } else { BackgroundDownloadTask dt = new BackgroundDownloadTask(); dt.execute(widget.getBackgroundURL()); } } else if (widget.isBackgroundInAssets()) { AssetManager am = this.getAssets(); root.setBackgroundDrawable(new BitmapDrawable(am.open(widget.getBackgroundURL()))); } if (contacts != null) { ImageView avatarImage = (ImageView) findViewById(R.id.grouped_contacts_details_avatar); avatarImage.setImageResource(R.drawable.gc_profile_avatar); if (person.hasAvatar() && NetworkUtils.isOnline(this)) { avatarImage.setVisibility(View.VISIBLE); Glide.with(this).load(person.getAvatarUrl()).placeholder(R.drawable.gc_profile_avatar) .dontAnimate().into(avatarImage); } else { avatarImage.setVisibility(View.VISIBLE); avatarImage.setImageResource(R.drawable.gc_profile_avatar); } String name = ""; neededContacts = new ArrayList<>(); for (Contact con : contacts) { if ((con.getType() == 5) || (con.getDescription().length() == 0)) { } else { if (con.getType() == 0) { name = con.getDescription(); } else neededContacts.add(con); } } if (neededContacts.isEmpty()) { handler.sendEmptyMessage(THERE_IS_NO_CONTACT_DATA); return; } headSeparator = findViewById(R.id.gc_head_separator); bottomSeparator = findViewById(R.id.gc_bottom_separator); imageBottom = findViewById(R.id.gc_image_bottom_layout); personName = (TextView) findViewById(R.id.gc_details_description); if ("".equals(name)) personName.setVisibility(View.GONE); else { personName.setVisibility(View.VISIBLE); personName.setText(name); personName.setTextColor(Statics.color3); } if (Statics.isLight) { headSeparator.setBackgroundColor(Color.parseColor("#4d000000")); bottomSeparator.setBackgroundColor(Color.parseColor("#4d000000")); } else { headSeparator.setBackgroundColor(Color.parseColor("#4dFFFFFF")); bottomSeparator.setBackgroundColor(Color.parseColor("#4dFFFFFF")); } ViewUtils.setBackgroundLikeHeader(imageBottom, Statics.color1); ListView list = (ListView) findViewById(R.id.grouped_contacts_details_list_view); list.setDivider(null); ContactDetailsAdapter adapter = new ContactDetailsAdapter(ContactDetailsActivity.this, R.layout.grouped_contacts_details_item, neededContacts, isChemeDark(Statics.color1)); list.setAdapter(adapter); list.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View view, int position, long id) { listViewItemClick(position); } }); } if (widget.hasParameter("add_contact")) { HashMap<String, String> hm = new HashMap<>(); for (int i = 0; i < contacts.size(); i++) { switch (contacts.get(i).getType()) { case 0: { hm.put("contactName", contacts.get(i).getDescription()); } break; case 1: { hm.put("contactNumber", contacts.get(i).getDescription()); } break; case 2: { hm.put("contactEmail", contacts.get(i).getDescription()); } break; case 3: { hm.put("contactSite", contacts.get(i).getDescription()); } break; } } addNativeFeature(NATIVE_FEATURES.ADD_CONTACT, null, hm); } if (widget.hasParameter("send_sms")) { HashMap<String, String> hm = new HashMap<>(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < contacts.size(); i++) { sb.append(contacts.get(i).getDescription()); if (i < contacts.size() - 1) { sb.append(", "); } } hm.put("text", sb.toString()); addNativeFeature(NATIVE_FEATURES.SMS, null, hm); } if (widget.hasParameter("send_mail")) { HashMap<String, CharSequence> hm = new HashMap<>(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < contacts.size(); i++) { switch (contacts.get(i).getType()) { case 0: { sb.append("Name: "); } break; case 1: { sb.append("Phone: "); } break; case 2: { sb.append("Email: "); } break; case 3: { sb.append("Site: "); } break; case 4: { sb.append("Address: "); } break; } sb.append(contacts.get(i).getDescription()); sb.append("<br/>"); } if (widget.isHaveAdvertisement()) { sb.append("<br>\n (sent from <a href=\"http://ibuildapp.com\">iBuildApp</a>)"); } hm.put("text", sb.toString()); hm.put("subject", "Contacts"); addNativeFeature(NATIVE_FEATURES.EMAIL, null, hm); } } catch (Exception e) { Log.e(TAG, e.getMessage()); e.printStackTrace(); } }
From source file:com.xgf.inspection.qrcode.google.zxing.client.CaptureActivity.java
@Override protected void onResume() { super.onResume(); // CameraManager must be initialized here, not in onCreate(). This is // necessary because we don't // want to open the camera driver and measure the screen size if we're // going to show the help on // first launch. That led to bugs where the scanning rectangle was the // wrong size and partially // off screen. cameraManager = new CameraManager(getApplication()); viewfinderView = (ViewfinderView) findViewById(R.id.viewfinder_view); viewfinderView.setCameraManager(cameraManager); resultView = findViewById(R.id.result_view); statusView = (TextView) findViewById(R.id.status_view); handler = null;/*from w w w. java 2 s .c o m*/ lastResult = null; resetStatusView(); SurfaceView surfaceView = (SurfaceView) findViewById(R.id.preview_view); SurfaceHolder surfaceHolder = surfaceView.getHolder(); if (hasSurface) { // The activity was paused but not stopped, so the surface still // exists. Therefore // surfaceCreated() won't be called, so init the camera here. initCamera(surfaceHolder); } else { // Install the callback and wait for surfaceCreated() to init the // camera. surfaceHolder.addCallback(this); surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); } beepManager.updatePrefs(); inactivityTimer.onResume(); Intent intent = getIntent(); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); copyToClipboard = prefs.getBoolean(PreferencesActivity.KEY_COPY_TO_CLIPBOARD, true) && (intent == null || intent.getBooleanExtra(Intents.Scan.SAVE_HISTORY, true)); source = IntentSource.NONE; decodeFormats = null; characterSet = null; if (intent != null) { String action = intent.getAction(); String dataString = intent.getDataString(); if (Intents.Scan.ACTION.equals(action)) { // Scan the formats the intent requested, and return the result // to the calling activity. source = IntentSource.NATIVE_APP_INTENT; decodeFormats = DecodeFormatManager.parseDecodeFormats(intent); if (intent.hasExtra(Intents.Scan.WIDTH) && intent.hasExtra(Intents.Scan.HEIGHT)) { int width = intent.getIntExtra(Intents.Scan.WIDTH, 0); int height = intent.getIntExtra(Intents.Scan.HEIGHT, 0); if (width > 0 && height > 0) { cameraManager.setManualFramingRect(width, height); } } String customPromptMessage = intent.getStringExtra(Intents.Scan.PROMPT_MESSAGE); if (customPromptMessage != null) { statusView.setText(customPromptMessage); } } else if (dataString != null && dataString.contains(PRODUCT_SEARCH_URL_PREFIX) && dataString.contains(PRODUCT_SEARCH_URL_SUFFIX)) { // Scan only products and send the result to mobile Product // Search. source = IntentSource.PRODUCT_SEARCH_LINK; sourceUrl = dataString; decodeFormats = DecodeFormatManager.PRODUCT_FORMATS; } else if (isZXingURL(dataString)) { // Scan formats requested in query string (all formats if none // specified). // If a return URL is specified, send the results there. // Otherwise, handle it ourselves. source = IntentSource.ZXING_LINK; sourceUrl = dataString; Uri inputUri = Uri.parse(sourceUrl); returnUrlTemplate = inputUri.getQueryParameter(RETURN_URL_PARAM); returnRaw = inputUri.getQueryParameter(RAW_PARAM) != null; decodeFormats = DecodeFormatManager.parseDecodeFormats(inputUri); } characterSet = intent.getStringExtra(Intents.Scan.CHARACTER_SET); } }
From source file:com.haibison.android.anhuu.FragmentFiles.java
/** * Creates new instance with {@link FileChooserActivity#ACTION_CHOOSE}. * //from www . ja 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); }
From source file:com.asburymotors.android.disneysocal.service.UtilityService.java
@Override protected void onHandleIntent(Intent intent) { String action = intent != null ? intent.getAction() : null; if (ACTION_ADD_GEOFENCES.equals(action)) { addGeofencesInternal();//from w ww . j a va2s . c om } else if (ACTION_GEOFENCE_TRIGGERED.equals(action)) { geofenceTriggered(intent); } else if (ACTION_REQUEST_LOCATION.equals(action)) { requestLocationInternal(); } else if (ACTION_LOCATION_UPDATED.equals(action)) { locationUpdated(intent); } else if (ACTION_CLEAR_NOTIFICATION.equals(action)) { clearNotificationInternal(); } else if (ACTION_CLEAR_REMOTE_NOTIFICATIONS.equals(action)) { clearRemoteNotifications(); } else if (ACTION_FAKE_UPDATE.equals(action)) { LatLng currentLocation = Utils.getLocation(this); // If location unknown use test city, otherwise use closest city String city = currentLocation == null ? TouristAttractions.TEST_CITY : TouristAttractions.getClosestCity(currentLocation); showNotification(city, intent.getBooleanExtra(EXTRA_TEST_MICROAPP, Constants.USE_MICRO_APP)); } }