|
1 | 1 | # AndroidAppUpdateLibrary |
2 | 2 | Android App Update Library can be used for downloading the Apk from a link , Save it to External or Internal Storage, Than automatic installing the apk. Remember to add provider xml and android runtime permission before using this library. See sample use in app folder. |
3 | 3 |
|
| 4 | +[](https://jitpack.io/#Piashsarker/AndroidAppUpdateLibrary) |
| 5 | +## How To Use |
| 6 | +#### Step 1. Add the JitPack repository to your build file |
4 | 7 |
|
5 | | - |
| 8 | +Add it in your root build.gradle at the end of repositories: </br> |
| 9 | + |
| 10 | + |
| 11 | + allprojects { |
| 12 | + repositories { |
| 13 | + ... |
| 14 | + maven { url 'https://jitpack.io' } |
| 15 | + } |
| 16 | + } |
| 17 | + |
| 18 | +#### Step 2. Add the dependency |
| 19 | + |
| 20 | + dependencies { |
| 21 | + compile 'com.github.Piashsarker:AndroidAppUpdateLibrary:1.0.0' |
| 22 | + } |
| 23 | + |
| 24 | + |
| 25 | +#### Step 3. Add Runtime Permission |
| 26 | + |
| 27 | +Remember to add below permission in `Manifest.xml file` . And Also add runtime permission for (Version => Marshmallow ). See the sample app. |
| 28 | + |
| 29 | + <uses-permission android:name="android.permission.INTERNET"/> |
| 30 | + |
| 31 | + <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> |
| 32 | + |
| 33 | + #### Step 4. Add Provider XML |
| 34 | + Create a folder called `xml` in `res` folder. Create a xml file and named it `provider_paths`. Paste below code: |
| 35 | + |
| 36 | + <?xml version="1.0" encoding="utf-8"?> |
| 37 | + <paths xmlns:android="http://schemas.android.com/apk/res/android"> |
| 38 | + <external-path name="external_files" path="."/> |
| 39 | + </paths> |
| 40 | + |
| 41 | + Add below code in your `manifest.xml` file. |
| 42 | + |
| 43 | + |
| 44 | + <application |
| 45 | + |
| 46 | + .............. |
| 47 | + <provider |
| 48 | + android:name="android.support.v4.content.FileProvider" |
| 49 | + android:authorities="${applicationId}.provider" |
| 50 | + android:exported="false" |
| 51 | + android:grantUriPermissions="true"> |
| 52 | + <meta-data |
| 53 | + android:name="android.support.FILE_PROVIDER_PATHS" |
| 54 | + android:resource="@xml/provider_paths"/> |
| 55 | + </provider> |
| 56 | + |
| 57 | + |
| 58 | + </application> |
| 59 | + |
| 60 | + |
| 61 | + #### Step 5. For downloading and installing the apk automatically. |
| 62 | + |
| 63 | + After setting up all neccessary files it's just two line of code to download and install the apk updates in your device. |
| 64 | + |
| 65 | + String url = "http://androidpala.com/tutorial/app-debug.apk"; |
| 66 | + |
| 67 | + DownloadApk downloadApk = new DownloadApk(MainActivity.this); |
| 68 | + |
| 69 | + downloadApk.startDownloadingApk(url); |
| 70 | + |
| 71 | + |
| 72 | + |
| 73 | + <b> You are Good To Go. Happy Coding </b> |
| 74 | + |
0 commit comments