Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try
- {
- new AsyncTask<Void, Void, Void>() {
- @Override
- protected Void doInBackground( Void... voids ) {
- try
- {
- URL url = new URL(SERVER_URI + "/notifications/add");
- HttpURLConnection httpCon = (HttpURLConnection) url.openConnection();
- httpCon.setDoOutput(true);
- // httpCon.setRequestProperty("Content-Type", "application/x-www-form-urlencoded" );
- // httpCon.setRequestMethod("DELETE");
- httpCon.setRequestMethod("POST");
- httpCon.setRequestProperty("Accept", "application/json");
- httpCon.connect();
- String jsonNotification = new Gson().toJson(notification);
- DataOutputStream wr = new DataOutputStream(httpCon.getOutputStream());
- wr.writeBytes(jsonNotification);
- wr.flush();
- wr.close();
- } catch(IOException e)
- {
- e.printStackTrace();
- }
- return null;
- }
- }.execute().get();
- } catch(InterruptedException e)
- {
- e.printStackTrace();
- } catch(ExecutionException e)
- {
- e.printStackTrace();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement