zoukankan      html  css  js  c++  java
  • android 广播,manifest.xml注册,代码编写

    1.种

    private void downloadBr(File file) {
      // 广播出去,由广播接收器来处理下载完成的文件
      Intent sendIntent = new Intent("com.test.downloadComplete");
      // 把下载好的文件的保存地址加进Intent
      sendIntent.putExtra("downloadFile", file.getPath());
      sendBroadcast(sendIntent);
     }

     <receiver android:name="com.yuxin.mhealth.ui.dbmanager.DownLoadBR" >
                <intent-filter>
                    <action android:name="com.test.downloadComplete" >
                    </action>
                </intent-filter>
            </receiver>

    2种

    public  static  void start(Context context,String fileUrl,String name){
      Intent downloadIntent = new Intent(context, DownloadFileService.class);
            Bundle bundle = new Bundle();
            bundle.putString("url", fileUrl);
            bundle.putString("fileName", name);
            downloadIntent.putExtras(bundle);
            context.startService(downloadIntent);
     }

        <service android:name="com.yuxin.mhealth.ui.dbmanager.DownloadFileService" >
            </service>

  • 相关阅读:
    使用IOCP完成端口队列做任务队列
    对Zlib单元进行再封装
    XmlReader/XmlWriter 类
    TextReader/TextWriter 的类
    LINQ to XML
    Xml序列化
    动态Linq(结合反射)
    设计模式总结
    深入了解.Net上下文
    应用程序域
  • 原文地址:https://www.cnblogs.com/melons/p/5791945.html
Copyright © 2011-2022 走看看