Download File Using service
<p>I'm trying to make download manager to android, So when I'm trying to start the service it's give me errors</p>

<p>In my Manifest I have declare service name and I got internet permission and write on external storage permission</p>

<p>This is the main Activity:</p>

<pre><code>public class DownloadLabMyClassActivity extends Activity {
    Button downloadButton;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        downloadButton = (Button) findViewById(R.id.button1);
        downloadButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent serviceIntent = new Intent(DownloadLabMyClassActivity.this,DownloadService.class);
                startService(serviceIntent);
            }
        });
}
}
</code></pre>

<p>This is the service</p>

<pre><code>public class DownloadService extends IntentService {


    public DownloadService(String name) {
        super("");
        // TODO Auto-generated constructor stub
    }

    @Override
    protected void onHandleIntent(Intent arg0) {
        // TODO Auto-generated method stub
        Log.d("service", "onHandleIntent()");
    /*          try {
            URL fileUrl = new URL("http://goo.gl/Mfyya");

            HttpURLConnection urlConnection = (HttpURLConnection)fileUrl.openConnection();
            urlConnection.setRequestMethod("GET");
            urlConnection.setDoOutput(true);
            urlConnection.connect();

            File sdcard = Environment.getExternalStorageDirectory();
            File file = new File (sdcard, "filename.ext");

            FileOutputStream fileoutput = new FileOutputStream (file);
            InputStream inputstream = urlConnection.getInputStream();

            int totalSize = urlConnection.getContentLength();
            int downloadedSize = 0;
            byte[] buffer = new byte[1024];
            int bufferlength =0;

            while ((bufferlength = inputstream.read(buffer)) &gt; 0)
            {   
                fileoutput.write(buffer, 0, bufferlength);
                downloadedSize += bufferlength;
                //updateProgress(downloadedSize, totalSize);
            }
            fileoutput.close();
        } catch (IOException e) {
            Log.d("service", "error");
            //e.printStackTrace();
        }*/
    }
}
</code></pre>

<p>and this the error :</p>

<pre><code>11-20 09:38:21.107: E/AndroidRuntime(1627): FATAL EXCEPTION: main
11-20 09:38:21.107: E/AndroidRuntime(1627): java.lang.RuntimeException: Unable to instantiate service com.test2.lab.DownloadService: java.lang.InstantiationException: can't instantiate class com.test2.lab.DownloadService; no empty constructor
11-20 09:38:21.107: E/AndroidRuntime(1627):     at android.app.ActivityThread.handleCreateService(ActivityThread.java:2237)
11-20 09:38:21.107: E/AndroidRuntime(1627):     at android.app.ActivityThread.access$1600(ActivityThread.java:123)
11-20 09:38:21.107: E/AndroidRuntime(1627):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1201)
11-20 09:38:21.107: E/AndroidRuntime(1627):     at android.os.Handler.dispatchMessage(Handler.java:99)
11-20 09:38:21.107: E/AndroidRuntime(1627):     at android.os.Looper.loop(Looper.java:137)
11-20 09:38:21.107: E/AndroidRuntime(1627):     at android.app.ActivityThread.main(ActivityThread.java:4424)
11-20 09:38:21.107: E/AndroidRuntime(1627):     at java.lang.reflect.Method.invokeNative(Native Method)
11-20 09:38:21.107: E/AndroidRuntime(1627):     at java.lang.reflect.Method.invoke(Method.java:511)
11-20 09:38:21.107: E/AndroidRuntime(1627):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
11-20 09:38:21.107: E/AndroidRuntime(1627):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
11-20 09:38:21.107: E/AndroidRuntime(1627):     at dalvik.system.NativeStart.main(Native Method)
11-20 09:38:21.107: E/AndroidRuntime(1627): Caused by: java.lang.InstantiationException: can't instantiate class com.test2.lab.DownloadService; no empty constructor
11-20 09:38:21.107: E/AndroidRuntime(1627):     at java.lang.Class.newInstanceImpl(Native Method)
11-20 09:38:21.107: E/AndroidRuntime(1627):     at java.lang.Class.newInstance(Class.java:1319)
11-20 09:38:21.107: E/AndroidRuntime(1627):     at android.app.ActivityThread.handleCreateService(ActivityThread.java:2234)
11-20 09:38:21.107: E/AndroidRuntime(1627):     ... 10 more
</code></pre>

<p></p>

<p>My questions :</p></p>

<ul>
<li>How to start this service correctly?</li>
<li>The needed permission and if anything missing?</li>
<li>How to download multiple files using this service?</li>
<li>Can I instantiate this service for every file and add it to a list of them, so in the future I can pause or resume the whole list or specific service?</li>
</ul>
