List of usage examples for android.content Intent getBooleanExtra
public boolean getBooleanExtra(String name, boolean defaultValue)
From source file:com.github.luluvise.droid_utils.lib.network.NetworkBroadcastReceiver.java
@Override public void onReceive(Context context, Intent intent) { if (DroidConfig.DEBUG) { // debugging network info final NetworkInfo otherNetworkInfo = (NetworkInfo) intent .getParcelableExtra(ConnectivityManager.EXTRA_OTHER_NETWORK_INFO); final String reason = intent.getStringExtra(ConnectivityManager.EXTRA_REASON); final boolean failover = intent.getBooleanExtra(ConnectivityManager.EXTRA_IS_FAILOVER, false); Log.i(TAG,/* w w w. j ava 2s. co m*/ "onReceive(): " + " otherNetworkInfo = " + (otherNetworkInfo == null ? "[none]" : otherNetworkInfo) + ", failover=" + failover + ", reason=" + reason); } // use EXTRA_NO_CONNECTIVITY to check if there is no connection if (intent.getBooleanExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY, false)) { notifyConnectionGone(context); return; } final ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); final NetworkInfo netInfo = cm.getActiveNetworkInfo(); // send local broadcast to notify all registered receivers if (netInfo != null && netInfo.isConnected()) { // connection active notifyConnectionActive(context, netInfo.getType()); } else { // connection has gone notifyConnectionGone(context); } }
From source file:com.netpace.expressit.activity.UploadImageStoryActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_upload_image_story); getSupportActionBar().setTitle("retake"); getSupportActionBar().setDisplayShowHomeEnabled(false); Intent intent = getIntent(); img_filePath = intent.getStringExtra(IMAGE_PATH); widthAfter = intent.getIntExtra(IMAGE_WIDTH, 0); heightAfter = intent.getIntExtra(IMAGE_HEIGHT, 0); isGalleryPhoto = intent.getBooleanExtra("isGalleryPhoto", false); imageViewThumbnail = (ImageView) findViewById(R.id.imageViewThumb); imageViewThumbnail.setImageURI(Uri.parse(img_filePath)); titleTextView = (TypefaceEditText) findViewById(R.id.story_title_txt_field); button_saveLater = (Button) findViewById(R.id.shareButton); button_saveLater.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (isValidate()) { // close the keyboard. InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(titleTextView.getWindowToken(), 0); getMediaKeyFromRemoteServer(); }/*from www.j a v a 2s . co m*/ } }); }
From source file:com.android.cts.intent.sender.ContentTest.java
/** * Ensure that sender is only able to send data that it has access to. */// ww w . j a va 2 s . c o m public void testSecurity() throws Exception { // Pick a URI that neither of us have access to; it doens't matter if // its missing, since we expect a SE before a FNFE. final Uri uri = Uri.parse("content://media/external/images/media/10240"); final Intent intent = new Intent(ACTION_READ_FROM_URI); intent.setClipData(ClipData.newRawUri("", uri)); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); // We're expecting to run into a security exception final Intent result = mActivity.getCrossProfileResult(intent); if (result == null) { // This is fine; probably of a SecurityException when off in the // system somewhere. } else { // But if we somehow came through, make sure they threw. assertTrue(result.getBooleanExtra("extra_caught_security_exception", false)); } }
From source file:com.example.androidx.media.VideoViewTest.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //Remove title bar requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.video_activity); mVideoView = findViewById(R.id.video_view); String errorString = null;/*ww w.j a v a2 s. c om*/ Intent intent = getIntent(); Uri contentUri; if (intent == null || (contentUri = intent.getData()) == null || !contentUri.isAbsolute()) { errorString = "Invalid intent"; } else { mUseTextureView = intent.getBooleanExtra(USE_TEXTURE_VIEW_EXTRA_NAME, false); if (mUseTextureView) { mVideoView.setViewType(VideoView2.VIEW_TYPE_TEXTUREVIEW); } mVideoView.setFullScreenRequestListener(new FullScreenRequestListener()); mVideoView.setVideoUri(contentUri); mMediaControlView = new MediaControlView2(this); mVideoView.setMediaControlView2(mMediaControlView, 2000); } if (errorString != null) { showErrorDialog(errorString); } }
From source file:com.lgallardo.qbittorrentclient.RSSItemActivity.java
private void handleIntent(Intent intent) { rssChannelPosition = 0;/*from w ww . ja va 2s .c om*/ if (intent != null) { rssChannelPosition = intent.getIntExtra("position", 0); // Get package name packageName = intent.getStringExtra("packageName"); // Get theme UI preference dark_ui = intent.getBooleanExtra("dark_ui", false); } }
From source file:eu.inmite.apps.smsjizdenka.service.UpdateService.java
@Override protected void onHandleIntent(Intent intent) { if (intent == null) { return;/* ww w . j a v a 2s .c o m*/ } final boolean force = intent.getBooleanExtra("force", false); try { Locale loc = Locale.getDefault(); String lang = loc.getISO3Language(); // http://www.loc.gov/standards/iso639-2/php/code_list.php; T-values if present both T and B if (lang == null || lang.length() == 0) { lang = ""; } int serverVersion = intent.getIntExtra("serverVersion", -1); boolean fromPush = serverVersion != -1; JSONObject versionJson = null; if (!fromPush) { versionJson = getVersion(true); serverVersion = versionJson.getInt("version"); } int localVersion = Preferences.getInt(c, Preferences.DATA_VERSION, -1); final String localLanguage = Preferences.getString(c, Preferences.DATA_LANGUAGE, ""); if (serverVersion <= localVersion && !force && lang.equals(localLanguage) && !LOCAL_DEFINITION_TESTING) { // don't update DebugLog.i("Nothing new, not updating"); return; } // update but don't notify about it. boolean firstLaunchNoUpdate = ((localVersion == -1 && getVersion(false).getInt("version") == serverVersion) || !lang.equals(localLanguage)); if (!firstLaunchNoUpdate) { DebugLog.i("There are new definitions available!"); } handleAuthorMessage(versionJson, lang, intent, fromPush); InputStream is = getIS(URL_TICKETS_ID); try { String json = readResult(is); JSONObject o = new JSONObject(json); JSONArray array = o.getJSONArray("tickets"); final SQLiteDatabase db = DatabaseHelper.get(this).getWritableDatabase(); for (int i = 0; i < array.length(); i++) { final JSONObject city = array.getJSONObject(i); try { final ContentValues cv = new ContentValues(); cv.put(Cities._ID, city.getInt("id")); cv.put(Cities.CITY, getStringLocValue(city, lang, "city")); if (city.has("city_pubtran")) { cv.put(Cities.CITY_PUBTRAN, city.getString("city_pubtran")); } cv.put(Cities.COUNTRY, city.getString("country")); cv.put(Cities.CURRENCY, city.getString("currency")); cv.put(Cities.DATE_FORMAT, city.getString("dateFormat")); cv.put(Cities.IDENTIFICATION, city.getString("identification")); cv.put(Cities.LAT, city.getDouble("lat")); cv.put(Cities.LON, city.getDouble("lon")); cv.put(Cities.NOTE, getStringLocValue(city, lang, "note")); cv.put(Cities.NUMBER, city.getString("number")); cv.put(Cities.P_DATE_FROM, city.getString("pDateFrom")); cv.put(Cities.P_DATE_TO, city.getString("pDateTo")); cv.put(Cities.P_HASH, city.getString("pHash")); cv.put(Cities.PRICE, city.getString("price")); cv.put(Cities.PRICE_NOTE, getStringLocValue(city, lang, "priceNote")); cv.put(Cities.REQUEST, city.getString("request")); cv.put(Cities.VALIDITY, city.getInt("validity")); if (city.has("confirmReq")) { cv.put(Cities.CONFIRM_REQ, city.getString("confirmReq")); } if (city.has("confirm")) { cv.put(Cities.CONFIRM, city.getString("confirm")); } final JSONArray additionalNumbers = city.getJSONArray("additionalNumbers"); for (int j = 0; j < additionalNumbers.length() && j < 3; j++) { cv.put("ADDITIONAL_NUMBER_" + (j + 1), additionalNumbers.getString(j)); } db.beginTransaction(); int count = db.update(DatabaseHelper.CITY_TABLE_NAME, cv, Cities._ID + " = " + cv.getAsInteger(Cities._ID), null); if (count == 0) { db.insert(DatabaseHelper.CITY_TABLE_NAME, null, cv); } db.setTransactionSuccessful(); getContentResolver().notifyChange(Cities.CONTENT_URI, null); } finally { if (db.inTransaction()) { db.endTransaction(); } } } Preferences.set(c, Preferences.DATA_VERSION, serverVersion); Preferences.set(c, Preferences.DATA_LANGUAGE, lang); if (!firstLaunchNoUpdate && !fromPush) { final int finalServerVersion = serverVersion; mHandler.post(new Runnable() { @Override public void run() { Toast.makeText(UpdateService.this, getString(R.string.cities_update_completed, finalServerVersion), Toast.LENGTH_LONG).show(); } }); } if (LOCAL_DEFINITION_TESTING) { DebugLog.w( "Local definition testing - data updated from assets - must be removed in production!"); } } finally { is.close(); } } catch (IOException e) { DebugLog.e("IOException when calling update: " + e.getMessage(), e); } catch (JSONException e) { DebugLog.e("JSONException when calling update: " + e.getMessage(), e); } }
From source file:com.juick.android.XMPPMessageReceiver.java
@Override public void onReceive(final Context context, final Intent intent) { if (intent.getAction().equals("android.intent.action.BOOT_COMPLETED")) { context.startService(new Intent(context, XMPPService.class)); }/*ww w . j a va2 s . c om*/ if (intent.getAction().equals(XMPPService.ACTION_MESSAGE_RECEIVED)) { int nMessages = intent.getIntExtra("messagesCount", 0); boolean sound = intent.getBooleanExtra("sound", true); XMPPService.IncomingMessage messag = (XMPPService.IncomingMessage) intent .getSerializableExtra("message"); if (nMessages == 0) return; ArrayList<MessageReceiverListener> allListeners = (ArrayList<MessageReceiverListener>) listeners .clone(); boolean handled = false; for (MessageReceiverListener listener : allListeners) { handled |= listener.onMessageReceived(messag); } if (!handled) { updateInfo(context, nMessages, !sound); } } if (intent.getAction().equals(XMPPService.ACTION_LAUNCH_MESSAGELIST)) { Intent nintent = new Intent(context, XMPPIncomingMessagesActivity.class); nintent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); nintent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(nintent); } }
From source file:net.dahanne.spring.android.ch3.restful.example.recipeapp.RecipeEditor.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); /*/*w w w .j av a 2 s .com*/ * Creates an Intent to use when the Activity object's result is sent back to the * caller. */ final Intent intent = getIntent(); if (intent.getBooleanExtra(RecipeEditor.NEW_RECIPE, true)) { id = null; mState = STATE_INSERT; } else { mState = STATE_EDIT; id = intent.getLongExtra(RecipeEditor.RECIPE_ID, 0L); } // Sets the layout for this Activity. See res/layout/recipe_editor.xml setContentView(R.layout.recipe_editor); // Gets a handle to the EditText in the the layout. mText = (EditText) findViewById(R.id.recipe); title = (EditText) findViewById(R.id.title); typeSpinner = (Spinner) this.findViewById(R.id.spinner1); // Step 2: Create and fill an ArrayAdapter with a bunch of "State" objects ArrayAdapter<DishType> spinnerArrayAdapter = new ArrayAdapter<DishType>(this, android.R.layout.simple_spinner_item, new DishType[] { DishType.ENTREE, DishType.MAIN_DISH, DishType.DESSERT }); // Step 3: Tell the spinner about our adapter typeSpinner.setAdapter(spinnerArrayAdapter); /* * If this Activity had stopped previously, its state was written the ORIGINAL_CONTENT * location in the saved Instance state. This gets the state. */ if (savedInstanceState != null) { mOriginalContent = savedInstanceState.getString(ORIGINAL_CONTENT); } }
From source file:com.arantius.tivocommander.SeasonPass.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode != Activity.RESULT_OK) { return;/*from w w w . jav a2 s .c o m*/ } if (data.getBooleanExtra("refresh", false)) { startRequest(); } }
From source file:com.mattprecious.prioritysms.receiver.AlarmReceiver.java
private void handleIntent(Context context, Intent intent) { if (!intent.hasExtra(Intents.EXTRA_PROFILE)) { missingExtra(Intents.EXTRA_PROFILE); }//from w ww . j ava 2s. com BaseProfile profile = intent.getParcelableExtra(Intents.EXTRA_PROFILE); if (Intents.ALARM_KILLED.equals(intent.getAction())) { boolean replaced = intent.getBooleanExtra(Intents.ALARM_REPLACED, false); if (!replaced) { // TODO: throw a notification saying it was auto-killed NotificationManager nm = getNotificationManager(context); nm.cancel(profile.getId()); // should be caught in the activity, but you can never have too // many stopServices! context.stopService(new Intent(Intents.ACTION_ALERT)); } return; } else if (!Intents.ACTION_ALERT.equals(intent.getAction())) { // Unknown intent, bail. return; } if (!intent.hasExtra(Intents.EXTRA_NUMBER)) { missingExtra(Intents.EXTRA_NUMBER); } else if (profile instanceof SmsProfile) { if (!intent.hasExtra(Intents.EXTRA_MESSAGE)) { missingExtra(Intents.EXTRA_MESSAGE); } } String number = intent.getStringExtra(Intents.EXTRA_NUMBER); String message = intent.getStringExtra(Intents.EXTRA_MESSAGE); Log.v(TAG, "Received alarm set for id=" + profile.getId()); if (profile.getActionType() == ActionType.ALARM) { doAlarm(context, profile, number, message); } else { doNotify(context, profile); } }