Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hiteshsahu/android-slices-demo
This project explains how to use Android Jetpack to create Slices.
https://github.com/hiteshsahu/android-slices-demo
android j jetpack-android slices
Last synced: 1 day ago
JSON representation
This project explains how to use Android Jetpack to create Slices.
- Host: GitHub
- URL: https://github.com/hiteshsahu/android-slices-demo
- Owner: hiteshsahu
- License: apache-2.0
- Created: 2019-05-08T15:59:16.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-05-22T13:15:42.000Z (over 5 years ago)
- Last Synced: 2024-11-11T06:40:00.413Z (2 months ago)
- Topics: android, j, jetpack-android, slices
- Language: Kotlin
- Size: 3.08 MB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Android-Slices-Demo
### This project explains how to use Android Jetpack to create Slices.
Topic covered:
1. __Basic slices__ shared data through slices with activity
2. __Advance Slices__ :
- Live List
- Grid
- Header
- Toggle Switches
- Multiple Actions passing
- Live Slider
- Live Progress Bar &
- Complex SlicesFollow the steps to get started with slices from blog: http://hiteshsahu.com/blogs/android_slices
# Android Slices Tutorial
> ### Continuing in last post here I gone explain how to create Slices for your application. If you have not read it please go through my previous post [Understanding Slices](http://hiteshsahu.com/blogs/android_slices) to get your setup ready.
## First Get your setup ready
You need to install [__Slice Viewer__](https://github.com/googlesamples/android-SliceViewer/releases) apk to view your slices. Download latest relase of slice viewer apk from [https://github.com/googlesamples/android-SliceViewer/releases](https://github.com/googlesamples/android-SliceViewer/releases) & install it using command:
> `adb install -r -t slice-viewer.apk`
where :
- -r: replaces existing application
- -t: allow test packagesNow you can view your Slice by running the following command:
> `adb shell am start -a android.intent.action.VIEW -d slice-content://com.hiteshsahu.slicedemo/`
It is pretty much like loading different pages of a website by changing URLS
For example:
- __content://com.hiteshsahu.slicedemo/__ : will gone load home slice
- __content://com.hiteshsahu.slicedemo/about__ : will gone load about slice
- __content://com.hiteshsahu.slicedemo/contact__ : will gone load contact sliceand so on see the result below.
#### Every time you gone launch a new slice with this adb command then that slice will be automatically get added in Slice Viewer demo app. Which you can see any time later.
Same can be achieve with the help of Android studio but I prefer command line tool. COmmand line tool is less complicate and less overhead.
### Uninstall sliceviewer
If you have uninstalled _sliceviewer.apk_ by drag and drop in Launcher app then chances are you might no longer will be able to install it back via adb command. This is a weird bug I found. In that case you will need to uninstall sliceviewer using this command.
adb uninstall com.example.android.sliceviewer## Building Custom Slices
As already described in my previous post [Understanding SLices](http://hiteshsahu.com/blogs/android_slices) you can use Android Studio to create Slices as shown in pic below:
## Steps to build slices
1. Install SliceViewer APK:
> adb install -r -t slice-viewer.apk
2. Download, Build, Install & Launch this project.
3. Execute this command from adb termainal:
> adb shell am start -a android.intent.action.VIEW -d slice-
For example to Launch Home screen from Slice execute. Note the "-" after slice.> adb shell am start -a android.intent.action.VIEW -d slice-content://com.hiteshsahu.slicedemo/
### Basic SLices
`BasicSliceProvider` class contain example of how we can create aslice and use Peending Intent to send data to the App
Similarly replace with this uris to launch Slice mapped to screens.
- home
content://com.hiteshsahu.slicedemo/
- aboutcontent://com.hiteshsahu.slicedemo/about
- contactcontent://com.hiteshsahu.slicedemo/contact
- ERROR 404content://com.hiteshsahu.slicedemo/etc :
### Advance SlicesUse this uri to launch complex slices with live data
- __SLICE WITH HEADER__ : this uri launch a Slice with a header and 3 custom Actions. Each action can be send to App with the help of Pending Intents. Click on Actions to see how App handle them.
content://com.hiteshsahu.slicedemo.advance/
- __SLICE WITH TOGGLE__ Show how to use toggle switch to turn on/off Wificontent://com.hiteshsahu.slicedemo.advance/toggle
- __SLICE WITH RANGE SLIDER & PROGRESS BAR__ Show how to show progress bar and Slider in Slices & control Media Volume of the devicecontent://com.hiteshsahu.slicedemo.advance/slider
- __SLICE WITH GRID__ Show how to show Grid of Images in Slicescontent://com.hiteshsahu.slicedemo.advance/grid
- __SLICE WITH WIFI LIST__ Show how to show List of Wifi along with show more option.content://com.hiteshsahu.slicedemo.advance/list
- __COMPLEX SLICE__: Complex slice with more than one grid and rowcontent://com.hiteshsahu.slicedemo.advance/combine