protected void onPostExecute(LocationManager lm) {
   // Start feeds on Musubi
   List<MLocation> locations = lm.getLocations();
   JSONObject toCreate = new JSONObject();
   JSONArray outerArr = new JSONArray();
   ArrayList<String> principals = new ArrayList<String>();
   for (MLocation location : locations) {
     if (location.feedUri == null && !location.principal.equals("")) {
       JSONObject primary = new JSONObject();
       JSONArray arr = new JSONArray();
       JSONObject one = new JSONObject();
       try {
         if (location.principal == null
             || Util.getPickedAccountType(OmniStanfordBaseActivity.this) == null
             || (location.feedUri != null && !location.feedUri.equals(""))) {
           continue;
         }
         primary.put("visible", false);
         one.put(
             "hashed",
             Base64.encodeToString(
                 OmniStanfordBaseActivity.digestPrincipal(location.principal), Base64.DEFAULT));
         one.put("name", location.name);
         one.put("type", location.accountType);
         principals.add(location.principal);
         arr.put(0, one);
         primary.put("members", arr);
         primary.put("sender", Util.getPickedAccountType(OmniStanfordBaseActivity.this));
         outerArr.put(primary);
       } catch (JSONException e) {
         Log.e(TAG, "JSON parse error", e);
         return;
       }
     }
   }
   try {
     toCreate.put("array", outerArr);
     if (outerArr.length() > 0) {
       Intent intent = new Intent(ACTION_CREATE_STANFORD_FEED);
       intent.putExtra(EXTRA_NAME, toCreate.toString());
       Log.d(TAG, "starting...");
       Log.d(TAG, toCreate.toString());
       intent.putStringArrayListExtra("principals", principals);
       Log.d(TAG, "sent principals: " + principals);
       try {
         startActivityForResult(intent, REQUEST_CREATE_FEED);
       } catch (ActivityNotFoundException e) {
         Log.w(TAG, "activity not found", e);
       }
     }
   } catch (JSONException e) {
     Log.e(TAG, "JSON error", e);
   }
 }
 private void setActionBar() {
   String currentName = Util.getPickedAccountName(this);
   if (currentName != null) {
     ActionBar bar = getSupportActionBar();
     if (bar != null && currentName != null) {
       bar.setTitle(currentName);
     }
   }
 }
  @Override
  public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == REQUEST_PICK_ID) {
      if (resultCode == RESULT_OK) {
        ArrayList<String> names = data.getStringArrayListExtra("names");
        ArrayList<String> types = data.getStringArrayListExtra("types");
        ArrayList<String> hashes = data.getStringArrayListExtra("principal_hashes");
        Log.d(TAG, "Names: " + names);
        Log.d(TAG, "Types: " + types);
        Log.d(TAG, "Hashes: " + hashes);
        // TODO: use the first returned account

        int i;
        for (i = 0; i < types.size(); i++) {
          if (types.get(i).equals(ACCOUNT_TYPE_STANFORD)) {
            break;
          }
        }
        if (i == types.size()) {
          i = 0;
        }

        for (int j = 0; j < names.size(); j++) {
          Util.saveAccount(this, names.get(j), hashes.get(j), types.get(j));
        }

        Util.setPickedAccount(this, names.get(i), types.get(i), hashes.get(i));

        if (Musubi.isMusubiInstalled(this)) {
          new CreateFeedsTask().execute(App.getDatabaseSource(this));
        }
      }
    } else if (requestCode == REQUEST_CREATE_FEED) {
      if (resultCode == RESULT_OK) {
        Log.d(TAG, "got a feed start result");
        Uri feedUri = data.getData();
        if (feedUri != null) {
          // Single feed
          Log.d(TAG, "Feed URI: " + feedUri);
        } else if (data.getStringArrayListExtra("uris") != null
            && data.getStringArrayListExtra("principals") != null) {
          // Multiple feeds
          ArrayList<String> array = data.getStringArrayListExtra("uris");
          ArrayList<String> principals = data.getStringArrayListExtra("principals");
          LocationManager lm = new LocationManager(App.getDatabaseSource(this));
          for (int i = 0; i < array.size(); i++) {
            Log.d(TAG, "Principal: " + principals.get(i));
            List<MLocation> locs = lm.getLocationWithDuplicates(principals.get(i));
            for (MLocation loc : locs) {
              if (loc != null) {
                loc.feedUri = Uri.parse(array.get(i));
                Log.i(TAG, loc.feedUri.toString());
                lm.updateLocation(loc);
              }
            }
          }
        }
      }
    }
  }