0
回答
用DownloadManager实现监听下载完成?
华为云4核8G,高性能云服务器,免费试用   
public void funclick(View v1){  
		        String serviceString = Context.DOWNLOAD_SERVICE;  
		        DownloadManager downloadManager;  
		        downloadManager = (DownloadManager)getSystemService(serviceString);  
		          
		        Uri uri = Uri.parse("http://10.10.11.111/download3/download/yangqitingshu_45.apk");  
		        DownloadManager.Request request = new Request(uri);  
		        request.setAllowedNetworkTypes(Request.NETWORK_WIFI);  
		        downloadManager.getRecommendedMaxBytesOverMobile(getApplicationContext());  
		        final long myreference = downloadManager.enqueue(request);  
		          
		        IntentFilter filter = new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE );  
		        BroadcastReceiver receiver = new BroadcastReceiver(){  
		      
		            @Override  
		            public void onReceive(Context context, Intent intent) {  
		                long reference = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID,-1);  
		                    if(reference == myreference){  
		                        //对下载的文件进行一些操作  
		                    	Log.e(TAG, "AAAAAAAAAAAAAAAAAAAAAAAAA");
		                    }  
		            }  
		              
		        };  
		        registerReceiver(receiver, filter);  
		    }



Android开发中,想实现监听下载完成并自动显示安装界面,不知道怎么实现,监听下载完成的代码如下,但是一直无法完成,不知道怎么修改?代码如下,
<无标签>
举报
christinalgz
发帖于3年前 0回/1K+阅
顶部