All Projects → simplepeng → Updater

simplepeng / Updater

基于DownloadManager封装的更新器,使用超简单!

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Updater

Backgroundupdate
后台更新APP(两句代码实现)
Stars: ✭ 80 (-2.44%)
Mutual labels:  apk, notifications
AndroidProjects
个人总结归纳Android知识点。1.Data Binding框架MVVM;2. BaseView;3.CollapseView;4.Notification;5.MultiChannelBuild;6.SwipeBack;7.CustomTabs;8.HandlerCourse;9.VolleyStudy;10.OkHttpStudy;11.PermissionManage;12.InterView;13.KotlinLearning
Stars: ✭ 32 (-60.98%)
Mutual labels:  notifications, apk
Crypto Coin Alerts
An application that let you set alerts for the prices of several cryptocurrencies
Stars: ✭ 72 (-12.2%)
Mutual labels:  notifications
Web Push Php
Web Push library for PHP
Stars: ✭ 1,224 (+1392.68%)
Mutual labels:  notifications
Notify
Cross-platform library for desktop notifications for your go application
Stars: ✭ 76 (-7.32%)
Mutual labels:  notifications
Kivy Apk
Vbox+Ubuntu16.04打包生成kivy apk
Stars: ✭ 74 (-9.76%)
Mutual labels:  apk
Homebridge Unifi Protect Camera Motion
Camera & Motion sensor support for Unifi Protect cameras in Homekit via Homebridge
Stars: ✭ 79 (-3.66%)
Mutual labels:  notifications
Typednotifications
A mechanism for sending typed notifications with payloads across your iOS app.
Stars: ✭ 70 (-14.63%)
Mutual labels:  notifications
Gradle Android Apk Size Plugin
Gradle plugin that generates CSV files with apk size per output and variant of an apk
Stars: ✭ 79 (-3.66%)
Mutual labels:  apk
Vab
V Android Bootstrapper
Stars: ✭ 77 (-6.1%)
Mutual labels:  apk
Applozic Web Plugin
Javascript (jQuery) Real Time Chat & Messaging plugin
Stars: ✭ 76 (-7.32%)
Mutual labels:  notifications
Uget Chrome Wrapper
Moved to https://github.com/ugetdm/uget-integrator and https://github.com/ugetdm/uget-extension
Stars: ✭ 74 (-9.76%)
Mutual labels:  downloadmanager
Sharexin
ShareX for Linux and BSD
Stars: ✭ 79 (-3.66%)
Mutual labels:  notifications
Notti
Dead simple user notification.
Stars: ✭ 72 (-12.2%)
Mutual labels:  notifications
Chatter App
This is a flutter based modern messaging app where users can sign up and log in to chat with their friends, family, colleagues among groups with enriched User-Experience.
Stars: ✭ 80 (-2.44%)
Mutual labels:  apk
Qy Wechat Notification Plugin
企业微信Jenkins构建通知插件
Stars: ✭ 72 (-12.2%)
Mutual labels:  notifications
Mobile Security Framework Mobsf
Mobile Security Framework (MobSF) is an automated, all-in-one mobile application (Android/iOS/Windows) pen-testing, malware analysis and security assessment framework capable of performing static and dynamic analysis.
Stars: ✭ 10,212 (+12353.66%)
Mutual labels:  apk
Playlistcore
Media Playlist Service With Notification and Remote View Support
Stars: ✭ 77 (-6.1%)
Mutual labels:  notifications
Jquery Toast Plugin
Highly customizable jquery plugin to show toast messages
Stars: ✭ 1,237 (+1408.54%)
Mutual labels:  notifications
React Semantic Toasts
React Semantic UI notifications library
Stars: ✭ 80 (-2.44%)
Mutual labels:  notifications

Updater

基于DownloadManager封装的更新器,更简单的操作,更丰富的自定义,一行代码搞定应用更新,断点续传完全交给系统,再也不用自己操心。零依赖,不必再添加其他网络框架的依赖,DownloadManager在Android SDK中就已经集成。

样例

这里notification上的图标是Android小机器人可以不用担心,DownloadManager封装的 notification会自己找该应用的icon,也就是说还是会变成你应用的icon的。

添加依赖

compile 'com.simplepeng:updater:1.0.3'

使用

开始下载

updater = new Updater.Builder(getApplicationContext())
                     .setDownloadUrl(url)
                     .setApkName("test.apk")
                     .setNotificationTitle("updater")
                     .start();

默认下载路径在sd的Download目录(推荐做法)。

如果想自定义目录(默认是sd下的目录),可以调用

setApkDir(String dirName)

示例:setApkDir("test")

或者自定义全路径

setApkPath(String apkPath)

示例:setApkPath(Environment.getExternalStorageDirectory().getAbsolutePath())

注册监听下载完成的广播,会自动安装apk(非静默)

  • 推荐在manifest中静态注册
<receiver android:name="com.simplepeng.updaterlibrary.DownloadReceiver">
     <intent-filter >
          <action android:name="android.intent.action.DOWNLOAD_COMPLETE"/>
     </intent-filter>
</receiver>
  • 动态注册(不推荐)
updater.registerDownloadReceiver();

如果需要解绑监听器,记得调用该方法

 updater.unRegisterDownloadReceiver();

需要的权限

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!--调用hideNotification不显示notification需要的权限-->
<uses-permission android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION" />

监听下载进度

一般不需要,看自己业务需求,notification上已经有进度显示了

updater.addProgressListener(new ProgressListener() {
         @Override
          public void onProgressChange(long totalBytes, long curBytes, int progress) {
                        
                    }
                });

方法概括

Updater.Builder中的方法

  • setApkName(String apkName) 设置下载下来的apk文件名
  • setApkPath(String apkPath) 设置apk下载的路径(全路径)
  • setApkDir(String dirName) 设置下载apk的文件目录
  • setDownloadUrl(String downloadUrl) 设置下载的链接地址
  • setNotificationTitle(String title) 通知栏显示的标题
  • hideNotification() 隐藏通知栏
  • debug() 是否为debug模式,会输出很多log信息(手动斜眼)
  • allowedOverRoaming() 允许漫游网络可下载
  • start() 开始下载

Updater中的方法

  • registerDownloadReceiver 注册下载完成的监听
  • unRegisterDownloadReceiver() 解绑下载完成的监听
  • addProgressListener(ProgressListener progressListener) 添加下载进度回调
  • removeProgressListener(ProgressListener progressListener) 移除下载进度回调

版本信息

  • 1.0.0 初版
  • 1.0.1 增加6.0动态权限支持,7.0文件访问权限支持
  • 1.0.2 增加7.0访问权限设置
  • 1.0.3 增加8.0第三方apk安装权限

License

Copyright 2016 simple peng

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].