So Zeigen Sie den download-Fortschritt in der Statusleiste in Android?

Ich bin mit .net web services und ich bin in der Lage, laden Sie die Datei in sd-Karte, Aber ich will zeigen, Fortschrittsbalken, wenn bestimmte Datei herunterladen und ausfüllen und dann möchte ich Möglichkeiten zeigen, wie anzeigen und Abbrechen.

Click-Ereignis, Klasse:

public void onItemClick(AdapterView<?> parent, View v, int position, long id)
{
    LazyAdapter ca = (LazyAdapter)parent.getAdapter();
    FolderList item_name = (FolderList)ca.getItem(position);
    FolderList DocumentID = (FolderList)ca.getItem(position);
    FolderList type = (FolderList)ca.getItem(position);

    Intent mIntent = new Intent();  
    mIntent.putExtra("item_name", item_name.folder_name);
    mIntent.putExtra("item_id", DocumentID.ID);
    mIntent.putExtra("item_type", type.type);

    mIntent.getStringExtra("item_name");

    String Type = mIntent.getStringExtra("item_type");

    Log.i("Type", Type);

    if {
       //Some code here...
    } else {
        Intent i = new Intent(getApplicationContext(), Display_image.class);
        i.putExtra("item_name", item_name.folder_name);
        i.putExtra("ID", DocumentID.ID);
        i.putExtra("item_type", type.type);
        i.putExtra("User_ID",User_ID);

        i.getStringExtra("item_name");
        Id = i.getStringExtra("ID");
        i.getStringExtra("item_type");
        startActivity(i);
    }
}

Meinem Code: ich möchte mit download-manager

    SoapPrimitive DocumentResponse = (SoapPrimitive)Envelope.getResponse();
        Log.i("DocumentResponse", DocumentResponse.toString());

        String DocAsString = DocumentResponse.toString();

        byte[] decodedString = Base64.decode(DocAsString, Base64.DEFAULT);

         File direct = new File(Environment.getExternalStorageDirectory() + "/MyFolder");

         if(!direct.exists())
         {
           direct.mkdir();
         }
        File photo = new File(Environment.getExternalStorageDirectory() + "/MyFolder", Name);

         if (photo.exists())
         {
           photo.delete();
         }
     try {

         DownloadManager.Request request = new DownloadManager.Request(Uri.parse(Name));
         request.setDescription("Have Fun ;)");
         request.setTitle("Downloading...");
         //in order for this if to run, you must use the android 3.2 to compile your app
         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
             request.allowScanningByMediaScanner();
             request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
         }

       FileOutputStream fos=new FileOutputStream(photo.getPath());
       fos.write(decodedString);
       fos.close();

       DownloadManager manager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
       manager.enqueue(request);

       ContentValues values= new ContentValues();

       System.out.println(values);

     }
     catch (java.io.IOException e) 
     {
       Log.e("PictureDemo", "Exception in photoCallback", e);
     }
    } 

Bitte vorschlagen, wie Sie download-manager??? Dank

InformationsquelleAutor Shweta | 2013-03-21

Schreibe einen Kommentar