Example usage for android.content Intent getStringExtra

List of usage examples for android.content Intent getStringExtra

Introduction

In this page you can find the example usage for android.content Intent getStringExtra.

Prototype

public String getStringExtra(String name) 

Source Link

Document

Retrieve extended data from the intent.

Usage

From source file:com.josecarlos.couplecounters.MainActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {

    Log.i("CC", "Entered onActivityResult()");

    if (requestCode == LOGIN_REQUEST && resultCode == RESULT_OK) {
        currentPartner1 = data.getStringExtra("partner1");
        currentPartner2 = data.getStringExtra("partner2");
        namePartner1 = data.getStringExtra("name1");
        namePartner2 = data.getStringExtra("name2");
        Log.i("CC", currentPartner1 + " " + currentPartner2);
        String[] countersName = data.getStringArrayExtra("countersName");
        String[] countersType = data.getStringArrayExtra("countersType");
        for (int i = 0; i < countersName.length; i++) {
            Log.i("CC", countersName[i]);
            listAdapter.add(new CounterItem(countersName[i], "1".equals(countersType[i])));
        }/*from  w  w w . j a v a2s  . com*/
    } else if (requestCode == COUNTER_REQUEST && resultCode == RESULT_OK) {
        String newCounter = data.getStringExtra("counter");
        String commonCounter = data.getStringExtra("common");
        listAdapter.add(new CounterItem(newCounter, "1".equals(commonCounter)));
    }

    else if (requestCode == EDIT_REQUEST && resultCode == RESULT_OK) {
        CounterItem item = listAdapter.getItem(currentCounter);
        item.setCounterName(data.getStringExtra("counter"));
        listAdapter.set(currentCounter, item);
    }

}

From source file:de.grobox.blitzmail.SendActivity.java

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // before doing anything show notification about sending process
    mNotifyManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    mBuilder = new NotificationCompat.Builder(this);
    mBuilder.setContentTitle(getString(R.string.sending_mail)).setContentText(getString(R.string.please_wait))
            .setSmallIcon(R.drawable.notification_icon).setOngoing(true);
    // Sets an activity indicator for an operation of indeterminate length
    mBuilder.setProgress(0, 0, true);/*w w w.j a  va2 s.  c o  m*/
    // Create Pending Intent
    notifyIntent = new Intent(this, NotificationHandlerActivity.class);
    notifyIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notifyIntent,
            PendingIntent.FLAG_UPDATE_CURRENT);
    mBuilder.setContentIntent(pendingIntent);
    // Issues the notification
    mNotifyManager.notify(0, mBuilder.build());

    Properties prefs;
    try {
        prefs = getPrefs();
    } catch (Exception e) {
        String msg = e.getMessage();

        Log.i("SendActivity", "ERROR: " + msg, e);

        if (e.getClass().getCanonicalName().equals("java.lang.RuntimeException") && e.getCause() != null
                && e.getCause().getClass().getCanonicalName().equals("javax.crypto.BadPaddingException")) {
            msg = getString(R.string.error_decrypt);
        }

        showError(msg);
        return;
    }

    // get and handle Intent
    Intent intent = getIntent();
    String action = intent.getAction();

    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

    if (action.equals(Intent.ACTION_SEND)) {
        String text = intent.getStringExtra(Intent.EXTRA_TEXT);
        //String email   = intent.getStringExtra(Intent.EXTRA_EMAIL);
        String subject = intent.getStringExtra(Intent.EXTRA_SUBJECT);
        String cc = intent.getStringExtra(Intent.EXTRA_CC);
        String bcc = intent.getStringExtra(Intent.EXTRA_BCC);

        // Check for empty content
        if (subject == null && text != null) {
            // cut all characters from subject after the 128th
            subject = text.substring(0, (text.length() < 128) ? text.length() : 128);
            // remove line breaks from subject
            subject = subject.replace("\n", " ").replace("\r", " ");
        } else if (subject != null && text == null) {
            text = subject;
        } else if (subject == null && text == null) {
            Log.e("Instant Mail", "Did not send mail, because subject and body empty.");
            showError(getString(R.string.error_no_body_no_subject));
            return;
        }

        // create JSON object with mail information
        mMail = new JSONObject();
        try {
            mMail.put("id", String.valueOf(new Date().getTime()));
            mMail.put("body", text);
            mMail.put("subject", subject);
            mMail.put("cc", cc);
            mMail.put("bcc", bcc);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        // remember mail for later
        MailStorage.saveMail(this, mMail);

        // pass mail on to notification dialog class
        notifyIntent.putExtra("mail", mMail.toString());

        // Start Mail Task
        AsyncMailTask mail = new AsyncMailTask(this, prefs, mMail);
        mail.execute();
    } else if (action.equals("BlitzMailReSend")) {
        try {
            mMail = new JSONObject(intent.getStringExtra("mail"));
        } catch (JSONException e) {
            e.printStackTrace();
        }

        // pass mail on to notification dialog class
        notifyIntent.putExtra("mail", mMail.toString());

        // Start Mail Task
        AsyncMailTask mail = new AsyncMailTask(this, prefs, mMail);
        mail.execute();
    }
    finish();
}

