Пример #1
0
 @Override
 public void onActivityResult(int requestCode, int resultCode, Intent data) {
   super.onActivityResult(requestCode, resultCode, data);
   if (resultCode != Activity.RESULT_OK) {
     return;
   }
   switch (requestCode) {
     case ACTIVITY_SELECT_SERVER_URL:
       Uri serverUri = data.getData();
       if (serverUri == null) {
         toast(getString(R.string.errorFailedGetServerUrl));
       } else {
         long id = Long.parseLong(serverUri.getPathSegments().get(1));
         String url =
             Utils.idToValue(
                 this, Server.Columns.CONTENT_URI, Server.Columns._ID, Server.Columns.URL, id);
         if (url != null) {
           SharedPreferences prefs =
               PreferenceManager.getDefaultSharedPreferences(getBaseContext());
           SharedPreferences.Editor editor = prefs.edit();
           editor.putString(getString(R.string.keyService), url);
           editor.commit();
         }
       }
       break;
   }
 }
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    // Refresh testbeds list

    final ListPreference testbedslist = (ListPreference) findPreference("selecttestbed");
    SharedPreferences prefs = getSharedPreferences("prefs", MODE_PRIVATE);
    ServerDatabaseHandler serverDatabase = new ServerDatabaseHandler(this);
    Server currentServer = serverDatabase.getServer(prefs.getInt("prefServerId", 0));
    serverDatabase.close();
    DataSource tempDS = new DataSource(currentServer);
    List<Testbed> testbeds = tempDS.getTestbeds();
    ArrayList<CharSequence> testbedName = new ArrayList<CharSequence>();
    ArrayList<CharSequence> testbedValues = new ArrayList<CharSequence>();
    int i;
    for (i = 0; i < testbeds.size(); i++) {
      testbedName.add(testbeds.get(i).getName());
      testbedValues.add(Integer.toString(i));
    }
    final CharSequence[] items = testbedName.toArray(new CharSequence[testbedName.size()]);
    final CharSequence[] values = testbedValues.toArray(new CharSequence[testbedValues.size()]);

    testbedslist.setEntries(items);
    testbedslist.setEntryValues(values);
  }
Пример #3
0
 @Override
 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
   super.onActivityResult(requestCode, resultCode, data);
   if (requestCode == ALARM_CONFIGURE) {
     alarmSchedulingPreferenceUpdated(mAlarmEnablePreference.isChecked());
     updateAlarmPreferences();
   }
 }
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    // Check to see if the result is from our Place Picker intent
    if (requestCode == PLACE_PICKER_REQUEST) {
      // Make sure the request was successful
      if (resultCode == RESULT_OK) {
        Place place = PlacePicker.getPlace(data, this);
        String address = place.getAddress().toString();
        LatLng latLong = place.getLatLng();

        // If the provided place doesn't have an address, we'll form a display-friendly
        // string from the latlng values.
        if (TextUtils.isEmpty(address)) {
          address = String.format("(%.2f, %.2f)", latLong.latitude, latLong.longitude);
        }

        SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
        SharedPreferences.Editor editor = sharedPreferences.edit();
        editor.putString(getString(R.string.pref_keys_location), address);

        // Also store the latitude and longitude so that we can use these to get a precise
        // result from our weather service. We cannot expect the weather service to
        // understand addresses that Google formats.
        editor.putFloat(getString(R.string.pref_location_latitude), (float) latLong.latitude);
        editor.putFloat(getString(R.string.pref_location_longitude), (float) latLong.longitude);
        editor.commit();

        /*Refresh The Preference*/
        // Tell the SyncAdapter that we've changed the location, so that we can update
        // our UI with new values. We need to do this manually because we are responding
        // to the PlacePicker widget result here instead of allowing the
        // LocationEditTextPreference to handle these changes and invoke our callbacks

        Preference locationPreference = findPreference(getString(R.string.pref_keys_location));
        locationPreference.setSummary(address);

        // Add attributions for our new PlacePicker location.
        if (mAttribution != null) {
          mAttribution.setVisibility(View.VISIBLE);
        } else {
          // For pre-Honeycomb devices, we cannot add a footer, so we will use a snackbar
          View rootView = findViewById(android.R.id.content);
          Snackbar.make(rootView, getString(R.string.attribution_text), Snackbar.LENGTH_LONG)
              .show();
        }

        Utility.resetLocationStatus(this);
        SunshineSyncAdapter.syncImmediately(this);
      }
    } else {
      super.onActivityResult(requestCode, resultCode, data);
    }
  }
Пример #5
0
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {

    if (requestCode == REQ_SCANNER_CHANNEL) {
      if (resultCode != RESULT_OK || data == null) return;
      Log.v("onActivityResult()");
      ContentQuery.dumpIntent(data);
      String description = data.getStringExtra("description");
      Intent scanIntent = data.getParcelableExtra("playIntent");
      if (description == null || scanIntent == null) return;
      ContentQuery.dumpIntent(scanIntent);

      ManagePreferences.setScannerChannel(description);
      scannerPref.setSummary(description);
      ManagePreferences.setScannerIntent(scanIntent);
      return;
    }
    super.onActivityResult(requestCode, resultCode, data);
  }
Пример #6
0
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (resultCode == RESULT_OK && requestCode == 0) {
      setResult(RESULT_OK, data);
    } else if (requestCode == 1) {
      SharedPreferences.Editor editor = settings.edit();

      StringBuffer definedKeysStr = new StringBuffer();

      for (int i = 0; i < InputHandler.keyMapping.length; i++)
        definedKeysStr.append(InputHandler.keyMapping[i] + ":");

      editor.putString(PrefsHelper.PREF_DEFINED_KEYS, definedKeysStr.toString());
      editor.commit();
      return;
    }
    finish();
  }
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
    super.onActivityResult(requestCode, resultCode, intent);
    if (resultCode == RESULT_CANCELED) {
      // request was canceled, so do nothing
      return;
    }

    switch (requestCode) {
      case IMAGE_CHOOSER:
        String sourceImagePath = null;

        // get gp of chosen file
        Uri uri = intent.getData();
        if (uri.toString().startsWith("file")) {
          sourceImagePath = uri.toString().substring(6);
        } else {
          String[] projection = {MediaColumns.DATA};
          Cursor c = null;
          try {
            c = getContentResolver().query(uri, projection, null, null, null);
            int i = c.getColumnIndexOrThrow(MediaColumns.DATA);
            c.moveToFirst();
            sourceImagePath = c.getString(i);
          } finally {
            if (c != null) {
              c.close();
            }
          }
        }

        // setting image path
        setSplashPath(sourceImagePath);
        break;
    }
  }
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
    super.onActivityResult(requestCode, resultCode, intent);

    if (resultCode == RESULT_CANCELED) {
      // request was canceled, so do nothing
      return;
    }

    switch (requestCode) {
      case IMAGE_CHOOSER:

        // get gp of chosen file
        Uri uri = intent.getData();
        String[] projection = {Images.Media.DATA};

        Cursor c = managedQuery(uri, projection, null, null, null);
        startManagingCursor(c);
        int i = c.getColumnIndexOrThrow(Images.Media.DATA);
        c.moveToFirst();

        break;
    }
  }
 @Override
 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
   super.onActivityResult(requestCode, resultCode, data);
   eventManager.fire(new OnActivityResultEvent(requestCode, resultCode, data));
 }
Пример #10
0
 @Override
 public void onActivityResult(int requestCode, int resultCode, Intent data) {
   super.onActivityResult(requestCode, resultCode, data);
   mUtility.onActivityResult(requestCode, resultCode, data);
   initPhoneInstance();
 }