Create a new Java class
com.packtpub.store.Color
encapsulating an integer representation of a color. This integer is parsed fromString
containing HTML code (for example,#FF0000
) thanks to theandroid.graphics.Color
class:package com.packtpub.store; import android.text.TextUtils; public class Color { private int mColor; public Color(String pColor) { if (TextUtils.isEmpty(pColor)) { throw new IllegalArgumentException(); } mColor = android.graphics.Color.parseColor(pColor); } @Override public String toString() { return String.format("#%06X", mColor); } }
In
StoreType.java
, append the new Color data type to the enumeration:public enum StoreType { Integer, String, Color }
In the
Store
class, append two new native methods to retrieve and save aColor
object:public class Store { ... public native Color getColor(String pKey); public native void...
Android NDK: Beginner's Guide
By :
Android NDK: Beginner's Guide
By:
Overview of this book
Table of Contents (18 chapters)
Android NDK Beginner's Guide Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Free Chapter
Setting Up Your Environment
Starting a Native Android Project
Interfacing Java and C/C++ with JNI
Calling Java Back from Native Code
Writing a Fully Native Application
Rendering Graphics with OpenGL ES
Playing Sound with OpenSL ES
Handling Input Devices and Sensors
Porting Existing Libraries to Android
Intensive Computing with RenderScript
Afterword
Index
Customer Reviews