From source file:com.luyaozhou.recognizethisforglass.ViewFinder.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == RESULT_OK && requestCode == PHOTO_REQUEST_CODE) {
        String photoFileName = data.getStringExtra(Intents.EXTRA_THUMBNAIL_FILE_PATH);
        String picturePath = data.getStringExtra(Intents.EXTRA_PICTURE_FILE_PATH);
        processPictureWhenReady(picturePath);
    }/*from  ww w .  j a  v a 2 s. c  o m*/
    super.onActivityResult(requestCode, resultCode, data);
}

From source file:cc.arduino.mvd.services.BinocularService.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {

    if (!started) {
        url = intent.getStringExtra(MvdServiceReceiver.EXTRA_SERVICE_URL);

        // Make sure the url ends with a slash
        if (!url.endsWith("/")) {
            url = url + "/";
        }/*from   ww w .j  a v a 2 s. co m*/

        //delay = intent.getIntExtra(MvdServiceReceiver.EXTRA_SERVICE_DELAY, 5000);
        delay = 2000;

        startGetRequests(delay);

        started = true;

        if (DEBUG) {
            Log.d(TAG, TAG + " started.");
        }
    }

    return START_STICKY;
}

From source file:cm.aptoide.pt.RemoteInSearch.java

@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    query = intent.getStringExtra(SearchManager.QUERY);
    apk_lst = db.getSearch(query, order_lst);
}

From source file:com.inbeacon.cordova.CordovaInbeaconManager.java

/**
 * Transform Android event data into JSON Object used by JavaScript
 * @param intent inBeacon SDK event data
 * @return a JSONObject with keys 'event', 'name' and 'data'
 *//* www  .j  a  v a  2  s. co  m*/
private JSONObject getEventObject(Intent intent) {
    String action = intent.getAction();
    String event = action.substring(action.lastIndexOf(".") + 1); // last part of action
    String message = intent.getStringExtra("message");
    Bundle extras = intent.getExtras();

    JSONObject eventObject = new JSONObject();
    JSONObject data = new JSONObject();

    try {
        if (extras != null) {
            Set<String> keys = extras.keySet();
            for (String key : keys) {
                data.put(key, extras.get(key)); // Android API < 19
                //                    data.put(key, JSONObject.wrap(extras.get(key)));    // Android API >= 19
            }
        }
        data.put("message", message);

        eventObject.put("name", event);
        eventObject.put("data", data);

    } catch (JSONException e) {
        Log.e(TAG, e.getMessage(), e);
    }

    return eventObject;
}

From source file:com.aafr.alfonso.sunshine.app.service.SunshineService.java

