Category : http

After reading Tutorials on the internet I came up with this function for downloading a sound file from HTTP: try { URL url = new URL(filePath); HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection(); urlConnection.setRequestMethod("GET"); urlConnection.setDoOutput(true); urlConnection.connect(); File storage = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS); File directory = new File(storage.getAbsolutePath()); directory.mkdirs(); file = new File(directory, fileName + ".mp3"); FileOutputStream fileOutput = new ..

Read more

I am using this solution to make server request. String message = URLEncoder.encode("my message", "UTF-8"); try { // instantiate the URL object with the target URL of the resource to // request URL url = new URL("http://www.example.com/comment"); // instantiate the HttpURLConnection with the URL object – A new // connection is opened every time by ..

Read more

protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); listView= findViewById(R.id.liste); String showUrl = "https://xxxxxxxx.php?password="; final JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.POST, showUrl, null, new Response.Listener<JSONObject>() { @Override public void onResponse(JSONObject response) { System.out.println(response.toString()); try { String a, b, c; JSONArray showarray = response.getJSONArray("showarray"); final ArrayList<String> arrayListim = new ArrayList<String>(); final ArrayAdapter<String> adaptor = new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_list_item_1, arrayListim); for ..

Read more