android 广播,manifest.xml注册,代码编写
2014-11-27 17:40
387 查看
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>
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>
相关文章推荐
- android 广播,manifest.xml注册,代码编写
- BroadcastReceiver(一)在AndroidManifest.xml中配置的广播接收器(自动注册注销)
- BroadcastReceiver广播接收者(二)——利用AndroidManifest.xml注册广播接收者
- [置顶] 关于在AndroidManifest.xml注册的广播和activity使用回调的问题
- android的广播介绍,在manifest .xml中注册广播
- android eclipse中在androidmanifest.xml注册的问题-----代码
- BroadcastReceiver广播接收者(二)——利用AndroidManifest.xml注册广播接收者
- android eclipse中在androidmanifest.xml注册的问题
- android 注册广播代码(备用)
- mars android开发之一:在AndroidMainfest.xml中注册广播
- android 代码方式注册广播接收着
- 调用没有在AndroidManifest.xml注册过的Activity,报出的错误提示
- Java代码改变AndroidManifest.xml的包名和icon值
- Android APK反编译方法(可以获取APK xml和android Manifest,java代码等内容)
- 调用没有在AndroidManifest.xml注册过的Activity,报出的错误提示
- android之旅19 代码注册广播接收者
- android中代码形式注册广播接收者
- AndroidManifest.xml 注册服务
- Android APK反编译方法(可以获取APK xml和android Manifest,java代码等内容)
- 每一个activity都要在AndroidManifest.xml注册和字体