Giter Club home page Giter Club logo

updateapk's Introduction

updateapk

几行代码实现android更新下载APP,适配到androd7.0

image

1.导入到工程

Step 1.Add it in your root build.gradle at the end of repositories:

allprojects {
  	repositories {
  		...
  		maven { url 'https://jitpack.io' }
  	}
  }

Step 2. Add the dependency

dependencies {
          compile 'com.github.gypnick:updateapk:V1.1'
  }

2.使用

 UpdateService.Builder.create(url)  //url为下载apk的地址
            .setVersionCode(2)  //这里设置服务器上的版本,通过这里来和本地versionCode版本对比 
            .setIsForce(true)  //是否强制更新,强制更新用户不更新就强制退出APP
            .build(MainActivity.this); 

android7.0需要添加以下文件

1.在 AndroidManifest.xml中加入

    <provider
        android:name="android.support.v4.content.FileProvider"
        android:authorities="${applicationId}.fileProvider"
        android:exported="false"
        android:grantUriPermissions="true">
        <meta-data
            android:name="android.support.FILE_PROVIDER_PATHS"
            android:resource="@xml/file_paths" />
    </provider>

2.在 /src/main/res/xml/ 加入file_paths.xml

  <?xml version="1.0" encoding="utf-8"?>
  <paths>
    <external-path path="Android/data/你的包名/" name="files_root" />
    <external-path path="." name="external_storage_root" />
  </paths>        

updateapk's People

Contributors

gypnick avatar

Stargazers

i小灰 avatar 思勤 avatar 慕栀Muz avatar A avatar 编程吴彦祖 代码蔡徐坤 avatar  avatar ldw_wow avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.