@Override
protected void onHandleIntent(Intent intent) {
    String locationQuery = intent.getStringExtra(LOCATION_QUERY_EXTRA);

    // These two need to be declared outside the try/catch
    // so that they can be closed in the finally block.
    HttpURLConnection urlConnection = null;
    BufferedReader reader = null;

    // Will contain the raw JSON response as a string.
    String forecastJsonStr = null;

    String format = "json";
    String units = "metric";
    int numDays = 14;

    try {//from w  ww.j a  va  2  s .  co m
        // Construct the URL for the OpenWeatherMap query
        // Possible parameters are avaiable at OWM's forecast API page, at
        // http://openweathermap.org/API#forecast
        final String FORECAST_BASE_URL = "http://api.openweathermap.org/data/2.5/forecast/daily?";
        final String QUERY_PARAM = "q";
        final String FORMAT_PARAM = "mode";
        final String UNITS_PARAM = "units";
        final String DAYS_PARAM = "cnt";

        Uri builtUri = Uri.parse(FORECAST_BASE_URL).buildUpon().appendQueryParameter(QUERY_PARAM, locationQuery)
                .appendQueryParameter(FORMAT_PARAM, format).appendQueryParameter(UNITS_PARAM, units)
                .appendQueryParameter(DAYS_PARAM, Integer.toString(numDays)).build();

        URL url = new URL(builtUri.toString());

        // Create the request to OpenWeatherMap, and open the connection
        urlConnection = (HttpURLConnection) url.openConnection();
        urlConnection.setRequestMethod("GET");
        urlConnection.connect();

        // Read the input stream into a String
        InputStream inputStream = urlConnection.getInputStream();
        StringBuffer buffer = new StringBuffer();
        if (inputStream == null) {
            // Nothing to do.
            return;
        }

        reader = new BufferedReader(new InputStreamReader(inputStream));
        String line;
        while ((line = reader.readLine()) != null) {
            // Since it's JSON, adding a newline isn't necessary (it won't affect parsing)
            // But it does make debugging a *lot* easier if you print out the completed
            // buffer for debugging.
            buffer.append(line);
            buffer.append("\n");
        }

        if (buffer.length() == 0) {
            // Stream was empty.  No point in parsing.
            return;
        }
        forecastJsonStr = buffer.toString();
    } catch (IOException e) {
        Log.e(LOG_TAG, "Error ", e);
        // If the code didn't successfully get the weather data, there's no point in attempting
        // to parse it.
        return;
    } finally {
        if (urlConnection != null) {
            urlConnection.disconnect();
        }
        if (reader != null) {
            try {
                reader.close();
            } catch (final IOException e) {
                Log.e(LOG_TAG, "Error closing stream", e);
            }
        }
    }

    // Now we have a String representing the complete forecast in JSON Format.
    // Fortunately parsing is easy:  constructor takes the JSON string and converts it
    // into an Object hierarchy for us.

    // These are the names of the JSON objects that need to be extracted.

    // Location information
    final String OWM_CITY = "city";
    final String OWM_CITY_NAME = "name";
    final String OWM_COORD = "coord";

    // Location coordinate
    final String OWM_LATITUDE = "lat";
    final String OWM_LONGITUDE = "lon";

    // Weather information.  Each day's forecast info is an element of the "list" array.
    final String OWM_LIST = "list";

    final String OWM_DATETIME = "dt";
    final String OWM_PRESSURE = "pressure";
    final String OWM_HUMIDITY = "humidity";
    final String OWM_WINDSPEED = "speed";
    final String OWM_WIND_DIRECTION = "deg";

    // All temperatures are children of the "temp" object.
    final String OWM_TEMPERATURE = "temp";
    final String OWM_MAX = "max";
    final String OWM_MIN = "min";

    final String OWM_WEATHER = "weather";
    final String OWM_DESCRIPTION = "main";
    final String OWM_WEATHER_ID = "id";

    try {
        JSONObject forecastJson = new JSONObject(forecastJsonStr);
        JSONArray weatherArray = forecastJson.getJSONArray(OWM_LIST);

        JSONObject cityJson = forecastJson.getJSONObject(OWM_CITY);
        String cityName = cityJson.getString(OWM_CITY_NAME);

        JSONObject cityCoord = cityJson.getJSONObject(OWM_COORD);
        double cityLatitude = cityCoord.getDouble(OWM_LATITUDE);
        double cityLongitude = cityCoord.getDouble(OWM_LONGITUDE);

        long locationId = addLocation(locationQuery, cityName, cityLatitude, cityLongitude);

        // Insert the new weather information into the database
        Vector<ContentValues> cVVector = new Vector<ContentValues>(weatherArray.length());

        for (int i = 0; i < weatherArray.length(); i++) {
            // These are the values that will be collected.

            long dateTime;
            double pressure;
            int humidity;
            double windSpeed;
            double windDirection;

            double high;
            double low;

            String description;
            int weatherId;

            // Get the JSON object representing the day
            JSONObject dayForecast = weatherArray.getJSONObject(i);

            // The date/time is returned as a long.  We need to convert that
            // into something human-readable, since most people won't read "1400356800" as
            // "this saturday".
            dateTime = dayForecast.getLong(OWM_DATETIME);

            pressure = dayForecast.getDouble(OWM_PRESSURE);
            humidity = dayForecast.getInt(OWM_HUMIDITY);
            windSpeed = dayForecast.getDouble(OWM_WINDSPEED);
            windDirection = dayForecast.getDouble(OWM_WIND_DIRECTION);

            // Description is in a child array called "weather", which is 1 element long.
            // That element also contains a weather code.
            JSONObject weatherObject = dayForecast.getJSONArray(OWM_WEATHER).getJSONObject(0);
            description = weatherObject.getString(OWM_DESCRIPTION);
            weatherId = weatherObject.getInt(OWM_WEATHER_ID);

            // Temperatures are in a child object called "temp".  Try not to name variables
            // "temp" when working with temperature.  It confuses everybody.
            JSONObject temperatureObject = dayForecast.getJSONObject(OWM_TEMPERATURE);
            high = temperatureObject.getDouble(OWM_MAX);
            low = temperatureObject.getDouble(OWM_MIN);

            ContentValues weatherValues = new ContentValues();

            weatherValues.put(WeatherContract.WeatherEntry.COLUMN_LOC_KEY, locationId);
            weatherValues.put(WeatherContract.WeatherEntry.COLUMN_DATETEXT,
                    WeatherContract.getDbDateString(new Date(dateTime * 1000L)));
            weatherValues.put(WeatherContract.WeatherEntry.COLUMN_HUMIDITY, humidity);
            weatherValues.put(WeatherContract.WeatherEntry.COLUMN_PRESSURE, pressure);
            weatherValues.put(WeatherContract.WeatherEntry.COLUMN_WIND_SPEED, windSpeed);
            weatherValues.put(WeatherContract.WeatherEntry.COLUMN_DEGREES, windDirection);
            weatherValues.put(WeatherContract.WeatherEntry.COLUMN_MAX_TEMP, high);
            weatherValues.put(WeatherContract.WeatherEntry.COLUMN_MIN_TEMP, low);
            weatherValues.put(WeatherContract.WeatherEntry.COLUMN_SHORT_DESC, description);
            weatherValues.put(WeatherContract.WeatherEntry.COLUMN_WEATHER_ID, weatherId);

            cVVector.add(weatherValues);
        }
        if (cVVector.size() > 0) {
            ContentValues[] cvArray = new ContentValues[cVVector.size()];
            cVVector.toArray(cvArray);
            this.getContentResolver().bulkInsert(WeatherContract.WeatherEntry.CONTENT_URI, cvArray);

        }
        Log.d(LOG_TAG, "Sunshine Service Complete. " + cVVector.size() + " Inserted");

    } catch (JSONException e) {
        Log.e(LOG_TAG, e.getMessage(), e);
        e.printStackTrace();
    }

}

