- Android - Intents/Filters
- Android - Fragments
- Android - Content Providers
- Android - Broadcast Receivers
- Android - Services
- Android - Activities
- Android - Resources
- Android - Hello World Example
- Android - Application Components
- Android - Architecture
- Android - Environment Setup
- Android - Overview
- Android - Home
Android - User Interface
- Android - Custom Components
- Android - Styles and Themes
- Android - Event Handling
- Android - UI Controls
- Android - UI Layouts
Android Advanced Concepts
- Publishing Android Application
- Android - Phone Calls
- Android - Sending SMS
- Android - Sending Email
- Location Based Services
- Android - Notifications
- Android - Drag and Drop
Android Useful Examples
- Android - XML Parsers
- Android - Widgets
- Android - Wi-Fi
- Android - WebView Layout
- Android - UI Testing
- Android - UI Patterns
- Android - UI Design
- Android - Twitter Integration
- Android - TextureView
- Android - Text to Speech
- Android - Testing
- Android - Support Library
- Android - SQLite Database
- Android - Spelling Checker
- Android - SIP Protocol
- Android - Shared Preferences
- Android - Session Management
- Android - Sensors
- Android - SDK Manager
- Android - Screen Cast
- Android - RSS Reader
- Android - RenderScript
- Android - Push Notification
- Android - ProgressBar
- Android - Progress Circle
- Android - PHP/MySQL
- Android - NFC Guide
- Android - Network Connection
- Android - Navigation
- Android - Multitouch
- Android - MediaPlayer
- Android - Login Screen
- Android - Localization
- Android - Loading Spinner
- Android - Linkedin Integration
- Android - JSON Parser
- Android - JetPlayer
- Android - Internal Storage
- Android - ImageSwitcher
- Android - Image Effects
- Android - Google Maps
- Android - Gestures
- Android - Facebook Integration
- Android - Emulator
- Android - Developer Tools
- Android - Data Backup
- Android - Custom Fonts
- Android - Clipboard
- Android - Camera
- Android - Bluetooth
- Android - Best Practices
- Android - Auto Complete
- Android - AudioManager
- Android - Audio Capture
- Android - Animations
- Android - Alert Dialoges
Android Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Android - RenderScript
In this chapter, we will learn about Android RenderScript. Usually the apps on android are designed as to consume as minimum resources as possible. But some apppcations pke some 3D games need high level processing on android.
To provide these apppcations high performance android introduced the RenderScript. It is android based framework which is used for running apppcations that perform very highly computational tasks. The development on this framework is done in Native Development Kit(NDK) provided by android. RenderScript is extremely useful for apppcations which performs following types of actions −
3D Rendering
Image Processing
Computational Photography
Computer Vision
How RenderScript Works
RenderScript framework is basically based on data parallel computation. It distributes your apppcation workload on all the processors available on your device pke multi-core CPUs or GPUs.
This parallel distribution of workload frees the programmer from the tension of load balancing and work schedupng. You can write more detailed and complex algorithms for your app without the worry of computational power.
How to Begin
To use the RenderScript Framework you must have following two things −
A RenderScript Kernel
RenderScript APIs
A RenderScript Kernel
A kernel is a program which manages data processing instructions and manage workload on Central Processing Units.A kernel is a fundamental part of the operating system.
Similarly to run the RenderScript framework we need a written script named as Kernel to manage all the data processing requests from our app and utipze more features of the android OS provided by the NDK and as mentioned earper that the development of RenderScript is done in the Native Development Kit of Android.
The Kernel Script is written in C-99 standard of C-language. This Standard was before the development of C++. A RenderScript kernel script file usually placed in .rs file. Each file is called as a script. A RenderScript Kernel script can contain following elements −
Sr.No | Elements & Description |
---|---|
1 |
A Language declaration It declares the version of RenderScript Kernel language used in this script. |
2 |
A package declaration This declaration names the package name of the Java class which will be affected by this Kernel Code. |
3 |
Invokable functions You can call these invokable functions from your JAVA code with arbitrary arguments. |
4 |
Script Global Variables These are just pke the variables defined in C and C++ programming language. You can access these variables from your JAVA code. |
Following is the Sample Code of a Kernel −
uchar4 __convert__((kernel)) invert(uchar4 in, uint32_t x, uint32_t y) { uchar4 out = in; out.r = 255 - in.r; out.g = 255 - in.g; return out; }
RenderScript APIs
If you want to use RenderScript in your API, you can do it in following two ways −
Sr.No | APIs & Description |
---|---|
1 |
android.renderscript This API is available on devices running Android 3.0 and higher. |
2 |
android.support.v8.renderscript This API is available on devices running Android 2.2 and higher. |
To android support pbrary following tools are required −
Latest Android SDK Tools version
Latest Android SDK Build-tools version
How to use RenderScript Support Library
First Open the project.properties file in your project and add following pnes in the file −
renderscript.target=18 renderscript.support.mode=true sdk.buildtools=18.1.0
Now open your main class which use RenderScript and add an import for the Support Library classes as following −
import android.support.v8.renderscript.*;
Following are the purposes of above mentioned properties that we add in the project.properties file.
Sr.No | Project properties & Description |
---|---|
1 |
renderscript.target It specifies the byte code version to be generated. |
2 |
renderscript.support.mode It specifies a compatible version for the generated byte code to fall back. |
3 |
sdk.buildtools It Specifies the versions of Android SDK build tools to use. |
Now call your RenderScript Kernel functions and compute complex algorithms in your app.
Advertisements