Wiki
Clone wikiandroid Utils / Home
Welcome
This is an API that wraps call help you make http request, ImageUtil function, Basic Cache functionality in android application. This is in beta state that worked for my project.
Go ahead and try
$ git clone https://bitbucket.org/alexsapran/android-http.git
How to Use
- In Eclipse create a new project from existing source.
- In the project properties in the Android tab check "is Library" so you could include it later on to your project.
- From the project you already have from the properties menu in the Library section click add and select the "android-http".
After completing these steps add this code to your project
Here's an example of how to Use:
import gr.sap.android.Utils.Downloader; .... public class Myclass extends Activity { private Downloader downloader; @Override public void onCreate(Bundle savedInstanceState) { .... downloader = new Downloader(getApplicationContext()); HashMap<String,String> params = new HashMap<String,String>(); params.put("Key","value"); // this will be posted to the url InputStream val = downloader.Post(url,params); String resp = downloader.Convert(val); .... } }
If you want to use these library as an asynchronous call you have to use AsyncTask.
public class DownloadAsync extends AsyncTask<String, Void, String> { private Downloader downloader; private Context mContext; public DownloadAsync (Context mContext){ downloader = new Downloader(mContext); this.mContext = mContext; } @Override protected String doInBackground(String... params) { InputStream ins = downloader.Get(URL); String json_string = downloader.Convert(ins); return json_string; } @Override protected void onPostExecute(String result) { return result[0]; } } //and to your activity or wherever you want you can do new DownloadAsync(getApplicationContext()).execute("");
Feature Update
- Async request through the API accessed from the downloader class.
- Performance Issues
- Cache Request to files and to memory for better reusing
- Better Image Utilities
Have fun!
Updated