Reference to:http://blog.csdn.net/u012858313/article/details/38821857
Project encountered a problem, is to use the Downloadmanager when the first judge, if you have their own definition of the use of their own, no words with the system,Downloadmanager code is actually written in the project, so at first not quite understand, and then think about, Originally refers to the Downloadmanager inside the database Downloadprovider, because Downloadprovider is not in my project manifest file, but in the company's mobile phone has been defined earlier, and the system The Downloadprovider in Downloadmanager is not in my control,
1, know the Downloads.Impl.CONTENT_URI of their definition;
Private voidchoosedownloads () {cursor cursor=mcontext.getcontentresolver (). Query (URI,NULL,NULL,NULL,NULL); if(Cursor = =NULL) {Issystemdownload=true; Systemanager=(Android.app.DownloadManager) Mcontext.getsystemservice (Context.download_service); } Else{issystemdownload=false; Nonsystemmanager=downloadmanager.getinstance (Mcontext); }}
2.suspension of the Downloadmanager,
2. Downloadmanager pause, uri uri=new contentvalues ();
Values.put (Android.provider.Downloads.COLUMN_CONTROL, Android.provider.Downloads.Impl.CONTROL_PAUSED);
NULL null);
3.DownloadManager continue (Must change Downloadmanager source, because the system Downloadmanager will not ignore you to android/android-downloadmanager-pro/
Uri uri=new contentvalues (); if (Pausedforwifi) { values.put (Android.provider.Downloads.Impl.COLUMN_ALLOWED_NETWORK_TYPES, Android.app.DownloadManager.Request.NETWORK_WIFI
| nullnull);
4. Start again:
systemanager.restartdownload (Downloadid); Uri uri=newnullnull);
5. Determine whether to manually control pause or run
Uri uri=Contenturis.withappendedid (Android.provider.Downloads.Impl.CONTENT_URI, Downloadid); Cursor Cursor= Mcontext.getcontentresolver (). Query (URI,NULL,NULL,NULL,NULL); while(Cursor.movetonext ()) {intControl=Cursor.getint (Cursor.getcolumnindex (Android.provider.Downloads.Impl.COLUMN_CONTROL)); if(android.provider.downloads.impl.control_run!=control&&android.provider.downloads.impl.control_paused!) =control) { return true; }}
return false;
[Android Pro] to determine the URI corresponding to the contentprovider operation of the database U exist, and Downloadmanager pause, continue