Android 更新升级下载 自定义Updates 兼容版,android蓝牙开发的基本流程

本文介绍了Android应用中实现自定义更新下载服务的详细流程,包括使用Intent Service进行下载管理和进度通知。同时,文章提及了Android蓝牙开发的基础知识,帮助开发者了解相关开发流程。
摘要由CSDN通过智能技术生成

Intent service = new Intent(this, DownloadService.class);

service.putExtra(DownloadService.INTENT_URL, dl);

startService(service);

} else {

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(dl));

startActivity(intent);

}

}

}

  1. 下载模块

package com.example.updataapk;

import java.io.File;

import java.io.FileOutputStream;

import java.io.InputStream;

import java.net.HttpURLConnection;

import java.net.URL;

import android.app.Notification;

import android.app.NotificationManager;

import android.app.PendingIntent;

import android.app.Service;

import android.content.Context;

import android.content.Intent;

import android.net.Uri;

import android.os.Handler;

import android.os.IBinder;

import android.os.Message;

import android.util.Log;

import android.widget.RemoteViews;

public class DownloadService extends Service {

// notification 名字

private String notify_name = “apk正在下载…”;

public static final String INTENT_URL = “url”;

private Context mContext = this;

Notification mNotification;

private static final int NOTIFY_ID = 0;

private NotificationManager mNotificationManager;

/* 下载包安装路径 */

private static final String savePath = Function_Utility.getUpgradePath();

private static final String saveFileName = savePath + “demo.apk”;

private String apkUrl;

private int progress;

boolean canceled;

private Thread downLoadThread;

@Override

public IBinder onBind(Intent intent) {

return null;

}

@Override

public void onCreate() {

super.onCreate();

mNotificationManager = (NotificationManager) getSystemService(android.content.Context.NOTIFICATION_SERVICE);

}

public int onStartCommand(Intent intent, int flags, int startId) {

Log.i(“DownloadServi

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值