From source file:net.olejon.mdapp.PoisoningsCardsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Connected?
    if (!mTools.isDeviceConnected()) {
        mTools.showToast(getString(R.string.device_not_connected), 1);

        finish();//  ww w.j a  v  a  2 s.c  o  m

        return;
    }

    // Intent
    final Intent intent = getIntent();

    searchString = intent.getStringExtra("search");

    // Layout
    setContentView(R.layout.activity_poisonings_cards);

    // Toolbar
    mToolbar = (Toolbar) findViewById(R.id.poisonings_cards_toolbar);
    mToolbar.setTitle(getString(R.string.poisonings_cards_search) + ": \"" + searchString + "\"");

    setSupportActionBar(mToolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    // Progress bar
    mProgressBar = (ProgressBar) findViewById(R.id.poisonings_cards_toolbar_progressbar);
    mProgressBar.setVisibility(View.VISIBLE);

    // Refresh
    mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.poisonings_cards_swipe_refresh_layout);
    mSwipeRefreshLayout.setColorSchemeResources(R.color.accent_blue, R.color.accent_green,
            R.color.accent_purple, R.color.accent_orange);

    mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            search(searchString, false);
        }
    });

    // Recycler view
    mRecyclerView = (RecyclerView) findViewById(R.id.poisonings_cards_cards);

    mRecyclerView.setHasFixedSize(true);
    mRecyclerView.setAdapter(new PoisoningsCardsAdapter(mContext, new JSONArray()));
    mRecyclerView.setLayoutManager(new LinearLayoutManager(mContext));

    // No poisonings
    mNoPoisoningsLayout = (LinearLayout) findViewById(R.id.poisonings_cards_no_poisonings);

    Button noPoisoningsHelsenorgeButton = (Button) findViewById(R.id.poisonings_cards_check_on_helsenorge);
    Button noPoisoningsHelsebiblioteketButton = (Button) findViewById(
            R.id.poisonings_cards_check_on_helsebiblioteket);

    noPoisoningsHelsenorgeButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            try {
                Intent intent = new Intent(mContext, MainWebViewActivity.class);
                intent.putExtra("title",
                        getString(R.string.poisonings_cards_search) + ": \"" + searchString + "\"");
                intent.putExtra("uri", "https://helsenorge.no/sok/giftinformasjon/?k="
                        + URLEncoder.encode(searchString.toLowerCase(), "utf-8"));
                mContext.startActivity(intent);
            } catch (Exception e) {
                Log.e("PoisoningsCardsActivity", Log.getStackTraceString(e));
            }
        }
    });

    noPoisoningsHelsebiblioteketButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            try {
                Intent intent = new Intent(mContext, MainWebViewActivity.class);
                intent.putExtra("title",
                        getString(R.string.poisonings_cards_search) + ": \"" + searchString + "\"");
                intent.putExtra("uri",
                        "http://www.helsebiblioteket.no/forgiftninger/alle-anbefalinger?cx=005475784484624053973%3A3bnj2dj_uei&ie=UTF-8&q="
                                + URLEncoder.encode(searchString.toLowerCase(), "utf-8") + "&sa=S%C3%B8k");
                mContext.startActivity(intent);
            } catch (Exception e) {
                Log.e("PoisoningsCardsActivity", Log.getStackTraceString(e));
            }
        }
    });

    // Search
    search(searchString, true);

    // Correct
    RequestQueue requestQueue = Volley.newRequestQueue(mContext);

    try {
        JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.GET,
                getString(R.string.project_website_uri) + "api/1/correct/?search="
                        + URLEncoder.encode(searchString, "utf-8"),
                new Response.Listener<JSONObject>() {
                    @Override
                    public void onResponse(JSONObject response) {
                        try {
                            final String correctSearchString = response.getString("correct");

                            if (!correctSearchString.equals("")) {
                                new MaterialDialog.Builder(mContext)
                                        .title(getString(R.string.correct_dialog_title))
                                        .content(Html.fromHtml(getString(R.string.correct_dialog_message)
                                                + ":<br><br><b>" + correctSearchString + "</b>"))
                                        .positiveText(getString(R.string.correct_dialog_positive_button))
                                        .negativeText(getString(R.string.correct_dialog_negative_button))
                                        .callback(new MaterialDialog.ButtonCallback() {
                                            @Override
                                            public void onPositive(MaterialDialog dialog) {
                                                ContentValues contentValues = new ContentValues();
                                                contentValues.put(PoisoningsSQLiteHelper.COLUMN_STRING,
                                                        correctSearchString);

                                                SQLiteDatabase sqLiteDatabase = new PoisoningsSQLiteHelper(
                                                        mContext).getWritableDatabase();

                                                sqLiteDatabase.delete(PoisoningsSQLiteHelper.TABLE,
                                                        PoisoningsSQLiteHelper.COLUMN_STRING + " = "
                                                                + mTools.sqe(searchString) + " COLLATE NOCASE",
                                                        null);
                                                sqLiteDatabase.insert(PoisoningsSQLiteHelper.TABLE, null,
                                                        contentValues);

                                                sqLiteDatabase.close();

                                                mToolbar.setTitle(getString(R.string.poisonings_cards_search)
                                                        + ": \"" + correctSearchString + "\"");

                                                mProgressBar.setVisibility(View.VISIBLE);

                                                mNoPoisoningsLayout.setVisibility(View.GONE);
                                                mSwipeRefreshLayout.setVisibility(View.VISIBLE);

                                                search(correctSearchString, true);
                                            }
                                        }).contentColorRes(R.color.black).positiveColorRes(R.color.dark_blue)
                                        .negativeColorRes(R.color.black).show();
                            }
                        } catch (Exception e) {
                            Log.e("PoisoningsCardsActivity", Log.getStackTraceString(e));
                        }
                    }
                }, new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {
                        Log.e("PoisoningsCardsActivity", error.toString());
                    }
                });

        jsonObjectRequest.setRetryPolicy(new DefaultRetryPolicy(10000, DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
                DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));

        requestQueue.add(jsonObjectRequest);
    } catch (Exception e) {
        Log.e("PoisoningsCardsActivity", Log.getStackTraceString(e));
    }
}

From source file:com.example.cuisoap.agrimac.homePage.homeFragment.java

public void onActivityResult(int requestCode, int resultCode, Intent i) {
    if (requestCode == 0) {
        try {/*from  ww  w.j  a  v  a  2 s . c  o m*/
            if (resultCode == Activity.RESULT_CANCELED)
                ;
            else {
                System.out.println(i.getStringExtra("data"));
                JSONObject m = new JSONObject(i.getStringExtra("data"));
                HashMap<String, String> s = new HashMap<>();
                s.put("machine_name", m.getString("machine_name"));
                s.put("machine_powertype", m.getString("machine_powertype"));
                s.put("machine_power", m.getString("machine_power"));
                s.put("passenger_num", m.getString("passenger_num"));
                s.put("machine_paytype", m.getString("machine_paytype"));
                s.put("machine_type", m.getString("machine_type"));
                s.put("machine_wheeldistance", m.getString("machine_wheeldistance"));
                s.put("machine_checktime", m.getString("machine_checktime"));
                s.put("machine_license1", m.getString("machine_license1"));
                s.put("machine_license2", m.getString("machine_license2"));
                s.put("drive_type", m.getString("drive_type"));
                if (m.getString("drive_type").equals("1")) {
                    s.put("driver_name", m.getString("driver_name"));
                    s.put("driver_age", m.getString("driver_age"));
                    s.put("driver_gender", m.getString("driver_gender"));
                    s.put("driver_license_type", m.getString("driver_license_type"));
                    s.put("driver_license", m.getString("driver_license"));
                }
                s.put("lease_month", m.getString("lease_month"));
                s.put("lease_time", m.getString("lease_time"));
                s.put("need_type", m.getString("need_type"));
                if (m.getString("need_type").equals("2")) {
                    s.put("need_item", m.getString("need_item"));
                }
                s.put("work_condition", m.getString("work_condition"));
                s.put("machine_house", m.getString("house_type"));
                data.add(s);
                adapter.setData(data);
                adapter.notifyDataSetChanged();
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
    } else if (requestCode == 1) {
        if (resultCode == Activity.RESULT_CANCELED) {
            System.out.println("canceled");
        } else if (resultCode == -1) {
            removeDataItem((HashMap<String, String>) i.getSerializableExtra("data"));
        } else {
            replaceDataItem((HashMap<String, String>) i.getSerializableExtra("data"));
            System.out.println(data.size());
        }
        adapter.setData(data);
        adapter.notifyDataSetChanged();
    }
}