tag:blogger.com,1999:blog-47298318542333419972024-02-22T11:50:07.386-08:00Android Applications, Examples and User GuidesAnonymoushttp://www.blogger.com/profile/00908564854719054075noreply@blogger.comBlogger12125tag:blogger.com,1999:blog-4729831854233341997.post-44877255190551490342015-03-09T11:43:00.001-07:002015-03-09T11:43:55.017-07:00Best Practices for Coding - Java<div dir="ltr" style="text-align: left;" trbidi="on">
Hi all,<br />
<br />
After a while without publish anything, due family growing and moving to other country once again, I'm back now publishing some tips for better code, maintainability and some that will help you keep your memory usage footprint low. Of course if the project has a not very optimal architecture will be hard just with code keep low memory footprint, though good code always helps.<br />
This one is long, I have read articles from Oracle, across the web and the Java Performance Book (<a href="http://www.amazon.com/Java-Performance-Definitive-Scott-Oaks/dp/1449358454/ref=sr_1_1?s=books&ie=UTF8&qid=1425925347&sr=1-1&keywords=java+performance">Link for Amazon Book</a>) that I recommend and it's a really good book for those that want to have better performance with Java.<br />
In this post, nearly all tips and good practices are for code, I hope this helps those one looking for improve their code or trying to set a bar for the minimum acceptable code quality.<br />
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><span style="font-size: 12.0pt; line-height: 107%;">Things to avoid at all cost in code,
this is a basic thing and it’s an issue in most projects.<o:p></o:p></span></b></div>
<div class="MsoNormal">
As the very first thing I would like to say to the
developer to do is <u>don’t</u> be lazy in create object, variables or any other reference
names, don’t make economy, use names that explain for any person what that
reference.variable name really means, don’t expect that others guess what you were thinking
earlier, not even make the mistake to think that you will remember exactly
what the short naming mean after a couple of months doing something else
in the project, be clear and verbose in explain a declaration.<o:p></o:p></div>
<div class="MsoNormal">
E.g.:<o:p></o:p></div>
<div class="MsoNormal">
<span style="color: #6aa84f;">// Don’t</span><o:p></o:p></div>
<div class="MsoNormal">
public class BfProcCustAss {…<o:p></o:p></div>
<div class="MsoNormal">
Object custAssActTdy = getCustomer();<o:p></o:p></div>
<div class="MsoNormal">
// Do<o:p></o:p></div>
<div class="MsoNormal">
public class BackfileProccessForCustmerAssociated {…<o:p></o:p></div>
<div class="MsoNormal">
Object customerAssociatedActiveToday = getCustomer();<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
Avoid duplicated strings in the code as it is bad for code
maintenance and memory, producing fragmented memory.<o:p></o:p></div>
<div class="MsoNormal">
<span style="color: #6aa84f;">// Don’t – <i>here you
have two objects without any variable or instance variable association</i></span><o:p></o:p></div>
<div class="MsoNormal">
If (customerType.equals(“Active”)) {<o:p></o:p></div>
<div class="MsoNormal">
foo.callCustomer(“Active”);<o:p></o:p></div>
<div class="MsoNormal">
….<o:p></o:p></div>
<div class="MsoNormal">
}<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="color: #6aa84f;">// Do – </span><i><span style="color: #6aa84f;">here you have
one String object and two references to it</span><o:p></o:p></i></div>
<div class="MsoNormal">
private static final String <i><span style="color: #5b9bd5; mso-themecolor: accent1;">ACTIVE</span></i><span style="color: #5b9bd5; mso-themecolor: accent1;"> </span>= “Active”;<o:p></o:p></div>
<div class="MsoNormal">
<span style="color: #6aa84f;">// or</span><o:p></o:p></div>
<div class="MsoNormal">
private final String <i><span style="color: #5b9bd5; mso-themecolor: accent1;">ACTIVE</span></i><span style="color: #5b9bd5; mso-themecolor: accent1;"> </span>= “Active”;<o:p></o:p></div>
<div class="MsoNormal">
….<o:p></o:p></div>
<div class="MsoNormal">
If (customerType.equals(<i><span style="color: #5b9bd5; mso-themecolor: accent1;">ACTIVE</span></i>)) {<o:p></o:p></div>
<div class="MsoNormal">
foo.callCustomer(<i><span style="color: #5b9bd5; mso-themecolor: accent1;">ACTIVE</span></i>);<o:p></o:p></div>
<div class="MsoNormal">
….<o:p></o:p></div>
<div class="MsoNormal">
}<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><span style="font-size: 12.0pt; line-height: 107%;">NO, magical numbers please!<o:p></o:p></span></b></div>
<div class="MsoNormal">
Try avoid those numbers that make so much sense to you at
the code conception time though after a while not even you will be able to
understand what it means.<o:p></o:p></div>
<div class="MsoNormal">
E.g.:<o:p></o:p></div>
<div class="MsoNormal">
final List<Object> myDifferentObjectList = getHeterogeneousObjectList();<o:p></o:p></div>
<div class="MsoNormal">
…<o:p></o:p></div>
<div class="MsoNormal">
<span style="color: #6aa84f;">// Don’t</span><o:p></o:p></div>
<div class="MsoNormal">
BeanOne beanOne = myDifferentObjectList.get(5);<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="color: #6aa84f;">// Do<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="color: #6aa84f;">// Declare it in your method as var or as instance variable
in your class</span><o:p></o:p></div>
<div class="MsoNormal">
Private static final int BEAN_ONE = 5;<o:p></o:p></div>
<div class="MsoNormal">
<span style="color: #6aa84f;">// Then</span><o:p></o:p></div>
<div class="MsoNormal">
BeanOne beanOne = myDifferentObjectList.get(BEAN_ONE);<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
Or<o:p></o:p></div>
<div class="MsoNormal">
<span style="color: #6aa84f;">// Don’t</span><o:p></o:p></div>
<div class="MsoNormal">
cs.setString(2, feedToLookUp);<o:p></o:p></div>
<div class="MsoNormal">
cs.setString(3, feedType);<o:p></o:p></div>
<div class="MsoNormal">
cs.registerOutParameter(4, OracleTypes.CURSOR); // What are
you getting from here?<o:p></o:p></div>
<div class="MsoNormal">
cs.registerOutParameter(5, OracleTypes.VARCHAR); // and
here?<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="color: #6aa84f;">// Do</span><o:p></o:p></div>
<div class="MsoNormal">
final int PI_FEED_LOOK_UP = 2;<o:p></o:p></div>
<div class="MsoNormal">
final int PI_FEED_TYPE = 3;<o:p></o:p></div>
<div class="MsoNormal">
final int PO_RC_FEED_LIST = 4;<o:p></o:p></div>
<div class="MsoNormal">
final int PO_MESSAGE_GROUP_ID = 5;<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
cs.setString(PI_FEED_LOOK_UP, feedToLookUp);<o:p></o:p></div>
<div class="MsoNormal">
cs.setString(PI_FEED_TYPE, feedType);<o:p></o:p></div>
<div class="MsoNormal">
cs.registerOutParameter(PO_RC_FEED_LIST,
OracleTypes.CURSOR); // Easier no?<o:p></o:p></div>
<div class="MsoNormal">
cs.registerOutParameter(PO_MESSAGE_GROUP_ID,
OracleTypes.VARCHAR);<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<i><u>Those tips above
should be used with any language, not been restricted to Java, it’s a minimum
for provide some code insight to the next developer that will maintain the code
made by you.<o:p></o:p></u></i></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<o:p><br /></o:p></div>
<div class="MsoNormal">
The tips bellow are good for C++ and Java, however a few
will be Java only as C++ has a quite better set for work with Threads than Java
does, even today with the new Fork and Join released in JDK 7.<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<o:p><br /></o:p></div>
<div class="MsoNormal">
<b><span style="font-size: 12.0pt; line-height: 107%;">Avoid or Minimize Synchronization<o:p></o:p></span></b></div>
<div class="MsoNormal">
Many performance studies have shown a high performance cost
in using synchronization in Java. Improper synchronization can also cause a
deadlock, which can result in complete loss of service because the system
usually has to be shut down and restarted. But performance overhead cost is not
a sufficient reason to avoid synchronization completely. Failing to make sure
your application is thread-safe in a multi-threaded environment can cause data
corruption, which can be much worse than losing performance. The following are
some practices that you can consider to minimize the overhead:<o:p></o:p></div>
<div class="MsoNormal">
Synchronize Critical Sections Only<o:p></o:p></div>
<div class="MsoNormal">
Do Not Use the Same Lock on Objects That Are Not Manipulated
Together<o:p></o:p></div>
<div class="MsoNormal">
Use Private Fields<o:p></o:p></div>
<div class="MsoNormal">
Use a Thread Safe Wrapper<o:p></o:p></div>
<div class="MsoNormal">
Use Immutable Objects<o:p></o:p></div>
<div class="MsoNormal">
Know Which Java Objects Already Have Synchronization
Built-in<o:p></o:p></div>
<div class="MsoNormal">
Do Not Under-Synchronize<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<o:p><br /></o:p></div>
<div class="MsoNormal">
<b><span style="font-size: 12.0pt; line-height: 107%;">Synchronize Critical Sections Only<o:p></o:p></span></b></div>
<div class="MsoNormal">
If only certain operations in the method must be
synchronized, use a synchronized block with a mutex instead of synchronizing
the entire method. For example:<o:p></o:p></div>
<div class="MsoNormal">
private Object mutex = new Object();<o:p></o:p></div>
<div class="MsoNormal">
...<o:p></o:p></div>
<div class="MsoNormal">
private void
doSomething()<o:p></o:p></div>
<div class="MsoNormal">
{<o:p></o:p></div>
<div class="MsoNormal">
<span style="color: #6aa84f;">// perform tasks
that do not require synchronicity</span><o:p></o:p></div>
<div class="MsoNormal">
...<o:p></o:p></div>
<div class="MsoNormal">
synchronized
(mutex)<o:p></o:p></div>
<div class="MsoNormal">
{<o:p></o:p></div>
<div class="MsoNormal">
...<o:p></o:p></div>
<div class="MsoNormal">
}<o:p></o:p></div>
<div class="MsoNormal">
...<o:p></o:p></div>
<div class="MsoNormal">
}<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<o:p><br /></o:p></div>
<div class="MsoNormal">
<b><span style="font-size: 12.0pt; line-height: 107%;">Do Not Use the Same Lock on Objects
That Are Not Manipulated Together<o:p></o:p></span></b></div>
<div class="MsoNormal">
Every Java object has a single lock associated with it. If
unrelated operations within the class are forced to share the same lock, then
they have to wait for the lock and must be executed one at a time. In this
case, define a different mutex for each unrelated operation that requires
synchronization.<o:p></o:p></div>
<div class="MsoNormal">
Also, do not use the same lock to restrict access to objects
that will never be shared by multiple threads. For example, using Hashtables to
store objects that will never be accessed concurrently causes unnecessary
synchronization overhead:<o:p></o:p></div>
<div class="MsoNormal">
public class myClass<o:p></o:p></div>
<div class="MsoNormal">
{<o:p></o:p></div>
<div class="MsoNormal">
private static
myObject1 myObj1;<o:p></o:p></div>
<div class="MsoNormal">
private static
mutex1 = new Object();<o:p></o:p></div>
<div class="MsoNormal">
private static
myObject2 myObj2;<o:p></o:p></div>
<div class="MsoNormal">
private static
mutex2 = new Object();<o:p></o:p></div>
<div class="MsoNormal">
...<o:p></o:p></div>
<div class="MsoNormal">
public static void
updateObject1()<o:p></o:p></div>
<div class="MsoNormal">
{<o:p></o:p></div>
<div class="MsoNormal">
synchronized(mutex1)<o:p></o:p></div>
<div class="MsoNormal">
{<o:p></o:p></div>
<div class="MsoNormal">
<span style="color: #6aa84f;">// update
myObj1 ...</span><o:p></o:p></div>
<div class="MsoNormal">
}<o:p></o:p></div>
<div class="MsoNormal">
}<o:p></o:p></div>
<div class="MsoNormal">
public static void
updateObject2()<o:p></o:p></div>
<div class="MsoNormal">
{<o:p></o:p></div>
<div class="MsoNormal">
synchronized(mutex2)<o:p></o:p></div>
<div class="MsoNormal">
{<o:p></o:p></div>
<div class="MsoNormal">
<span style="color: #6aa84f;">// update
myObj2 ...</span><o:p></o:p></div>
<div class="MsoNormal">
}<o:p></o:p></div>
<div class="MsoNormal">
}<o:p></o:p></div>
<div class="MsoNormal">
...<o:p></o:p></div>
<div class="MsoNormal">
}<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><span style="font-size: 12.0pt; line-height: 107%;">Use Private Fields<o:p></o:p></span></b></div>
<div class="MsoNormal">
Making fields private protects them from unsynchronized
access. Controlling their access means these fields need to be synchronized
only in the class's critical sections when they are being modified.<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<o:p><br /></o:p></div>
<div class="MsoNormal">
<b><span style="font-size: 12.0pt; line-height: 107%;">Use a Thread Safe Wrapper<o:p></o:p></span></b></div>
<div class="MsoNormal">
Provide a thread-safe wrapper on objects that are not
thread-safe. This is the approach used by the collection interfaces in JDK 1.2.<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<o:p><br /></o:p></div>
<div class="MsoNormal">
<b><span style="font-size: 12.0pt; line-height: 107%;">Use Immutable Objects<o:p></o:p></span></b></div>
<div class="MsoNormal">
An immutable object is one whose state cannot be changed
once it is created. Since there is no method that can change the state of any
of the object's instance variables once the object is created, there is no need
to synchronize on any of the object's methods.<o:p></o:p></div>
<div class="MsoNormal">
This approach works well for objects, which are small and
contain simple data types. The disadvantage is that whenever you need a
modified object, a new object has to be created. This may result in creating a
lot of small and short-lived objects that have to be garbage collected. One
alternative when using an immutable object is to also create a mutable wrapper
similar to the thread-safe wrapper.<o:p></o:p></div>
<div class="MsoNormal">
An example is the String and StringBuffer class in Java. The
String class is immutable while its companion class StringBuffer is not. This
is part of the reason why many Java performance books recommend using
StringBuffer instead of string concatenation.<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<o:p><br /></o:p></div>
<div class="MsoNormal">
<b><span style="font-size: 12.0pt; line-height: 107%;">Know Which Java Objects Already Have
Synchronization Built-in<o:p></o:p></span></b></div>
<div class="MsoNormal">
Some Java objects (such as Hashtable, Vector, and
StringBuffer) already have synchronization built into many of their APIs. They
may not require additional synchronization.<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<o:p><br /></o:p></div>
<div class="MsoNormal">
<b><span style="font-size: 12.0pt; line-height: 107%;">Do Not Under-Synchronize<o:p></o:p></span></b></div>
<div class="MsoNormal">
Some Java variables and operations are not atomic. If these
variables or operations can be used by multiple threads, you must use
synchronization to prevent data corruption. For example: (i) Java types long
and double are comprised of eight bytes; any access to these fields must be
synchronized. (ii) Operations such as ++ and -- must be synchronized because
they represent a read and a write, not an atomic operation.<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<o:p><br /></o:p></div>
<div class="MsoNormal">
<b><span style="font-size: 12.0pt; line-height: 107%;">Monitor Synchronization<o:p></o:p></span></b></div>
<div class="MsoNormal">
Java synchronization can cause a deadlock. The best way to
avoid this problem is to avoid the use of Java synchronization. One of the most
common uses of synchronization is to implement pooling of serially reusable
objects. Often, you can simply add a serially reusable object to an existing
pooled object. For example, you can add Java Database Connectivity (JDBC) and
Statement object to the instance variables of a single thread model servlet, or
you can use the Oracle JDBC connection pool rather than implement your own
synchronized pool of connections and statements.<o:p></o:p></div>
<div class="MsoNormal">
If you must use synchronization, you should either avoid
deadlock, or detect it and break it. Both strategies require code changes. So,
neither can be completely effective because some system code uses
synchronization and cannot be changed by the application.<o:p></o:p></div>
<div class="MsoNormal">
To prevent deadlock, simply number the objects that you must
lock, and ensure that clients lock objects in the same order.<o:p></o:p></div>
<div class="MsoNormal">
Proprietary JVM extensions may be available to help spot
deadlocks without having to instrument code, but there are no standard JVM
facilities for detecting deadlock.<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><span style="font-size: 12.0pt; line-height: 107%;">Monitor and Fix Resource Leaks<o:p></o:p></span></b></div>
<div class="MsoNormal">
One way to fix resource leaks is straightforward - a
periodic restart. It provides good protection against slow resource leaks. But
it is also important to spot applications that are draining resources too
quickly, so that any software bugs can be fixed. Leaks that prevent continuous
server operation for at least 24 hours must be fixed in the application code,
not by application restart.<o:p></o:p></div>
<div class="MsoNormal">
Common programming mistakes are:<o:p></o:p></div>
<div class="MsoNormal">
Not returning the resource to the pool (or not removing it
from the pool) after handling an error.<o:p></o:p></div>
<div class="MsoNormal">
Relying on the garbage collector to invoke finalize() and
free resources. <u>Never rely on the garbage collector to manage any resource
other than memory</u>.<o:p></o:p></div>
<div class="MsoNormal">
Not discarding old object references which prevent recycling
the memory occupied by the objects.<o:p></o:p></div>
<div class="MsoNormal">
Monitoring resource usage should be a combination of code
instrumentation and external monitoring utilities. With code instrumentation,
calls to an application-provided interface, or calls to a system-provided
interface like Oracle Dynamic Monitoring System (DMS), are inserted at key
points in the application's resource usage lifecycle. Done correctly, this can
give the most accurate picture of resource use. Unfortunately, the same
programming errors that cause resource leaks are also likely to cause
monitoring errors. That is, you may forget to release the resource, or forget
to monitor the release of the resource.<o:p></o:p></div>
<div class="MsoNormal">
Operating system commands like vmstat or ps in UNIX, provide
process-level information such as the amount of memory allocated, the number
and state of threads, or number of network connections. They can be used to
detect a resource leak. Some commercially available development tools can also
be used to find the leak.<o:p></o:p></div>
<div class="MsoNormal">
In addition to compromising availability, resource leaks and
overuse decrease performance.<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<o:p><br /></o:p></div>
<div class="MsoNormal">
<b><span style="font-size: 12.0pt; line-height: 107%;">Always Use a Finally Clause in Each
Method to Cleanup<o:p></o:p></span></b></div>
<div class="MsoNormal">
In Java, it is impossible to leave the try or catch blocks
(even with a throw or return statement) without executing the finally block. If
for any reason the instance variables cannot be cleaned, throw a catch-all
exception that should cause the caller to discard its object reference to this
now corrupt object. If, for any reason the static variables cannot be cleaned,
throw an InternalError or equivalent that will ultimately result in restarting
the now corrupt JVM.<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<o:p><br /></o:p></div>
<div class="MsoNormal">
<b><span style="font-size: 12.0pt; line-height: 107%;">Discard Objects That Throw Catch-All
Exceptions<o:p></o:p></span></b></div>
<div class="MsoNormal">
In many cases, these exceptions indicate that the internal
state of the invoked object is corrupt, and that further invocations will also
fail. Keep the object reference only if careful scrutiny of the exception shows
it is benign, and further invocations on this object are likely to succeed.<o:p></o:p></div>
<div class="MsoNormal">
Adopt a guilty unless proven innocent approach. For example,
a SQLException thrown from an Oracle JDBC invocation could represent one of
thousands of error conditions in the JDBC driver, the network, or the database
server. Some of these errors (for example, subclass SQLWarning) are benign.
Some SQLExceptions (for example, "ORA-3113: end of file on communication
channel") definitely leave the JDBC object useless. Most SQLExceptions do
not clearly specify what state the JDBC object is left in. The best approach is
to enumerate the benign error codes that could occur frequently in your
application and can definitely be retried, such as a unique key violation for user-supplied
input data. If any other error code is found, discard the potentially corrupt
object that threw the exception.<o:p></o:p></div>
<div class="MsoNormal">
Discard all object references to the (potentially) corrupt
object. Be sure to remove the corrupt object from all pools in order to prevent
pools from being poisoned by corrupt objects. Do not invoke the corrupt object
again - instantiate a brandnew object instead.<o:p></o:p></div>
<div class="MsoNormal">
When you are sure that the corrupt objects have been
discarded and that the catching object is not corrupt, throw a non-catch-all
exception so that the caller does not discard this object.<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<o:p><br /></o:p></div>
<div class="MsoNormal">
<b><span style="font-size: 12.0pt; line-height: 107%;">Design Transactions Usage Correctly<o:p></o:p></span></b></div>
<div class="MsoNormal">
Transactions should not span client requests because this
can tie up shared resources indefinitely.<o:p></o:p></div>
<div class="MsoNormal">
Requests generally should not span more than one transaction,
because a failure in mid-request could leave some transactions committed and
others rolled back. If this requires application-level compensation to recover,
then availability or data integrity may be compromised.<o:p></o:p></div>
<div class="MsoNormal">
Transactions generally should not span more than one
database, because distributed transactions lock shared resources longer, and
failure recovery may require simultaneous availability and coordination of
multiple databases.<o:p></o:p></div>
<div class="MsoNormal">
Applications that require a single client request (for
example, a confirm checkout request in a shopping cart application) to
ultimately affect several databases (for example, credit card, fulfillment,
shopping cart, and customer history databases) should perform the first step
with one database, and in the same transaction queue a message in the first
database addressed to the second database. The second database will perform the
second step and queue the third step, and so on. This queued transaction chain
will eventually complete automatically, or an administrator will see an
undeliverable message and will have to manually compensate.<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<o:p><br /></o:p></div>
<div class="MsoNormal">
<b><span style="font-size: 12.0pt; line-height: 107%;">Put Business Logic in the Right Place<o:p></o:p></span></b></div>
<div class="MsoNormal">
In general, you should not implement business logic in your
client program. Instead, put validation and defaulting logic in your entity
objects, and put client-callable methods in application modules, view objects,
and view rows.<o:p></o:p></div>
<div class="MsoNormal">
Working with application module methods allows the client
program to encapsulate task-level custom code in a place that allows
data-intensive operations to be done completely in the middle-tier without
burdening the client.<o:p></o:p></div>
<div class="MsoNormal">
Working with view object methods allows the client program
to access the entire row collection for cross-row calculations and operations.<o:p></o:p></div>
<div class="MsoNormal">
Working with view row methods allows the client program to
operate on individual rows of data. There are three types of custom view row methods
you may want to create:<o:p></o:p></div>
<div class="MsoNormal">
Accessor methods: The oracle.jbo.Row interface (which view
rows implement) contains the methods getAttribute() and setAttribute(), but
these methods are not typesafe. You can automatically generate custom typesafe
accessors when you generate a custom view row class.<o:p></o:p></div>
<div class="MsoNormal">
Delegators to entity methods: By design, clients cannot
directly access entity objects. If you want to expose an entity method to the
client tier, you should create a delegator method in a view row.<o:p></o:p></div>
<div class="MsoNormal">
Entity-independent calculations: This is useful if the
calculation uses attributes derived from multiple entity objects or from no
entity objects.<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<o:p><br /></o:p></div>
<div class="MsoNormal">
<b><span style="font-size: 12.0pt; line-height: 107%;">Avoid Common Errors That Can Result
In Memory Leaks<o:p></o:p></span></b></div>
<div class="MsoNormal">
In Java, memory bugs often appear as performance problems,
because memory leaks usually cause performance degradation. Because Java
manages the memory automatically, developers do not control when and how
garbage is collected. To avoid memory leaks, check your applications to make
sure they:<o:p></o:p></div>
<div class="MsoNormal">
Release JDBC ResultSet, Statement, or connection.<o:p></o:p></div>
<div class="MsoNormal">
Release failures here are usually in error conditions. Use a
finally block to make sure these objects are released appropriately.<o:p></o:p></div>
<div class="MsoNormal">
Release instance or resource objects that are stored in
static tables.<o:p></o:p></div>
<div class="MsoNormal">
Perform clean up on serially reusable objects.<o:p></o:p></div>
<div class="MsoNormal">
An example is appending error messages to a Vector defined
in a serially reusable object. The application never cleaned the Vector before
it was given to the next user. As the object was reused over and over again,
error messages accumulated, causing a memory leak that was difficult to track
down.<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><br /></b></div>
<div class="MsoNormal">
<b><span style="font-size: 12.0pt; line-height: 107%;">Avoid Creating Objects or Performing Operations
That May Not Be Used<o:p></o:p></span></b></div>
<div class="MsoNormal">
This mistake occurs most commonly in tracing or logging code
that has a flag to turn the operation on or off during runtime. Some of this
code goes to great lengths creating and formatting output without checking the
flag first, creating many objects that are never used when the flag is off.
This mistake can be quite expensive, because tracing and logging usually
involves many String objects and operations to translate the message or even
access to the database to retrieve the full text of the message. Large numbers
of debug or trace statements in the code make matters worse.<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<o:p><br /></o:p></div>
<div class="MsoNormal">
<b><span style="font-size: 12.0pt; line-height: 107%;">Replace Hashtable and Vector With
Hashmap, ArrayList, or LinkedList If Possible<o:p></o:p></span></b></div>
<div class="MsoNormal">
The Hashtable and Vector classes in Java are very powerful,
because they provide rich functions. Unfortunately, they can also be easily
misused. Since these classes are heavily synchronized even for read operations,
they can present some challenging problems in performance tuning. Hence, the
recommendations are:<o:p></o:p></div>
<div class="MsoNormal">
Use an Array Instead of an ArrayList If the Size Can Be
Fixed<o:p></o:p></div>
<div class="MsoNormal">
Use an ArrayList or LinkedList To Hold a List of Objects In
a Particular Sequence<o:p></o:p></div>
<div class="MsoNormal">
Use HashMap or TreeMap To Hold Associated Pairs of Objects<o:p></o:p></div>
<div class="MsoNormal">
Replace Hashtable, Vector, and Stack<o:p></o:p></div>
<div class="MsoNormal">
Avoid Using String As the Hash Key (If Using JDK Prior to
1.2.2)<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><br /></b></div>
<div class="MsoNormal">
<b><span style="font-size: 12.0pt; line-height: 107%;">Use an Array Instead of an ArrayList <u>If
the Size Can Be Fixed</u><o:p></o:p></span></b></div>
<div class="MsoNormal">
If you can determine the number of elements, use an Array
instead of an ArrayList, because it is much faster. An Array also provides type
checking, so there is no need to cast the result when looking up an object.<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<o:p><br /></o:p></div>
<div class="MsoNormal">
<b><span style="font-size: 12.0pt; line-height: 107%;">Use an ArrayList or LinkedList To
Hold a List of Objects In a Particular Sequence<o:p></o:p></span></b></div>
<div class="MsoNormal">
A List holds a sequence of objects in a particular order
based on some numerical indexes. It will be automatically resized. In general,
use an ArrayList if there are many random accesses. Use a LinkedList if there
are many insertions and deletions in the middle of the list.<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<o:p><br /></o:p></div>
<div class="MsoNormal">
<b><span style="font-size: 12.0pt; line-height: 107%;">Use HashMap or TreeMap To Hold
Associated Pairs of Objects<o:p></o:p></span></b></div>
<div class="MsoNormal">
A Map is an associative array, which associates any one
object with another object. Use a HashMap if the objects do not need to be
stored in sorted order. Use TreeMap if the objects are to be in sorted order.
Since a TreeMap has to keep the objects in order, it is usually slower than a
HashMap.<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<o:p><br /></o:p></div>
<div class="MsoNormal">
<b><span style="font-size: 12.0pt; line-height: 107%;">Replace Hashtable, Vector, and Stack<o:p></o:p></span></b></div>
<div class="MsoNormal">
Replace a Vector with an ArrayList or a LinkedList.<o:p></o:p></div>
<div class="MsoNormal">
Replace a Stack with a LinkedList.<o:p></o:p></div>
<div class="MsoNormal">
Replace a Hashtable with a HashMap or a TreeMap.<o:p></o:p></div>
<div class="MsoNormal">
Vector, Stack, and Hashtable are synchronized-views of List
and Map. For example, you can create the equivalent of a Hashtable using:<o:p></o:p></div>
<div class="MsoNormal">
private Map hashtable = Collections.synchronizedMap (new
HashMap());<o:p></o:p></div>
<div class="MsoNormal">
However, bear in mind that even though methods in these
synchronized-views are thread-safe, iterations through these views are not
safe. Therefore, they must be protected by a synchronized block.<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<o:p><br /></o:p></div>
<div class="MsoNormal">
<b><span style="font-size: 12.0pt; line-height: 107%;">Reuse Objects Instead of Creating New
Ones If Possible<o:p></o:p></span></b></div>
<div class="MsoNormal">
Object creation is an expensive operation in Java, with
impact on both performance and memory consumption. The cost varies depending on
the amount of initialization that needs to be performed when the object is to
be created. Here are ways to minimize excess object creation and garbage
collection overhead:<o:p></o:p></div>
<div class="MsoNormal">
Use a Pool to Share Resource Objects<o:p></o:p></div>
<div class="MsoNormal">
Recycle Objects<o:p></o:p></div>
<div class="MsoNormal">
Use Lazy Initialization to Defer Creating the Object Until
You Need It.<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<o:p><br /></o:p></div>
<div class="MsoNormal">
<b><span style="font-size: 12.0pt; line-height: 107%;">Use a Pool to Share Resource Objects<o:p></o:p></span></b></div>
<div class="MsoNormal">
Examples of resource objects are threads, JDBC connections,
sockets, and complex user-defined objects. They are expensive to create, and
pooling them reduces the overhead of repetitively creating and destroying them.
On the down side, using a pool means you must implement the code to manage it
and pay the overhead of synchronization when you get or remove objects from the
pool. But the overall performance gain you get from using a pool to manage
expensive resource objects outweighs that overhead.<o:p></o:p></div>
<div class="MsoNormal">
However, be cautious on implementing a resource pool. The
following mistakes in pool management are often observed:<o:p></o:p></div>
<div class="MsoNormal">
a resource object which should be used only serially is
given to more than one user at the same time objects that are returned to the
pool are not properly accounted for and are therefore not reused, wasting
resources and causing a memory leak elements or object references kept in the
pool are not reset or cleaned up properly before being given to the next user<o:p></o:p></div>
<div class="MsoNormal">
These mistakes can have severe consequences including data
corruption, memory leaks, a race condition, or even a security problem. Our
advice in managing your pool is: keep your algorithm simple.<o:p></o:p></div>
<div class="MsoNormal">
The J2EE section in this document includes examples showing
how you can use Oracle's built-in JDBC connection caching and the servlet's
SingleThreadModel to help manage a shared pool without implementing it
yourself.<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<o:p><br /></o:p></div>
<div class="MsoNormal">
<b><span style="font-size: 12.0pt; line-height: 107%;">Recycle Objects<o:p></o:p></span></b></div>
<div class="MsoNormal">
Recycling objects is similar to creating an object pool. But
there is no need to manage it because the pool only has one object. This
approach is most useful for relatively large container objects (such as Vector
or Hashtable) that you want to use for holding some temporary data. Reusing
these objects instead of creating new ones each time can avoid memory
allocation and reduce garbage collection.<o:p></o:p></div>
<div class="MsoNormal">
Similar to using a pool, you must take precautions to clear
all the elements in any recycled object before you reuse it to avoid memory
leak. The collection interfaces have the built-in clear() method that you can
use. If you are building your object, you should remember to include a reset()
or clear() method if necessary.<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<o:p><br /></o:p></div>
<div class="MsoNormal">
<b><span style="font-size: 12.0pt; line-height: 107%;">Use Lazy Initialization to Defer
Creating the Object Until You Need It.<o:p></o:p></span></b></div>
<div class="MsoNormal">
Defer creating an object until it is needed if the
initialization of the object is expensive or if the object is needed only under
some specific condition.<o:p></o:p></div>
<div class="MsoNormal">
public class myClass<o:p></o:p></div>
<div class="MsoNormal">
{<o:p></o:p></div>
<div class="MsoNormal">
private
mySpecialObject myObj;<o:p></o:p></div>
<div class="MsoNormal">
...<o:p></o:p></div>
<div class="MsoNormal">
public
mySpecialObject<o:p></o:p></div>
<div class="MsoNormal">
getSpecialObject()<o:p></o:p></div>
<div class="MsoNormal">
{<o:p></o:p></div>
<div class="MsoNormal">
if (myObj ==
null)<o:p></o:p></div>
<div class="MsoNormal">
myObj =
new mySpecialObject();<o:p></o:p></div>
<div class="MsoNormal">
return myObj;<o:p></o:p></div>
<div class="MsoNormal">
}<o:p></o:p></div>
<div class="MsoNormal">
...<o:p></o:p></div>
<div class="MsoNormal">
}<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><span style="font-size: 12.0pt; line-height: 107%;">Use Stringbuffer Instead of String
Concatenation<o:p></o:p></span></b></div>
<div class="MsoNormal">
The String class is the most commonly used class in Java.
Especially in Web applications, it is used extensively to generate and format
HTML content.<o:p></o:p></div>
<div class="MsoNormal">
String is designed to be immutable; in order to modify a
String, you have to create a new String object. Therefore, string concatenation
can result in creating many intermediate String objects before the final String
can be constructed. StringBuffer is the mutable companion class of String; it
allows you to modify the String. Therefore, StringBuffer is generally more
efficient than String when concatenation is needed.<o:p></o:p></div>
<div class="MsoNormal">
This section also features the following practices:<o:p></o:p></div>
<div class="MsoNormal">
Use StringBuffer Instead of String Concatenation If You
Repeatedly Append to a String In Multiple Statements<o:p></o:p></div>
<div class="MsoNormal">
Use Either String or StringBuffer If the Concatenation Is
Within One Statement<o:p></o:p></div>
<div class="MsoNormal">
Use StringBuffer Instead of String Concatenation If You Know
the Size of the String<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<o:p><br /></o:p></div>
<div class="MsoNormal">
<b><span style="font-size: 12.0pt; line-height: 107%;">Use StringBuffer Instead of String
Concatenation If You Repeatedly Append to a String In Multiple Statements<o:p></o:p></span></b></div>
<div class="MsoNormal">
Using the "+=" operation on a String repeatedly is
expensive.<o:p></o:p></div>
<div class="MsoNormal">
For example:<o:p></o:p></div>
<div class="MsoNormal">
String s = new<o:p></o:p></div>
<div class="MsoNormal">
String();<o:p></o:p></div>
<div class="MsoNormal">
[do some work
...]<o:p></o:p></div>
<div class="MsoNormal">
s += s1;<o:p></o:p></div>
<div class="MsoNormal">
[do some more
work...]<o:p></o:p></div>
<div class="MsoNormal">
s += s2;<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
Replace the above string concatenation with a StringBuffer:<o:p></o:p></div>
<div class="MsoNormal">
StringBuffer strbuf = new StringBuffer();<o:p></o:p></div>
<div class="MsoNormal">
[do some work
...]<o:p></o:p></div>
<div class="MsoNormal">
strbuf.append(s1);<o:p></o:p></div>
<div class="MsoNormal">
[so some more
work ...]<o:p></o:p></div>
<div class="MsoNormal">
strbuf.append(s2);<o:p></o:p></div>
<div class="MsoNormal">
String s = strbuf.toString();<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<o:p><br /></o:p></div>
<div class="MsoNormal">
<b><span style="font-size: 12.0pt; line-height: 107%;">Use Either String or StringBuffer If
the Concatenation Is Within One Statement<o:p></o:p></span></b></div>
<div class="MsoNormal">
String and StringBuffer perform the same in some cases; so
you do not need to use StringBuffer directly.<o:p></o:p></div>
<div class="MsoNormal">
String s =
"a" + "b" + "c";<o:p></o:p></div>
<div class="MsoNormal">
to<o:p></o:p></div>
<div class="MsoNormal">
String s =
"abc";<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
Optimization is done automatically by the compiler.<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
The Java2 compiler will automatically collapse the above.<o:p></o:p></div>
<div class="MsoNormal">
The Java2 compiler will also automatically convert the
following:<o:p></o:p></div>
<div class="MsoNormal">
String s = s1
+ s2;<o:p></o:p></div>
<div class="MsoNormal">
to<o:p></o:p></div>
<div class="MsoNormal">
String s =
(new StringBuffer()).append(s1).append(s2).toString();<o:p></o:p></div>
<div class="MsoNormal">
In these cases, there is no need to use StringBuffer
directly.<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<o:p><br /></o:p></div>
<div class="MsoNormal">
<b><span style="font-size: 12.0pt; line-height: 107%;">Use StringBuffer Instead of String
Concatenation If You Know the Size of the String<o:p></o:p></span></b></div>
<div class="MsoNormal">
The default character buffer for StringBuffer is 16. When
the buffer is full, a new one has to be re-allocated (usually at twice the size
of the original one). The old buffer will be released after the content is
copied to the new one. This constant reallocation can be avoided if the
StringBuffer is created with a buffer size that is big enough to hold the
String.<o:p></o:p></div>
<div class="MsoNormal">
The following will be more efficient than using a String
concatenation.<o:p></o:p></div>
<div class="MsoNormal">
String s = (new
StringBuffer(1024)).<o:p></o:p></div>
<div class="MsoNormal">
append(s1).append(s2). toString();<o:p></o:p></div>
<div class="MsoNormal">
will be faster than<o:p></o:p></div>
<div class="MsoNormal">
String s = s1 +
s2;<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<o:p><br /></o:p></div>
<div class="MsoNormal">
<b><span style="font-size: 12.0pt; line-height: 107%;">Loose Coupling<o:p></o:p></span></b></div>
<div class="MsoNormal">
Avoid using implementation types (i.e., HashSet, ArrayList);
use the interface (i.e, Set, List) instead.<o:p></o:p></div>
<div class="MsoNormal">
Here's an example of code that would trigger this rule:<o:p></o:p></div>
<div class="MsoNormal">
import java.util.*;<o:p></o:p></div>
<div class="MsoNormal">
public class Bar {<o:p></o:p></div>
<div class="MsoNormal">
<span style="color: #6aa84f;"> // Use List instead</span><o:p></o:p></div>
<div class="MsoNormal">
private ArrayList
list = new ArrayList();<o:p></o:p></div>
<div class="MsoNormal">
<span style="color: #6aa84f;"> // Use Set instead<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="color: #6aa84f;">// public Set getFoo() {…</span><o:p></o:p></div>
<div class="MsoNormal">
public HashSet
getFoo() {<o:p></o:p></div>
<div class="MsoNormal">
returnnew HashSet();<o:p></o:p></div>
<div class="MsoNormal">
}<o:p></o:p></div>
<div class="MsoNormal">
}<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><span style="font-size: 12.0pt; line-height: 107%;">Only One Return<o:p></o:p></span></b></div>
<div class="MsoNormal">
A method should have only one exit point, and that should be
the last statement in the method.<o:p></o:p></div>
<div class="MsoNormal">
Here's an example of code that would trigger this rule: <o:p></o:p></div>
<div class="MsoNormal">
public class
OneReturnOnly1 {<o:p></o:p></div>
<div class="MsoNormal">
public void foo(int
x) {<o:p></o:p></div>
<div class="MsoNormal">
if (x > 0) {<o:p></o:p></div>
<div class="MsoNormal">
return
"hey"; // oops, multiple exit
points!<o:p></o:p></div>
<div class="MsoNormal">
}<o:p></o:p></div>
<div class="MsoNormal">
return
"hi";<o:p></o:p></div>
<div class="MsoNormal">
}<o:p></o:p></div>
<div class="MsoNormal">
}<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><span style="font-size: 12.0pt; line-height: 107%;">Null Assignment<o:p></o:p></span></b></div>
<div class="MsoNormal">
Assigning a "null" to a variable (outside of its
declaration) is usually bad form. Sometimes, the assignment is an indication
that the programmer doesn't completely understand what is going on in the code.
<o:p></o:p></div>
<div class="MsoNormal">
NOTE: This sort of assignment may in rare cases be useful to
encourage garbage collection. If that's what you're using it for, by all means,
disregard this rule :-)<o:p></o:p></div>
<div class="MsoNormal">
Here's an example of code that would trigger this rule: <o:p></o:p></div>
<div class="MsoNormal">
public class Foo {<o:p></o:p></div>
<div class="MsoNormal">
public void bar() {<o:p></o:p></div>
<div class="MsoNormal">
Object x = null;
// This is OK.<o:p></o:p></div>
<div class="MsoNormal">
x = new Object();<o:p></o:p></div>
<div class="MsoNormal">
<span style="color: #6aa84f;"> // Big, complex
piece of code here.</span><o:p></o:p></div>
<div class="MsoNormal">
x = null; // This
is BAD.<o:p></o:p></div>
<div class="MsoNormal">
<span style="color: #6aa84f;">// Big, complex
piece of code here</span>.<o:p></o:p></div>
<div class="MsoNormal">
}<o:p></o:p></div>
<div class="MsoNormal">
}<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><span style="font-size: 12.0pt; line-height: 107%;">Call Super in Constructor<o:p></o:p></span></b></div>
<div class="MsoNormal">
It is a good practice to call super() in a constructor. If
super() is not called but another constructor (such as an overloaded
constructor) is called, this rule will not report it.<o:p></o:p></div>
<div class="MsoNormal">
Here's an example of code that would trigger this rule: <o:p></o:p></div>
<div class="MsoNormal">
public class Foo extends Bar{<o:p></o:p></div>
<div class="MsoNormal">
public Foo() {<o:p></o:p></div>
<div class="MsoNormal">
<span style="color: #6aa84f;">// call the
constructor of Bar</span><o:p></o:p></div>
<div class="MsoNormal">
super();<o:p></o:p></div>
<div class="MsoNormal">
}<o:p></o:p></div>
<div class="MsoNormal">
public Foo(int code)
{<o:p></o:p></div>
<div class="MsoNormal">
<span style="color: #6aa84f;">// do something with
code</span><o:p></o:p></div>
<div class="MsoNormal">
this();<o:p></o:p></div>
<div class="MsoNormal">
<span style="color: #6aa84f;"> // no problem with
this</span><o:p></o:p></div>
<div class="MsoNormal">
}<o:p></o:p></div>
<div class="MsoNormal">
} <o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><span style="font-size: 12.0pt; line-height: 107%;">Switch Statements Should Have Default<o:p></o:p></span></b></div>
<div class="MsoNormal">
Switch statements should have a default label.<o:p></o:p></div>
<div class="MsoNormal">
Here's an example of code that would trigger this rule: <o:p></o:p></div>
<div class="MsoNormal">
public class Foo {<o:p></o:p></div>
<div class="MsoNormal">
public void bar() {<o:p></o:p></div>
<div class="MsoNormal">
int x = 2;<o:p></o:p></div>
<div class="MsoNormal">
switch (x) {<o:p></o:p></div>
<div class="MsoNormal">
case 2: int j = 8;<o:p></o:p></div>
<div class="MsoNormal">
}<o:p></o:p></div>
<div class="MsoNormal">
}<o:p></o:p></div>
<div class="MsoNormal">
}<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><span style="font-size: 12.0pt; line-height: 107%;">Avoid Reassigning Parameters<o:p></o:p></span></b></div>
<div class="MsoNormal">
Reassigning values to parameters is a questionable practice.
Use a temporary local variable instead or use only when required.<o:p></o:p></div>
<div class="MsoNormal">
Here's an example of code that would trigger this rule: <o:p></o:p></div>
<div class="MsoNormal">
public class Foo {<o:p></o:p></div>
<div class="MsoNormal">
private void
foo(String bar) {<o:p></o:p></div>
<div class="MsoNormal">
bar =
"something else";<o:p></o:p></div>
<div class="MsoNormal">
}<o:p></o:p></div>
<div class="MsoNormal">
}<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><span style="font-size: 12.0pt; line-height: 107%;">Final Field Could Be Static<o:p></o:p></span></b></div>
<div class="MsoNormal">
If a final field is assigned to a compile-time constant, it
could be made static, thus saving overhead in each object at runtime.<o:p></o:p></div>
<div class="MsoNormal">
Here's an example of code that would trigger this rule: <o:p></o:p></div>
<div class="MsoNormal">
public class Foo {<o:p></o:p></div>
<div class="MsoNormal">
public final int BAR
= 42; <span style="color: #6aa84f;">// this could be static and save some space</span><o:p></o:p></div>
<div class="MsoNormal">
}<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><span style="font-size: 12.0pt; line-height: 107%;">Compare Objects With Equals<o:p></o:p></span></b></div>
<div class="MsoNormal">
Use equals() to compare object references; avoid comparing
them with ==.<o:p></o:p></div>
<div class="MsoNormal">
Here's an example of code that would violate this rule: <o:p></o:p></div>
<div class="MsoNormal">
class Foo {<o:p></o:p></div>
<div class="MsoNormal">
boolean bar(String a,
String b) {<o:p></o:p></div>
<div class="MsoNormal">
return a == b;<o:p></o:p></div>
<div class="MsoNormal">
}<o:p></o:p></div>
<div class="MsoNormal">
}<o:p></o:p></div>
<div class="MsoNormal">
If you have to compare POJO objects, override the equals and
hashcode, most IDE’s can do this for you, this will be faster and less verbose
than you compare field by field.<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><span style="font-size: 12.0pt; line-height: 107%;">Position Literals First In
Comparisons if you don’t want to check for null first<o:p></o:p></span></b></div>
<div class="MsoNormal">
Position literals first in String comparisons - that way if
the String is null you won't get a NullPointerException, it'll just return
false.<o:p></o:p></div>
<div class="MsoNormal">
Here's an example of code that would violatethis rule: <o:p></o:p></div>
<div class="MsoNormal">
class Foo {<o:p></o:p></div>
<div class="MsoNormal">
boolean bar(String x)
{<o:p></o:p></div>
<div class="MsoNormal">
return
x.equals("2"); <span style="color: #6aa84f;">// should be "2".equals(x)</span><o:p></o:p></div>
<div class="MsoNormal">
}<o:p></o:p></div>
<div class="MsoNormal">
} <o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><span style="font-size: 12.0pt; line-height: 107%;">Close Resource<o:p></o:p></span></b></div>
<div class="MsoNormal">
Ensure that resources (like Connection, Statement, and
ResultSet objects) are always closed after use.<o:p></o:p></div>
<div class="MsoNormal">
Here's an example of code that would violate this rule: <o:p></o:p></div>
<div class="MsoNormal">
public class Bar {<o:p></o:p></div>
<div class="MsoNormal">
public void foo() {<o:p></o:p></div>
<div class="MsoNormal">
Connection c =
pool.getConnection();<o:p></o:p></div>
<div class="MsoNormal">
try {<o:p></o:p></div>
<div class="MsoNormal">
<span style="color: #6aa84f;"> // do stuff</span><o:p></o:p></div>
<div class="MsoNormal">
} catch
(SQLException ex) {<o:p></o:p></div>
<div class="MsoNormal">
// handle
exception<o:p></o:p></div>
<div class="MsoNormal">
} finally {<o:p></o:p></div>
<div class="MsoNormal">
<span style="color: #6aa84f;">// oops, should
close the connection using 'close'!<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="color: #6aa84f;"> // c.close();</span><o:p></o:p></div>
<div class="MsoNormal">
}<o:p></o:p></div>
<div class="MsoNormal">
}<o:p></o:p></div>
<div class="MsoNormal">
}<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><span style="font-size: 12.0pt; line-height: 107%;">Non Static Initializer<o:p></o:p></span></b></div>
<div class="MsoNormal">
A nonstatic initializer block will be called any time a
constructor is invoked (just prior to invoking the constructor). While this is
a valid language construct, it is rarely used and is confusing.<o:p></o:p></div>
<div class="MsoNormal">
Here's an example of code that would violate this rule: <o:p></o:p></div>
<div class="MsoNormal">
public class MyClass {<o:p></o:p></div>
<div class="MsoNormal">
<span style="color: #6aa84f;">// this block gets
run before any call to a constructor</span><o:p></o:p></div>
<div class="MsoNormal">
{<o:p></o:p></div>
<div class="MsoNormal">
System.out.println("I am about to construct myself");<o:p></o:p></div>
<div class="MsoNormal">
}<o:p></o:p></div>
<div class="MsoNormal">
}<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><span style="font-size: 12.0pt; line-height: 107%;">Avoid Protected Field in Final Class<o:p></o:p></span></b></div>
<div class="MsoNormal">
Do not use protected fields in final classes since they
cannot be subclassed. Clarify your intent by using private or package access
modifiers instead.<o:p></o:p></div>
<div class="MsoNormal">
Here's an example of code that would violate this rule: <o:p></o:p></div>
<div class="MsoNormal">
public final class Bar {<o:p></o:p></div>
<div class="MsoNormal">
private int x;<o:p></o:p></div>
<div class="MsoNormal">
protected int y; <span style="color: #6aa84f;">// Bar cannot be subclassed, so is y really <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="color: #6aa84f;">
// private or package visible???</span><o:p></o:p></div>
<div class="MsoNormal">
Bar() {}<o:p></o:p></div>
<div class="MsoNormal">
}<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><span style="font-size: 12.0pt; line-height: 107%;">Avoid Synchronized At Method Level<o:p></o:p></span></b></div>
<div class="MsoNormal">
Method level synchronization can backfire when new code is
added to the method. Block-level synchronization helps to ensure that only the
code that needs synchronization gets it.<o:p></o:p></div>
<div class="MsoNormal">
Here's an example of code that would violate this rule:<o:p></o:p></div>
<div class="MsoNormal">
public class Foo {<o:p></o:p></div>
<div class="MsoNormal">
<span style="color: #6aa84f;">// Try to avoid this</span><o:p></o:p></div>
<div class="MsoNormal">
synchronized void
foo() {<o:p></o:p></div>
<div class="MsoNormal">
}<o:p></o:p></div>
<div class="MsoNormal">
<span style="color: #6aa84f;">// Prefer this:</span><o:p></o:p></div>
<div class="MsoNormal">
void bar() {<o:p></o:p></div>
<div class="MsoNormal">
synchronized(this) {<o:p></o:p></div>
<div class="MsoNormal">
}<o:p></o:p></div>
<div class="MsoNormal">
}<o:p></o:p></div>
<div class="MsoNormal">
}<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><span style="font-size: 12.0pt; line-height: 107%;">Use Notify All Instead Of Notify<o:p></o:p></span></b></div>
<div class="MsoNormal">
Thread.notify() awakens a thread monitoring the object. If
more than one thread is monitoring, then only one is chosen. The thread chosen
is arbitrary; thus it's usually safer to call notifyAll() instead.<o:p></o:p></div>
<div class="MsoNormal">
Here's an example of code that would violate this rule: <o:p></o:p></div>
<div class="MsoNormal">
public class Foo {<o:p></o:p></div>
<div class="MsoNormal">
void bar() {<o:p></o:p></div>
<div class="MsoNormal">
x.notify();<o:p></o:p></div>
<div class="MsoNormal">
<span style="color: #6aa84f;">// If many threads
are monitoring x, <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="color: #6aa84f;"> // only one (and you
won't know which) will be notified.<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="color: #6aa84f;"> // use instead:</span><o:p></o:p></div>
<div class="MsoNormal">
x.notifyAll();<o:p></o:p></div>
<div class="MsoNormal">
}<o:p></o:p></div>
<div class="MsoNormal">
} <o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><span style="font-size: 12.0pt; line-height: 107%;">Avoid Instantiating Objects in Loops<o:p></o:p></span></b></div>
<div class="MsoNormal">
Detects when a new object is created inside a loop<o:p></o:p></div>
<div class="MsoNormal">
Here's an example of code that would violate this rule: <o:p></o:p></div>
<div class="MsoNormal">
public class Something {<o:p></o:p></div>
<div class="MsoNormal">
public static void
main( String as[] ) { <o:p></o:p></div>
<div class="MsoNormal">
for (int i = 0; i
>; 10; i++) {<o:p></o:p></div>
<div class="MsoNormal">
Foo f = new
Foo(); <span style="color: #6aa84f;">//Avoid this whenever you can it's really<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="color: #6aa84f;">
//expensive</span><o:p></o:p></div>
<div class="MsoNormal">
}<o:p></o:p></div>
<div class="MsoNormal">
}<o:p></o:p></div>
<div class="MsoNormal">
}<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><span style="font-size: 12.0pt; line-height: 107%;">String Instantiation<o:p></o:p></span></b></div>
<div class="MsoNormal">
Avoid instantiating String objects; this is usually
unnecessary.<o:p></o:p></div>
<div class="MsoNormal">
Here's an example of code that would violate this rule: <o:p></o:p></div>
<div class="MsoNormal">
public class Foo {<o:p></o:p></div>
<div class="MsoNormal">
private String bar =
new String("bar"); <span style="color: #6aa84f;">// just do a String bar = "bar";</span><o:p></o:p></div>
<div class="MsoNormal">
} <o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><span style="font-size: 12.0pt; line-height: 107%;">For extract the max of JVM Garbage
Collector (GC) and memory management<o:p></o:p></span></b></div>
<div class="MsoNormal">
Avoid at all costs, leave objects that aren’t marked as
final without be cleaned (set it to null) from memory, even within a method as
GC doesn’t actually run just because the method has ran, those method objects
will be in the object pool (the heap) up to the GC runs that can be hours after
or even in the next day everything depends on the heaven size (memory that the
JVM has allocated as max to be used), this also helps to avoid memory leaks. The main problem with Java that demands
constants Application Servers restarts is bad memory that’s caused by bad code.
Fragmented memory is a direct effect from bad code as well and that’s ends up
with Out Of Memory Errors as for the JVM load up more objects it needs
continuous memory. Meaning if you have 10Mb of memory free doesn’t mean that its
continuous memory addresses. The GC doesn’t see it and that’s the reason good
code matters. The JVM just can load up objects to the memory if the free memory
is compose by continuous memory address.<o:p></o:p></div>
<div class="MsoNormal">
E.g.:<o:p></o:p></div>
<div class="MsoNormal">
Amount of free memory: 10240kb
(or 10Mb);<o:p></o:p></div>
<div class="MsoNormal">
Max free memory continuous available: 800kb;<o:p></o:p></div>
<div class="MsoNormal">
This imply that the largest object that the JVM may load up
is 800kb, if the object has 800.1kb it will throw Out Of Memory.<o:p></o:p></div>
<div class="MsoNormal">
The reason is that the JVM doesn’t need run GC as it has
10Mb and the object been load has 800Kb, so no GC in this operation, however
when the class loader try to loads up the object into the memory and the object
is bigger than the max continuous free memory, it will crash without run the
GC.<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
Marking the object to final or setting it as null after use,
will mark the object for be GC’ed.<o:p></o:p></div>
<div class="MsoNormal">
E.g.:<o:p></o:p></div>
<div class="MsoNormal">
final List<AnObject> objList = foo.getMyList();<o:p></o:p></div>
<div class="MsoNormal">
or <o:p></o:p></div>
<div class="MsoNormal">
List<AnObject> objList = null;<o:p></o:p></div>
<div class="MsoNormal">
…doing some tasks that will update the objList<o:p></o:p></div>
<div class="MsoNormal">
final An<o:p></o:p></div>
<div class="MsoNormal">
objList = null;<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
Avoid return values that doesn’t have a memory reference as
it will live longer in memory even after several GC ran and also this creates
other problem that is make the GC quite slower as it need to check all the
references taking longer than check just one.<o:p></o:p></div>
<div class="MsoNormal">
E.g.:<o:p></o:p></div>
<div class="MsoNormal">
public List<AnObject> getObjList() {<o:p></o:p></div>
<div class="MsoNormal">
…..<o:p></o:p></div>
<div class="MsoNormal">
<span style="color: #6aa84f;">// don’t </span><o:p></o:p></div>
<div class="MsoNormal">
return getList();<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="color: #6aa84f;">// do</span><o:p></o:p></div>
<div class="MsoNormal">
final List<AnObject> objToReutn = getList();<o:p></o:p></div>
<div class="MsoNormal">
return objToReturn;<o:p></o:p></div>
<div class="MsoNormal">
}<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
Maximize the object reuse as creation ‘costs’ more for JVM
(mean takes longer to create then reuse what’s in there).<o:p></o:p></div>
<div class="MsoNormal">
Use primitive types everywhere when it’s possible.<o:p></o:p></div>
<div class="MsoNormal">
Avoid to load long strings in memory, use stream instead and
always that’s possible.<o:p></o:p></div>
<div class="MsoNormal">
Avoid add up too many jars in the project for use a small
fraction of it to resolve the problem you can extract just what you need from
the jar creating other jar or create the part of code needed and don’t using at
all the third part jar. Keep in mind that “Frameworks aren’t in most cases
written by experts, so in over 90% of cases it’s not optimized for optimal
memory use”<o:p></o:p></div>
<div class="MsoNormal">
Use the right type for the right data, e.g.:<o:p></o:p></div>
<div class="MsoNormal">
<span style="color: #6aa84f;">// don’t</span><o:p></o:p></div>
<div class="MsoNormal">
String testVar = “C”;<o:p></o:p></div>
<div class="MsoNormal">
Double value = 10.00;<o:p></o:p></div>
<div class="MsoNormal">
/<span style="color: #6aa84f;">/ do</span><o:p></o:p></div>
<div class="MsoNormal">
char testVar = ‘C’;<o:p></o:p></div>
<div class="MsoNormal">
int value = 10;<o:p></o:p></div>
<div class="MsoNormal">
<span style="color: #6aa84f;">// or if you need floating points</span><o:p></o:p></div>
<div class="MsoNormal">
float value = 10.0f;<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
Use ENUMS instead having larger or several constant files whenever possible, as
it’s has several advantages over those several or immense constants classes. The
main advantage is speed and very low memory footprint as the class loader will
be loading up just a small set and getting just one object value and then
destroying the object, as if loading up a class full of constants will consume
far more memory.<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
Reference used:<o:p></o:p></div>
<div class="MsoNormal">
<a href="http://docs.oracle.com/cd/A97688_16/generic.903/bp/java.htm">http://docs.oracle.com/cd/A97688_16/generic.903/bp/java.htm</a><o:p></o:p></div>
<div class="MsoNormal">
<a href="https://sites.google.com/site/javatouch/javacode-bestpractices">https://sites.google.com/site/javatouch/javacode-bestpractices</a><o:p></o:p></div>
<div class="MsoNormal">
<a href="https://www.cs.virginia.edu/kim/publicity/pldi09tutorials/memory-efficient-java-tutorial.pdf">https://www.cs.virginia.edu/kim/publicity/pldi09tutorials/memory-efficient-java-tutorial.pdf</a></div>
<div class="MsoNormal">
<br /></div>
<br />
<div class="MsoNormal">
<br /></div>
<br />
<br /></div>
Anonymoushttp://www.blogger.com/profile/00908564854719054075noreply@blogger.com0tag:blogger.com,1999:blog-4729831854233341997.post-59739124892058607512013-05-22T19:38:00.001-07:002013-05-22T19:38:07.113-07:00Example using Volley Google Framework (very simple)<p>First you can download the <a href="https://github.com/villacak/GoogleHttpFramework.git" target="_blank">Git</a> where I did create a small lib project that have <a href="https://android.googlesource.com/platform/external/okhttp/" target="_blank">OkHttp</a> and <a href="https://android.googlesource.com/platform/frameworks/volley/" target="_blank">Volley</a> together, to use it as library project or export the .jar file to use it on your projects.</p> <p>If you want to use the project where I did put both together to facilitate the life (at least for myself), you need, after you have opened the project in the Eclipse, right click on the project name –> Properties –> Android , then scroll down to the bottom and check the box where says <em>isLibrary</em> , then <em>Apply</em> and <em>Ok</em>.</p> <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjvks_yEdZFIIRXJ_NNtBmPy4WmN04icv43fLl1lUbBocOGOt304PHvJzNTspMDKeHNP3bUZ7cZTxr6VU3muxZnQ3xo930tEH4YQCnnI73hI-Pa_6nNi8-3yZ6o4ZWK6Hkfvh1HwXvKpqM/s1600-h/image%25255B2%25255D.png"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjHV14_baDjzle1NGNBztJ4FO3JsNSKfefEpeWgc1XC_yzJayTojD0a-ZD4Gx-ccfaLYG-PmOXSz7CO6FNVnVduAEtTveGU2t3Csv4dkef7Pm294nC5q8GVCDtUkZzCTP0WtnYqMNUzmUI/?imgmax=800" width="187" height="244"></a></p> <p>After you have done that you can open your project, and going over your project name doing right click –> Properties –> Android, then scroll down to the bottom and click on add and select your library project that in this case is called GoogleHttpFramework, click Ok, then Apply and Ok.</p> <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFdWO83JyOG_Jt678tCaQwo-Lz4FpVIrtr7QRyTLzLC4h4ZjraeWyJuQk881yAFRdf2aCvfn420um1Wz7V8MgRLMVJgxEFD6x68oF63dJSbS4Mudgzg9k1j0rWyvUSE6plzCjD50LBYuw/s1600-h/image%25255B5%25255D.png"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXmRamEFSC30myqocHabjSfgPjHxaBZZrnxN2SmKZezzNkzpzhD4UhWGGwfXOTnx29fzwg6d6ilRzpd35-29tTN0SSnz8yZsL1GoeqOsUXqqmGa12JWv3Tivt6xnvO1mHMNeA2mTH3xQk/?imgmax=800" width="149" height="244"></a></p> <p>Doing this you will have create the link just like you would do inserting the jar in your built path.</p> <p>Now if you want to export the .jar file, it’s quite simple, it’s just right click over the project, in this case the GoogleHttpFramework then Export –> Java –> JAR File, uncheck all checkboxes like the image bellow, select the project and the path that you want have the .jar generated, then click finish.</p> <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9jzH3ALP2mbLBQ109QSBxxFVr9zGerkl4Nu2xR8eVcolCO-7q4TuUoWW4xG1oLWCy9lUwgf4sUf6tZfoisQuKl2Sj4sMpsvneSHlRW9FrBkEVSQxB62Y5PTq1KGKmsj1_SliqmvVFRIQ/s1600-h/image%25255B8%25255D.png"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxo4tZgNzTKodw0WRoVbeeb73ipr7QWWbpeViPw98UQxJ_OQUkWpV6wPj_csmnnuofhYCyoGW0RN0QU5WzXIQgIuzdpzOUPDJsKkr4StDnwPoX3e-_XZ6pAD4zEonMknpqk2ficGZiJsQ/?imgmax=800" width="207" height="244"></a></p> <p>Then you can copy the .jar to you /lib folder inside your project.</p> <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgkaxRCVaH6AWAN71BGBO877PyDss75Et4oxY8AaKHvRg8q4GpRfILs3kPLUTl5dJTw85XZBi3yoEqNWhNoRWi-xP9wHChUM4rbOovUXclYnR5KORd_DQn8VSQ91fHlEy4EPzTnuT-GNoA/s1600-h/image%25255B11%25255D.png"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnqoYsWdnNJT9m5l4ADKBKSfZBiVPHNkf5h394-YebsD21uV88r67frkjbPcqP_fF7ZJyngBDcLGv07QGN1OoTkCVXzbdF6PNew6Nmgq8iadA3IRZ78bM2ckZ8QP_7_6C4ReONCJ9SFEc/?imgmax=800" width="244" height="135"></a></p> <p>From now on you have access to your jar or of your library project.</p> <p>Then you can open my very simple example that you have downloaded from the <a href="https://github.com/villacak/RestFulClient.git" target="_blank">Git</a> also. The example project is called RestFulClient. </p> <p>This example is quite simple and you have only two buttons in the screen one will call a rest service that send us a bad formatted JSON object and consequently will generate an error, that will display it to you in a TextView on your screen, the second button will make a simple call to a Yahoo rest ws and will return a number that should be translated to a Date, however the number doesn’t seem come in a real long number, meaning that the date will basically be the same just having differences on the seconds. </p> <p>I’m using two URLs that I got from the web, for don’t have to create a server side project that would take some time, as this is a quite simple example and we just need one working well and other failing.</p> <p>Here is the method where the Volley makes the call to the Rest WS.</p> <div class="csharpcode"><pre class="alt"><span class="kwrd">private</span> <span class="kwrd">void</span> getService(String url) {</pre><pre><span class="rem">// JSONObject reqBody = new JSONObject();</span></pre><pre class="alt"> Map<String,String> <span class="kwrd">params</span> = <span class="kwrd">new</span> HashMap<String,String>();</pre><pre> <span class="kwrd">if</span> (url.equals(URL_SUCCESS)) {</pre><pre class="alt"> <span class="kwrd">try</span> {</pre><pre> <span class="kwrd">params</span>.put(<span class="str">"appid"</span>, <span class="str">"YahooDemo"</span>);</pre><pre class="alt"> <span class="kwrd">params</span>.put(<span class="str">"output"</span>, <span class="str">"json"</span>);</pre><pre> url = addParamsToUrl(url, <span class="kwrd">params</span>);</pre><pre class="alt"><span class="rem">// reqBody.put("appid", "YahooDemo");</span></pre><pre><span class="rem">// reqBody.put("output", "json");</span></pre><pre class="alt"> volleyRequestQueue = Volley.newRequestQueue(<span class="kwrd">this</span>);</pre><pre> <span class="rem">// GET</span></pre><pre class="alt"> volleyRequestQueue.add(<span class="kwrd">new</span> JsonObjectRequest(Method.GET, url, <span class="kwrd">null</span>, <span class="kwrd">new</span> MyResponseListener(), <span class="kwrd">new</span> MyErrorListener()));</pre><pre> </pre><pre class="alt"> <span class="rem">// POST </span></pre><pre> <span class="rem">// Need to comment at least the line 86 where url receive the par1ameters and uncomment lines 79, 87 and 88</span></pre><pre class="alt"> <span class="rem">// However this url doesn't seems accept post, you need to try a different URL or create your own for test purpose</span></pre><pre><span class="rem">// volleyRequestQueue.add(new JsonObjectRequest(Method.POST, url, reqBody, new MyResponseListener(), new MyErrorListener()));</span></pre><pre class="alt"> } <span class="kwrd">catch</span> (Exception e) {</pre><pre> Log.e(<span class="str">"ErrorListener"</span>, e.getLocalizedMessage());</pre><pre class="alt"> }</pre><pre> } <span class="kwrd">else</span> {</pre><pre class="alt"> <span class="kwrd">params</span>.put(<span class="str">"level"</span>, <span class="str">"1"</span>);</pre><pre> url = addParamsToUrl(url, <span class="kwrd">params</span>);</pre><pre class="alt"> volleyRequestQueue = Volley.newRequestQueue(<span class="kwrd">this</span>);</pre><pre> volleyRequestQueue.add(<span class="kwrd">new</span> JsonObjectRequest(Method.GET, url, <span class="kwrd">null</span>, <span class="kwrd">new</span> MyResponseListener(), <span class="kwrd">new</span> MyErrorListener()));</pre><pre class="alt"> }</pre><pre> }</pre></div><br /><style type="text/css">.csharpcode, .csharpcode pre<br />{<br /> font-size: small;<br /> color: black;<br /> font-family: consolas, "Courier New", courier, monospace;<br /> background-color: #ffffff;<br /> /*white-space: pre;*/<br />}<br />.csharpcode pre { margin: 0em; }<br />.csharpcode .rem { color: #008000; }<br />.csharpcode .kwrd { color: #0000ff; }<br />.csharpcode .str { color: #006080; }<br />.csharpcode .op { color: #0000c0; }<br />.csharpcode .preproc { color: #cc6633; }<br />.csharpcode .asp { background-color: #ffff00; }<br />.csharpcode .html { color: #800000; }<br />.csharpcode .attr { color: #ff0000; }<br />.csharpcode .alt <br />{<br /> background-color: #f4f4f4;<br /> width: 100%;<br /> margin: 0em;<br />}<br />.csharpcode .lnum { color: #606060; }<br /></style><br /><br /><br /><br /><br /><br /><p>and here the piece of code for the class response.</p><br /><div class="csharpcode"><pre class="alt"><span class="kwrd">class</span> MyResponseListener implements Listener<JSONObject> {</pre><pre> </pre><pre class="alt"> @Override</pre><pre> <span class="kwrd">public</span> <span class="kwrd">void</span> onResponse(JSONObject response) {</pre><pre class="alt"> MainActivity.<span class="kwrd">this</span>.jsonObj = response;</pre><pre> <span class="kwrd">try</span> {</pre><pre class="alt"> JSONObject result = MainActivity.<span class="kwrd">this</span>.jsonObj.getJSONObject(<span class="str">"Result"</span>);</pre><pre> String timestamp = result.getString(<span class="str">"Timestamp"</span>);</pre><pre class="alt"> MainActivity.<span class="kwrd">this</span>.resultTxt.setText(<span class="kwrd">new</span> Date(Long.parseLong(timestamp.trim())).toString());</pre><pre> } <span class="kwrd">catch</span> (Exception e) {</pre><pre class="alt"> Log.e(<span class="str">"ErrorListener"</span>, e.getLocalizedMessage());</pre><pre> }</pre><pre class="alt"> }</pre><pre> }</pre></div><br /><style type="text/css">.csharpcode, .csharpcode pre<br />{<br /> font-size: small;<br /> color: black;<br /> font-family: consolas, "Courier New", courier, monospace;<br /> background-color: #ffffff;<br /> /*white-space: pre;*/<br />}<br />.csharpcode pre { margin: 0em; }<br />.csharpcode .rem { color: #008000; }<br />.csharpcode .kwrd { color: #0000ff; }<br />.csharpcode .str { color: #006080; }<br />.csharpcode .op { color: #0000c0; }<br />.csharpcode .preproc { color: #cc6633; }<br />.csharpcode .asp { background-color: #ffff00; }<br />.csharpcode .html { color: #800000; }<br />.csharpcode .attr { color: #ff0000; }<br />.csharpcode .alt <br />{<br /> background-color: #f4f4f4;<br /> width: 100%;<br /> margin: 0em;<br />}<br />.csharpcode .lnum { color: #606060; }<br /></style><br /><br /><p> </p><br /><p>and the class error.</p><br /><div class="csharpcode"><pre class="alt"><span class="kwrd">class</span> MyErrorListener implements ErrorListener {</pre><pre> </pre><pre class="alt"> @Override</pre><pre> <span class="kwrd">public</span> <span class="kwrd">void</span> onErrorResponse(VolleyError error) {</pre><pre class="alt"> Log.e(<span class="str">"ErrorListener"</span>, error.getCause() + <span class="str">""</span>);</pre><pre> <span class="kwrd">if</span> (error.getCause() != <span class="kwrd">null</span>) {</pre><pre class="alt"> Log.e(<span class="str">"ErrorListener"</span>, error.getLocalizedMessage());</pre><pre> }</pre><pre class="alt"> MainActivity.<span class="kwrd">this</span>.resultTxt.setText(error.toString());</pre><pre> volleyRequestQueue.cancelAll(<span class="kwrd">this</span>);</pre><pre class="alt"> }</pre><pre> }</pre></div><br /><style type="text/css">.csharpcode, .csharpcode pre<br />{<br /> font-size: small;<br /> color: black;<br /> font-family: consolas, "Courier New", courier, monospace;<br /> background-color: #ffffff;<br /> /*white-space: pre;*/<br />}<br />.csharpcode pre { margin: 0em; }<br />.csharpcode .rem { color: #008000; }<br />.csharpcode .kwrd { color: #0000ff; }<br />.csharpcode .str { color: #006080; }<br />.csharpcode .op { color: #0000c0; }<br />.csharpcode .preproc { color: #cc6633; }<br />.csharpcode .asp { background-color: #ffff00; }<br />.csharpcode .html { color: #800000; }<br />.csharpcode .attr { color: #ff0000; }<br />.csharpcode .alt <br />{<br /> background-color: #f4f4f4;<br /> width: 100%;<br /> margin: 0em;<br />}<br />.csharpcode .lnum { color: #606060; }<br /></style><br /><br /><br /><p>I didn’t have tested thoroughly the Volley framework yet and as I’m progressing will posting more examples, I hope that this small example will help you when using HTTP requests and response. As Volley is a very powerful tool where you can create multi-thread requests and responses and also it’s deal with all try/catch’s and many other features that make HTTP easier to use, and it’s also compatible from Android 2.2 (API 8) to the latest.</p><br /><p><a href="http://www.youtube.com/watch?v=yhv8l9F44qo" target="_blank">Here</a> the link on You Tube to watch the speech at Google I/O 2013 from the Volley with Ficus Kirkpatrick.</p><br /><p>If you have any doubt or something do add please feel free to send me a email or post a comment.</p> Anonymoushttp://www.blogger.com/profile/00908564854719054075noreply@blogger.com0tag:blogger.com,1999:blog-4729831854233341997.post-55058717467771485742012-12-21T04:28:00.001-08:002013-05-18T01:47:08.016-07:00Be On Time – How’s To’s<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
Be On Time is a alarm that contain a different set of features then most regular alarm apps and in fact it’s a clock web radio. The minimum Android version accepted is ICS 4.0 and it’s made to be used with the latest 4.2. I also tested it in my Nexus 7 and it should work well on all tablets that have Wi-Fi and microphone than run from ICS 4.0 above.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgt23vpwKpm8OR-irkyop9A0ZweymhLoBZMVySiOgGQAYPOcQePjeY4TuaeHm4PWcwWyMvn7nbKb4zq2zneMId8yNCYI5Y1ViFqdJEq_0baTSsNMS_L1pClxPgSzAz0RhCFws5r1AU1dE4/s1600/Screenshot_2013-05-18-18-16-57.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgt23vpwKpm8OR-irkyop9A0ZweymhLoBZMVySiOgGQAYPOcQePjeY4TuaeHm4PWcwWyMvn7nbKb4zq2zneMId8yNCYI5Y1ViFqdJEq_0baTSsNMS_L1pClxPgSzAz0RhCFws5r1AU1dE4/s320/Screenshot_2013-05-18-18-16-57.png" width="192" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
This is the first screen that you will see, on the top left corner you can see the radio icon and a toggle button for on and off the radio. If you don’t have any radio the toggle button will be disabled. Touch on the radio icon and you will get to the radio selector spinner.<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiAcv3vCDM84t_5-CPOB5ddxagLs3lcYyew5UpasuxOfTAXJRrgMEzkvaOkLag3_RKkOYx6dYjtuOJL-EYStgJAmfjfAdEAyBI5vuLDcbY7Hpi53E0SBt__tG7Gvbp8fov7h0EechoI_SI/s1600/Screenshot_2013-05-18-18-17-15.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiAcv3vCDM84t_5-CPOB5ddxagLs3lcYyew5UpasuxOfTAXJRrgMEzkvaOkLag3_RKkOYx6dYjtuOJL-EYStgJAmfjfAdEAyBI5vuLDcbY7Hpi53E0SBt__tG7Gvbp8fov7h0EechoI_SI/s320/Screenshot_2013-05-18-18-17-15.png" width="192" /></a></div>
<br />
<br />
After you select you radio, touch the Select button that is at the right side of the spinner selector with this the popup will close and return to clock, after that if you wish turn on the radio it’s just hit the toggle button (Off/On), that the app will load the buffer and start play it as soon the buffer is full. <br />
Touching on the clock numbers will bring a different pop up, this one is for you select the transparency background color, the font type and color also.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhF-2-b22vsfgNOYLeOmhhqI8pmA8DoN4fjYAFYCDYUyipT1JpLyQTGTLuAG9Knv6NLZuzVQ3oYyKi6U1JI5mqnMvqpMB8R17cnf3YyVtC3Ejtm0Iqmp9e9UbrYts9ALT3uzhkqhvzt3ro/s1600/Screenshot_2013-05-18-18-17-04.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhF-2-b22vsfgNOYLeOmhhqI8pmA8DoN4fjYAFYCDYUyipT1JpLyQTGTLuAG9Knv6NLZuzVQ3oYyKi6U1JI5mqnMvqpMB8R17cnf3YyVtC3Ejtm0Iqmp9e9UbrYts9ALT3uzhkqhvzt3ro/s320/Screenshot_2013-05-18-18-17-04.png" width="192" /></a></div>
<br />
<br />
To select it you need touch the Select button. <br />
For you go to create/update or delete alarms, just touch the clock icon, the if you have any alarm on you will have the icon in blue.<br />
<br />
Once you hit the clock icon this next screen will load up, the main screen.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgt23vpwKpm8OR-irkyop9A0ZweymhLoBZMVySiOgGQAYPOcQePjeY4TuaeHm4PWcwWyMvn7nbKb4zq2zneMId8yNCYI5Y1ViFqdJEq_0baTSsNMS_L1pClxPgSzAz0RhCFws5r1AU1dE4/s1600/Screenshot_2013-05-18-18-16-57.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgt23vpwKpm8OR-irkyop9A0ZweymhLoBZMVySiOgGQAYPOcQePjeY4TuaeHm4PWcwWyMvn7nbKb4zq2zneMId8yNCYI5Y1ViFqdJEq_0baTSsNMS_L1pClxPgSzAz0RhCFws5r1AU1dE4/s320/Screenshot_2013-05-18-18-16-57.png" width="192" /></a></div>
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzuUH0jXdUpZtliORp9gtCcMAOdh1G-IsZJd_gY-D3JG-wHS1sbdEWpHzfb9yBv1liqNRW38NoeDM3pVvTI2jFIduFWvWTSbUf6rsnlXl8ihkcijhqv7SWb-rOZNJmTMRWSaJPq833N-8/s1600/Screenshot_2013-05-18-18-17-35.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzuUH0jXdUpZtliORp9gtCcMAOdh1G-IsZJd_gY-D3JG-wHS1sbdEWpHzfb9yBv1liqNRW38NoeDM3pVvTI2jFIduFWvWTSbUf6rsnlXl8ihkcijhqv7SWb-rOZNJmTMRWSaJPq833N-8/s320/Screenshot_2013-05-18-18-17-35.png" width="192" /></a></div>
<br />
<br />
<br />
To create a new alarm just touch on the plus blue icon on the top left corner from the screen.<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgMzNqzxefNPEkkwOYOfo6VI1FkKlWWTjQQUhEEiMp0P45B6-Tzr0bApYlCuApkCeKU15FeDSHXLrJ_1eAZRfFuefI-kmxa9qwRReOnQvBLbZgFf6FJeWsF3IrtnNFdI9SOFvJO7xsfwBY/s1600/Screenshot_2013-05-18-18-19-40.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgMzNqzxefNPEkkwOYOfo6VI1FkKlWWTjQQUhEEiMp0P45B6-Tzr0bApYlCuApkCeKU15FeDSHXLrJ_1eAZRfFuefI-kmxa9qwRReOnQvBLbZgFf6FJeWsF3IrtnNFdI9SOFvJO7xsfwBY/s320/Screenshot_2013-05-18-18-19-40.png" width="192" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbeJ8SxnPdPH5UGwVHhHekbZnWT8bg-8A6azvcgaY0MMzhrKw6DeWxon4XVhp_rsHiHm6LsMsfS-Pu_9PLx6EFwoZ9ZPv4SBQ2LVWrI4Xt7Yoqqe3UGqk06RLbJD4hRkg-ixskdBOx5qY/s1600/Screenshot_2013-05-18-18-19-47.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbeJ8SxnPdPH5UGwVHhHekbZnWT8bg-8A6azvcgaY0MMzhrKw6DeWxon4XVhp_rsHiHm6LsMsfS-Pu_9PLx6EFwoZ9ZPv4SBQ2LVWrI4Xt7Yoqqe3UGqk06RLbJD4hRkg-ixskdBOx5qY/s320/Screenshot_2013-05-18-18-19-47.png" width="192" /></a></div>
<br />
To set the hour and minutes, just touch over the time displayed under the alarm name entry, you can slide up and down or tap and entry the desired time in each field..<br />
<br />
Here you can create the alarm with all settings that you want. The rules for create an alarm are quite few though there is a few:<br />
You can’t set an alarm with less than 2 minutes from the actual time and to the same day using date, if you try it the app can if you are using week days, set the alarm to the exactly same time though to the next selected day, if using by date the alarm will not be created and for last if you don’t set a date or week days then the alarm will be setted to the next day at the same hour.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNlchsohDNtVrUVpTlfSFQ5XU6yM3IiZmCsagAi_eiV2udGvx9FxqY7-9csvkb74K1QnUPDx0KVyI1qLBHARy1t9pY7u2gDVM670s_Mh8ENOKgNWAzAGCp-8ojurPYnj38uSalfmJIdso/s1600/Screenshot_2013-05-18-18-20-02.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNlchsohDNtVrUVpTlfSFQ5XU6yM3IiZmCsagAi_eiV2udGvx9FxqY7-9csvkb74K1QnUPDx0KVyI1qLBHARy1t9pY7u2gDVM670s_Mh8ENOKgNWAzAGCp-8ojurPYnj38uSalfmJIdso/s320/Screenshot_2013-05-18-18-20-02.png" width="192" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj2uoWUnnwfqOYPvsuRyh4PKIBFOkVKYVJggGz0RoGHOO2H3DDHRtw7Q_4vVwZ03s03RLLsL-lFHrlXV8Z_7cwNF7vN84FViJYnW9FNeOed1KzfPPtmW-5Vtqh0PoD9PpiZdPgIMSa-J5w/s1600/Screenshot_2013-05-18-18-20-05.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj2uoWUnnwfqOYPvsuRyh4PKIBFOkVKYVJggGz0RoGHOO2H3DDHRtw7Q_4vVwZ03s03RLLsL-lFHrlXV8Z_7cwNF7vN84FViJYnW9FNeOed1KzfPPtmW-5Vtqh0PoD9PpiZdPgIMSa-J5w/s320/Screenshot_2013-05-18-18-20-05.png" width="192" /></a></div>
<br />
<br />
Screen for select week days (above), the rule to roll each column up or down and tapping to entry the value desired is also valid for Date,<br />
<br />
Screen for select date (above),<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJhhmt541clUUjH4hf70C9Y8fapo-XRrpO9zBXzdfcQn-U5ttMDGcXJmeTu2W0js_uCclDaKnSythguUtL2V2jO21Ul7lclhiJOFQCSg5MvivVDzlFhKCzyFh9XH9WKFQQIJsevRja8Hs/s1600/Screenshot_2013-05-18-18-20-20.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJhhmt541clUUjH4hf70C9Y8fapo-XRrpO9zBXzdfcQn-U5ttMDGcXJmeTu2W0js_uCclDaKnSythguUtL2V2jO21Ul7lclhiJOFQCSg5MvivVDzlFhKCzyFh9XH9WKFQQIJsevRja8Hs/s320/Screenshot_2013-05-18-18-20-20.png" width="192" /></a></div>
<br />
<br />
<br />
Volume options (above),<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-mRavA8OeZHXrQLAWkKYaGl-RSRQXazJWaMQqaivHxJE48Sy91Qr3d5ZUlHjQ6-ySzI5Re76YzoO5KHxRSlNiOiIwYfwm81ZPrYeKO-cZTNMdB23EZk5kp6jxCUY__PBFKNpdoGSBcwo/s1600/Screenshot_2013-05-18-18-20-25.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-mRavA8OeZHXrQLAWkKYaGl-RSRQXazJWaMQqaivHxJE48Sy91Qr3d5ZUlHjQ6-ySzI5Re76YzoO5KHxRSlNiOiIwYfwm81ZPrYeKO-cZTNMdB23EZk5kp6jxCUY__PBFKNpdoGSBcwo/s320/Screenshot_2013-05-18-18-20-25.png" width="192" /></a></div>
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhA-8e5Flvmunq8arCyKJTycyYsNOX9on4BPT0ss-j-_7u0z1lJnSHDeYYtclAe96yVqvDivMReR8hMLL4TXBessUU4FnchHdLFq763h6zLlDhaZJqFvznj9Zu5Kz34Yxu_Ur_7vqc6T5g/s1600/Screenshot_2013-05-18-18-20-32.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhA-8e5Flvmunq8arCyKJTycyYsNOX9on4BPT0ss-j-_7u0z1lJnSHDeYYtclAe96yVqvDivMReR8hMLL4TXBessUU4FnchHdLFq763h6zLlDhaZJqFvznj9Zu5Kz34Yxu_Ur_7vqc6T5g/s320/Screenshot_2013-05-18-18-20-32.png" width="192" /></a></div>
<br />
<br />
Snooze options (above), the snooze interval numbers means minutes.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgH8yUQJp702kJ5wsV4WkkSvcP9yRToKFHW0Y21LMv2Mxwyp8i4g2rJKoQLHRCbC4_oOyellgKsHQ6wtl-dLnJWoX8ArgJxz9iUrp7Srsuo4eLGpMQJg7Qg-9ioOzlH3Fy_6UPc5iz3uCI/s1600/Screenshot_2013-05-18-18-20-40.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgH8yUQJp702kJ5wsV4WkkSvcP9yRToKFHW0Y21LMv2Mxwyp8i4g2rJKoQLHRCbC4_oOyellgKsHQ6wtl-dLnJWoX8ArgJxz9iUrp7Srsuo4eLGpMQJg7Qg-9ioOzlH3Fy_6UPc5iz3uCI/s320/Screenshot_2013-05-18-18-20-40.png" width="192" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg7m709IgC2xl42zADPw51e0PHwEJWgJ7CieWhtZWRrs_hH08tN4dJTeGNEMbJqFl7VhXXVksWjj1RyCO9gckK-_l6RmP7l_a3BeNI39oE0Ha5MrAFKJPODmxQiNvTospVqIxdpBesCuKo/s1600/Screenshot_2013-05-18-18-20-43.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg7m709IgC2xl42zADPw51e0PHwEJWgJ7CieWhtZWRrs_hH08tN4dJTeGNEMbJqFl7VhXXVksWjj1RyCO9gckK-_l6RmP7l_a3BeNI39oE0Ha5MrAFKJPODmxQiNvTospVqIxdpBesCuKo/s320/Screenshot_2013-05-18-18-20-43.png" width="192" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuUA6cB5Tqd88gio-B7UtdUlUETnUmed9yq56NBb_VSwQsWobDT5yd3DK9Qp-CJb_gl4nVEV0gz6H60-gRPgrJL2GE8yrfjSHnj05ic0YlnDeBhWQ7TRIBVhBiOk0JevJwC4k0qfF2udc/s1600/Screenshot_2013-05-18-18-20-47.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuUA6cB5Tqd88gio-B7UtdUlUETnUmed9yq56NBb_VSwQsWobDT5yd3DK9Qp-CJb_gl4nVEV0gz6H60-gRPgrJL2GE8yrfjSHnj05ic0YlnDeBhWQ7TRIBVhBiOk0JevJwC4k0qfF2udc/s320/Screenshot_2013-05-18-18-20-47.png" width="192" /></a></div>
<br />
<br />
<br />
<br />
Select sound screens (above), the selected sound option will be in blue<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgG-VngMXGG1JHPGlQWEgR0cH4OnQhhzX7WcJGP-4-9384gC1AYNW7_Xn0hQc17BqO62vaH3pfwo7irg6UPYSsKNVW_yxTFky3XK-SRJe9ml6WjSbq8R-KSIhbwJLBqEQXlhwZo_D5szaY/s1600/Screenshot_2013-05-18-18-18-10.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgG-VngMXGG1JHPGlQWEgR0cH4OnQhhzX7WcJGP-4-9384gC1AYNW7_Xn0hQc17BqO62vaH3pfwo7irg6UPYSsKNVW_yxTFky3XK-SRJe9ml6WjSbq8R-KSIhbwJLBqEQXlhwZo_D5szaY/s320/Screenshot_2013-05-18-18-18-10.png" width="192" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgBWhVMpF0BVVlr2FQoR0oiGdo5BrxZLwzpsbWh9HLOKmDrskbYFMKL4Nq-zFwUZOMEIrRPwVpw_xzawOJgg-NENjM4CHBr4JyhHGT_WM2hkQQSL2cvHflCZqqcuKNcUP9j1EEcMjvUhJw/s1600/Screenshot_2013-05-18-18-18-42.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgBWhVMpF0BVVlr2FQoR0oiGdo5BrxZLwzpsbWh9HLOKmDrskbYFMKL4Nq-zFwUZOMEIrRPwVpw_xzawOJgg-NENjM4CHBr4JyhHGT_WM2hkQQSL2cvHflCZqqcuKNcUP9j1EEcMjvUhJw/s320/Screenshot_2013-05-18-18-18-42.png" width="192" /></a></div>
<br />
<br />
Add Net Radio option (from main screen menu), if you had copied or know one URL that you want, it’s just type, or copy it into the second entry field and Save it. Clear will just clear both entry fields. <br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNwkQEZBiCzCc6fs8PgVIFhzknaClzQrJfNWF0aEDmjcw2742fPzQ-CS4zEqCqSBsdQr2WA0g3tw38IAyWyNgsuw4L6TEnGdAM7T8wlVechDmmKQHn5x5ZL1g5yxaPbywApTG58drBQ3U/s1600/Screenshot_2013-05-18-18-18-52.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNwkQEZBiCzCc6fs8PgVIFhzknaClzQrJfNWF0aEDmjcw2742fPzQ-CS4zEqCqSBsdQr2WA0g3tw38IAyWyNgsuw4L6TEnGdAM7T8wlVechDmmKQHn5x5ZL1g5yxaPbywApTG58drBQ3U/s320/Screenshot_2013-05-18-18-18-52.png" width="192" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEm69LP8tgDOVw8IFAh0cP6iwWwpZ-Mcqh0raiZjIKdZkeHdxnzcp0lage0s_o2NiXsv143ohPNDJdiT8iJUE90OWOtV3cNVdx38qs8BBXYE2nvEpqXn_N58bQsnnB4z5d7aiO4ig2dkk/s1600/Screenshot_2013-05-18-18-18-56.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEm69LP8tgDOVw8IFAh0cP6iwWwpZ-Mcqh0raiZjIKdZkeHdxnzcp0lage0s_o2NiXsv143ohPNDJdiT8iJUE90OWOtV3cNVdx38qs8BBXYE2nvEpqXn_N58bQsnnB4z5d7aiO4ig2dkk/s320/Screenshot_2013-05-18-18-18-56.png" width="192" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh76HGb8pMbhvcHmxm3kmZLP7ol3pcggFvQShRk9JroLQSyZ3-4R6X7gKxbU7Ub0fBdG4ViRTRAMFQE0x5zf2GYKjR8cReT4ewRs2BOPwhG1ExvWHMY4H5__KfYvrGcgkrJv11thBEoypE/s1600/Screenshot_2013-05-18-18-19-16.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh76HGb8pMbhvcHmxm3kmZLP7ol3pcggFvQShRk9JroLQSyZ3-4R6X7gKxbU7Ub0fBdG4ViRTRAMFQE0x5zf2GYKjR8cReT4ewRs2BOPwhG1ExvWHMY4H5__KfYvrGcgkrJv11thBEoypE/s320/Screenshot_2013-05-18-18-19-16.png" width="192" /></a></div>
<br />
<br />
<br />
The web part for you import all links that you want, please be aware that many links are broken or missing, also you can hit menu and insert an URL desired, if the URL doesn’t contain HTTPS you can only type part of it e.g. : from <a href="http://www.blabla.com/">www.blabla.com</a> just type blabla.com that the browser will load it for you if the url is correct. To quit the browser you just need to hit back a few times or open the menu and touch on Exit browser.<br />
Once you had touched a net radio link, and if it’s compatible (Windows Media format is not) the app will import it to you and you will get a message telling you that (below).<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnYPQhqwcRRrARFCmkFnMrFlMsEJWds2WaZQEbCBplGo4baVuMXLjWm83GcumGOR7wxC4ev6GlzJl-G6lqthyphenhyphen-D0r0T0MaB8Qu58bckAbpybzPH_ChnvFX4OCJAa05kSZpu5JmIgfuY58/s1600/Screenshot_2013-05-18-18-17-48.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnYPQhqwcRRrARFCmkFnMrFlMsEJWds2WaZQEbCBplGo4baVuMXLjWm83GcumGOR7wxC4ev6GlzJl-G6lqthyphenhyphen-D0r0T0MaB8Qu58bckAbpybzPH_ChnvFX4OCJAa05kSZpu5JmIgfuY58/s320/Screenshot_2013-05-18-18-17-48.png" width="192" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhR_sH4Gwze_VlD28au_KMQAMW_Sd73RhjiVh9dIwzJUX_eGphdxXIACMo7HYZCZDhzafZYNfx9v6IPUPR7AOl-vky19UATFOnaS2ruKRK7gFAcEtyGjWbfkcJ77bU4kDHvdsxS80FmGRA/s1600/Screenshot_2013-05-18-18-17-57.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhR_sH4Gwze_VlD28au_KMQAMW_Sd73RhjiVh9dIwzJUX_eGphdxXIACMo7HYZCZDhzafZYNfx9v6IPUPR7AOl-vky19UATFOnaS2ruKRK7gFAcEtyGjWbfkcJ77bU4kDHvdsxS80FmGRA/s320/Screenshot_2013-05-18-18-17-57.png" width="192" /></a></div>
<br />
The settings screens is pretty simple, the last item is the one that will make the alarm keep playing for the desired time selected.<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhH7uU0rFY0Qi-BFmAg5YcWIlzRT1LirhjIwmAw9xK-h8gFHNgWjGI3UWhAym0FYrB1FJ7o9aAAArLSnZHaNcHvz_mdJedD69tA_ywQmpLdSwY7OLt_TrASclAxql_puBbJuns4eXt04kQ/s1600/Screenshot_2013-05-18-18-44-16.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhH7uU0rFY0Qi-BFmAg5YcWIlzRT1LirhjIwmAw9xK-h8gFHNgWjGI3UWhAym0FYrB1FJ7o9aAAArLSnZHaNcHvz_mdJedD69tA_ywQmpLdSwY7OLt_TrASclAxql_puBbJuns4eXt04kQ/s320/Screenshot_2013-05-18-18-44-16.png" width="192" /></a></div>
<br />
<br />
Widget, will always tell you the next alarm, the blue plus button takes you straight to create a new alarm and the second to the main screen where you can edit, create or delete any alarm that you already have.<br />
<br />
To stop the alarm you must tap twice in less than 1 second.<br />
<br />
When importing radios be aware that not all links would be working, and also that not always that not working link will not be working, it's a matter of try it sometimes.<br />
<br />
So that’s all, if you have any doubt that it’s not in this post, please feel free to send me an email to <a href="mailto:kvandroidapp@gmail.com">kvandroidapp@gmail.com</a> that I’ll reply as soon as I can, and please rate the app if you like.</div>
Anonymoushttp://www.blogger.com/profile/00908564854719054075noreply@blogger.com0tag:blogger.com,1999:blog-4729831854233341997.post-10537939064405573922012-11-17T01:00:00.001-08:002013-05-21T19:47:10.470-07:00Example for Encrypt and Decrypt using AES with Android 4.2<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
I'll put in here the test that I did:<br />As after test the code on my Nexus it's worked encrypting and decrypting (before just encrypt was working), I got a String from an other phone, from SQLite, copied and sent it via email client (GMAIL) to my Nexus, then I have copied it and replace with the one that had been created on 4.2 (the copied one, was from 4.0.4 SII 3G), then started the app again and debugging I could see the correct string returning from this method:<br />
<pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"><span style="color: blue;">public</span> <span style="color: blue;">static</span> String decrypt(String seed, String encrypted) <span style="color: blue;">throws</span> Exception {</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> <span style="color: blue;">byte</span>[] seedByte = seed.getBytes();</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> System.arraycopy(seedByte, 0, key, 0, ((seedByte.length < 16) ? seedByte.length : 16));</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> String base64 = <span style="color: blue;">new</span> String(Base64.decode(encrypted, 0));</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> <span style="color: blue;">byte</span>[] rawKey = getRawKey(seedByte);</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> <span style="color: blue;">byte</span>[] enc = toByte(base64);</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> <span style="color: blue;">byte</span>[] result = decrypt(rawKey, enc);</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> <span style="color: blue;">return</span> <span style="color: blue;">new</span> String(result);</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> }</pre>
</pre>
<br />
<br />I've made an example to show how it's works.<br />
<br />
Activity_main.xml (layout):<br />
<pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"><span style="color: blue;"><</span><span style="color: maroon;">RelativeLayout</span> <span style="color: red;">xmlns</span>:<span style="color: red;">android</span>=<span style="color: blue;">"http://schemas.android.com/apk/res/android"</span></pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> <span style="color: red;">xmlns</span>:<span style="color: red;">tools</span>=<span style="color: blue;">"http://schemas.android.com/tools"</span></pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> <span style="color: red;">android</span>:<span style="color: red;">layout_width</span>=<span style="color: blue;">"match_parent"</span></pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> <span style="color: red;">android</span>:<span style="color: red;">layout_height</span>=<span style="color: blue;">"match_parent"</span></pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> <span style="color: red;">tools</span>:<span style="color: red;">context</span>=<span style="color: blue;">".MainActivity"</span> <span style="color: blue;">></span></pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"></pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> <span style="color: blue;"><</span><span style="color: maroon;">TextView</span></pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> <span style="color: red;">android</span>:<span style="color: red;">id</span>=<span style="color: blue;">"@+id/appName"</span></pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> <span style="color: red;">android</span>:<span style="color: red;">layout_width</span>=<span style="color: blue;">"wrap_content"</span></pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> <span style="color: red;">android</span>:<span style="color: red;">layout_height</span>=<span style="color: blue;">"wrap_content"</span></pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> <span style="color: red;">android</span>:<span style="color: red;">text</span>=<span style="color: blue;">"App name"</span> <span style="color: blue;">/></span></pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"></pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> <span style="color: blue;"><</span><span style="color: maroon;">TextView</span></pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> <span style="color: red;">android</span>:<span style="color: red;">id</span>=<span style="color: blue;">"@+id/seedName"</span></pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> <span style="color: red;">android</span>:<span style="color: red;">layout_width</span>=<span style="color: blue;">"wrap_content"</span></pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> <span style="color: red;">android</span>:<span style="color: red;">layout_height</span>=<span style="color: blue;">"wrap_content"</span></pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> <span style="color: red;">android</span>:<span style="color: red;">layout_below</span>=<span style="color: blue;">"@+id/appName"</span></pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> <span style="color: red;">android</span>:<span style="color: red;">layout_marginTop</span>=<span style="color: blue;">"5dp"</span></pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> <span style="color: red;">android</span>:<span style="color: red;">text</span>=<span style="color: blue;">"This is the seed."</span> <span style="color: blue;">/></span></pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> </pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> <span style="color: blue;"><</span><span style="color: maroon;">TextView</span></pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> <span style="color: red;">android</span>:<span style="color: red;">id</span>=<span style="color: blue;">"@+id/textToEncrypt"</span></pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> <span style="color: red;">android</span>:<span style="color: red;">layout_width</span>=<span style="color: blue;">"wrap_content"</span></pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> <span style="color: red;">android</span>:<span style="color: red;">layout_height</span>=<span style="color: blue;">"wrap_content"</span></pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> <span style="color: red;">android</span>:<span style="color: red;">layout_below</span>=<span style="color: blue;">"@+id/seedName"</span></pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> <span style="color: red;">android</span>:<span style="color: red;">layout_marginTop</span>=<span style="color: blue;">"5dp"</span></pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> <span style="color: red;">android</span>:<span style="color: red;">text</span>=<span style="color: blue;">"This is the text to encrypt"</span> <span style="color: blue;">/></span></pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"></pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> <span style="color: blue;"><</span><span style="color: maroon;">TextView</span></pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> <span style="color: red;">android</span>:<span style="color: red;">id</span>=<span style="color: blue;">"@+id/encryptedText"</span></pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> <span style="color: red;">android</span>:<span style="color: red;">layout_width</span>=<span style="color: blue;">"wrap_content"</span></pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> <span style="color: red;">android</span>:<span style="color: red;">layout_height</span>=<span style="color: blue;">"wrap_content"</span></pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> <span style="color: red;">android</span>:<span style="color: red;">layout_below</span>=<span style="color: blue;">"@+id/textToEncrypt"</span></pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> <span style="color: red;">android</span>:<span style="color: red;">layout_marginTop</span>=<span style="color: blue;">"5dp"</span></pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> <span style="color: red;">android</span>:<span style="color: red;">text</span>=<span style="color: blue;">"Encrypted text"</span> <span style="color: blue;">/></span></pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"></pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> <span style="color: blue;"><</span><span style="color: maroon;">TextView</span></pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> <span style="color: red;">android</span>:<span style="color: red;">id</span>=<span style="color: blue;">"@+id/decryptedText"</span></pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> <span style="color: red;">android</span>:<span style="color: red;">layout_width</span>=<span style="color: blue;">"wrap_content"</span></pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> <span style="color: red;">android</span>:<span style="color: red;">layout_height</span>=<span style="color: blue;">"wrap_content"</span></pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> <span style="color: red;">android</span>:<span style="color: red;">layout_below</span>=<span style="color: blue;">"@+id/encryptedText"</span></pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> <span style="color: red;">android</span>:<span style="color: red;">layout_marginTop</span>=<span style="color: blue;">"5dp"</span></pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> <span style="color: red;">android</span>:<span style="color: red;">text</span>=<span style="color: blue;">"Decrypted text"</span> <span style="color: blue;">/></span></pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"></pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> <span style="color: blue;"></</span><span style="color: maroon;">RelativeLayout</span><span style="color: blue;">></span></pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"></pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"></pre>
</pre>
<br />
<br />MainActivity.java :<br />
<pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 1: package com.example.encryptdecrittest;</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 2: </pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 3: import android.app.Activity;</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 4: import android.os.Bundle;</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 5: import android.util.Log;</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 6: import android.view.Menu;</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 7: import android.widget.TextView;</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 8: </pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 9: public class MainActivity extends Activity {</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 10: </pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 11: private String seedWith16Chars = "This is my seed.";</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 12: private String textToEncrypt = "Hi, this is a test to check its gone work or not.";</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 13: </pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 14: private TextView seed;</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 15: private TextView text;</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 16: private TextView encryptedValue;</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 17: private TextView decryptedValue;</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 18: </pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 19: </pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 20: @Override</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 21: protected void onCreate(Bundle savedInstanceState) {</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 22: super.onCreate(savedInstanceState);</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 23: setContentView(R.layout.activity_main);</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 24: </pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 25: seed = (TextView) findViewById(R.id.seedName);</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 26: seed.setText(seedWith16Chars);</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 27: </pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 28: text = (TextView) findViewById(R.id.textToEncrypt);</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 29: text.setText(textToEncrypt);</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 30: </pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 31: encryptedValue = (TextView) findViewById(R.id.encryptedText);</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 32: decryptedValue = (TextView) findViewById(R.id.decryptedText);</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 33: </pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 34: try {</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 35: // This value was got when did run it from an 2.3.3 device a Galaxy SII running Android 4.0.4</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 36: String encrypted = "MzA3RDBCMjMxMjQzNzcxREUxMUYxNjg1NzgwOTU1MjU1M0FDOUZEN0M3Q0JGQ0Q5MTI2NEIyNTE2"</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 37: + "OTQwQTc3NjM2QTBCRDFDMUEyNkUwRjlDMzQwN0U0MEI0NDg2M0JBMDU1OThCNTI1NTZCMEFGNjk1NjJFNzZBMUE0NzM4NTQ=";</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 38: </pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 39: // Uncomment the line bellow and comment the line above to run it on an Android 4.1.2 or older.</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 40: // String encrypted = EncodeDecodeAES.encrypt(seedWith16Chars, textToEncrypt);</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 41: Log.e("Encrypt", encrypted);</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 42: encryptedValue.setText(encrypted);</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 43: </pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 44: String decrypted = EncodeDecodeAES.decrypt(seedWith16Chars, encrypted);</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 45: decryptedValue.setText(decrypted);</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 46: Log.e("Decrypt", decrypted);</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 47: } catch (Exception e) {</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 48: Log.e("Exception", e.getLocalizedMessage());</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 49: }</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 50: </pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 51: }</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 52: </pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 53: </pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 54: @Override</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 55: public boolean onCreateOptionsMenu(Menu menu) {</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 56: // Inflate the menu; this adds items to the action bar if it is present.</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 57: getMenuInflater().inflate(R.menu.activity_main, menu);</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 58: return true;</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 59: }</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 60: </pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 61: }</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 62: </pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 63: </pre>
</pre>
<br />
<br />
<br />
EncodeDecodeAES.java :<br />
<pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 1: package com.example.encryptdecrittest;</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 2: </pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 3: import java.security.SecureRandom;</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 4: </pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 5: import javax.crypto.Cipher;</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 6: import javax.crypto.KeyGenerator;</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 7: import javax.crypto.SecretKey;</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 8: import javax.crypto.spec.SecretKeySpec;</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 9: </pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 10: import android.util.Base64;</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 11: </pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 12: public class EncodeDecodeAES {</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 13: </pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 14: private final static String HEX = "0123456789ABCDEF";</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 15: private final static int JELLY_BEAN_4_2 = 17;</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 16: private final static byte[] key = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 17: </pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 18: </pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 19: // static {</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 20: // Security.addProvider(new BouncyCastleProvider());</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 21: // }</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 22: </pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 23: public static String encrypt(String seed, String cleartext) throws Exception {</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 24: byte[] rawKey = getRawKey(seed.getBytes());</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 25: byte[] result = encrypt(rawKey, cleartext.getBytes());</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 26: String fromHex = toHex(result);</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 27: String base64 = new String(Base64.encodeToString(fromHex.getBytes(), 0));</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 28: return base64;</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 29: }</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 30: </pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 31: </pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 32: public static String decrypt(String seed, String encrypted) throws Exception {</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 33: byte[] seedByte = seed.getBytes();</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 34: System.arraycopy(seedByte, 0, key, 0, ((seedByte.length <span style="color: blue;"><</span> 16) ? seedByte.length : 16));</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 35: String base64 = new String(Base64.decode(encrypted, 0));</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 36: byte[] rawKey = getRawKey(seedByte);</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 37: byte[] enc = toByte(base64);</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 38: byte[] result = decrypt(rawKey, enc);</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 39: return new String(result);</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 40: }</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 41: </pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 42: </pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 43: public static byte[] encryptBytes(String seed, byte[] cleartext) throws Exception {</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 44: byte[] rawKey = getRawKey(seed.getBytes());</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 45: byte[] result = encrypt(rawKey, cleartext);</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 46: return result;</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 47: }</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 48: </pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 49: </pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 50: public static byte[] decryptBytes(String seed, byte[] encrypted) throws Exception {</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 51: byte[] rawKey = getRawKey(seed.getBytes());</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 52: byte[] result = decrypt(rawKey, encrypted);</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 53: return result;</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 54: }</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 55: </pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 56: </pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 57: private static byte[] getRawKey(byte[] seed) throws Exception {</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 58: KeyGenerator kgen = KeyGenerator.getInstance("AES"); // , "SC");</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 59: SecureRandom sr = null;</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 60: if (android.os.Build.VERSION.SDK_INT <span style="color: blue;">></span>= JELLY_BEAN_4_2) {</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 61: sr = SecureRandom.getInstance("SHA1PRNG", "Crypto");</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 62: } else {</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 63: sr = SecureRandom.getInstance("SHA1PRNG");</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 64: }</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 65: sr.setSeed(seed);</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 66: try {</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 67: kgen.init(256, sr);</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 68: // kgen.init(128, sr);</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 69: } catch (Exception e) {</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 70: // Log.w(LOG, "This device doesn't suppor 256bits, trying 192bits.");</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 71: try {</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 72: kgen.init(192, sr);</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 73: } catch (Exception e1) {</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 74: // Log.w(LOG, "This device doesn't suppor 192bits, trying 128bits.");</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 75: kgen.init(128, sr);</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 76: }</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 77: }</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 78: SecretKey skey = kgen.generateKey();</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 79: byte[] raw = skey.getEncoded();</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 80: return raw;</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 81: }</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 82: </pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 83: </pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 84: private static byte[] encrypt(byte[] raw, byte[] clear) throws Exception {</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 85: SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 86: Cipher cipher = Cipher.getInstance("AES"); // /ECB/PKCS7Padding", "SC");</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 87: cipher.init(Cipher.ENCRYPT_MODE, skeySpec);</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 88: byte[] encrypted = cipher.doFinal(clear);</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 89: return encrypted;</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 90: }</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 91: </pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 92: </pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 93: private static byte[] decrypt(byte[] raw, byte[] encrypted) throws Exception {</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 94: SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 95: Cipher cipher = Cipher.getInstance("AES"); // /ECB/PKCS7Padding", "SC");</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 96: cipher.init(Cipher.DECRYPT_MODE, skeySpec);</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 97: byte[] decrypted = cipher.doFinal(encrypted);</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 98: return decrypted;</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"> 99: }</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">100: </pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">101: </pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">102: public static String toHex(String txt) {</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">103: return toHex(txt.getBytes());</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">104: }</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">105: </pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">106: </pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">107: public static String fromHex(String hex) {</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">108: return new String(toByte(hex));</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">109: }</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">110: </pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">111: </pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">112: public static byte[] toByte(String hexString) {</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">113: int len = hexString.length() / 2;</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">114: byte[] result = new byte[len];</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">115: for (int i = 0; i <span style="color: blue;"><</span> len; i++)</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">116: result[i] = Integer.valueOf(hexString.substring(2 * i, 2 * i + 2), 16).byteValue();</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">117: return result;</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">118: }</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">119: </pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">120: </pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">121: public static String toHex(byte[] buf) {</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">122: if (buf == null)</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">123: return "";</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">124: StringBuffer result = new StringBuffer(2 * buf.length);</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">125: for (int i = 0; i <span style="color: blue;"><</span> buf.length; i++) {</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">126: appendHex(result, buf[i]);</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">127: }</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">128: return result.toString();</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">129: }</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">130: </pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">131: </pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">132: private static void appendHex(StringBuffer sb, byte b) {</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">133: sb.append(HEX.charAt((b <span style="color: blue;">></span>> 4) & 0x0f)).append(HEX.charAt(b & 0x0f));</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">134: }</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">135: </pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">136: }</pre>
<pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">137: </pre>
</pre>
<br />
<br />Then I did run it from a SII with that line that have a ciphered text commented,<br />
<br />
String encrypted = "MzA3RDBCMjMxMjQzNzcxREUxMUYxNjg1NzgwOTU1MjU1M0FDOUZEN0M3Q0JGQ0Q5MTI2NEIyNTE2"<br /> + "OTQwQTc3NjM2QTBCRDFDMUEyNkUwRjlDMzQwN0U0MEI0NDg2M0JBMDU1OThCNTI1NTZCMEFGNjk1NjJFNzZBMUE0NzM4NTQ=";<br />
<br />
and the one that have <br />
<br />
String encrypted = EncodeDecodeAES.encrypt(seedWith16Chars, textToEncrypt);<br />
<br />
Uncomented. Then the LogCat show me the encrypted value, remember that we are still running it from an Anroid 4.0.4 (SII). After that I've copied the text encrypted to be received by **encrypted** String, and unplugged the SII plugged my Nexus with 4.2 and ran the code and worked. <br />Maybe if you are using a seed (or password) with less than 16 digits it's gone fail. If it's the case try complete it from the text length (that is less then 16th position), with something like spaces or zeros, or even 1 and 0's - 10101..) up to the 16th position.<br />Also you need to pay attention if your previous code is initializing the keyGen with 128 bits and the class published above try first 256 and then if it's fail go downgrading up to 128bits, then you should comment all of them leaving only the one that has 128.<br />
If you want to download the example project please go to <span style="background-color: white; color: #404040; font-family: Roboto, arial, sans-serif; font-size: 13px; line-height: 18px;"> </span><a class="ot-anchor" href="https://github.com/villacak/EncryptDecritTest.git" rel="nofollow" style="-webkit-transition: color 0.218s; background-color: white; color: #404040; cursor: pointer; font-family: Roboto, arial, sans-serif; font-size: 13px; line-height: 18px; text-decoration: none; transition: color 0.218s;">https://github.com/villacak/EncryptDecritTest.git</a><span style="background-color: white; color: #404040; font-family: Roboto, arial, sans-serif; font-size: 13px; line-height: 18px;"> </span><br />I hope that it helps you.</div>
Anonymoushttp://www.blogger.com/profile/00908564854719054075noreply@blogger.com27tag:blogger.com,1999:blog-4729831854233341997.post-87036316470272894402012-03-12T03:55:00.001-07:002012-03-12T03:55:50.550-07:00Wallpaper Rotator<p>With this application you will be able to pick up to 30 pictures from your Gallery and make it rotate as your wallpaper, the minimum time interval it’s from 5 minutes, and the maximum of 7 days. This’s a pretty easy app. to work with and consume quite few battery also. It doesn’t let your CPU awake all the time.</p> <p>On FREE version there is the maximum possibility of just 3 pictures and also just 3 time intervals (15min, 1Hr and 1 Day).</p> <p>The first screen it’s the EULA, that will only be displayed once, and you will only be able to use the application if you agree with it.</p> <p><a href="http://lh4.ggpht.com/-Ulu8WyoU2zU/T13WDHiiRlI/AAAAAAAAAHs/6Z-6ogf9-E4/s1600-h/eula%25255B2%25255D.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="eula" border="0" alt="eula" src="http://lh4.ggpht.com/-ljJsrqtADRs/T13WEWZJ7wI/AAAAAAAAAH0/AgFKgNF3Ero/eula_thumb.png?imgmax=800" width="164" height="244"></a></p> <p>Then you will be taken to a screen where it will display all your pictures (from your Gallery), all of them will have a left up corner for you hit and select it, if you hit the picture one dialog will ask you to to edit. If you choose yes will be taken to the gallery where you can rotate the picture, and perform some other things. Choosing cancel you will stay in the program.</p> <p>After you select all pictures that you want, you should hit the Start button, that will take you to the Service page.</p> <p><a href="http://lh3.ggpht.com/-K9DqGhXbRR8/T13WFoQXjCI/AAAAAAAAAH8/SOLwVA__iMo/s1600-h/select%25255B2%25255D.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="select" border="0" alt="select" src="http://lh6.ggpht.com/-oBOJQ4rWrPM/T13WG4mR2uI/AAAAAAAAAIE/kzCAJN1YnBw/select_thumb.png?imgmax=800" width="164" height="244"></a></p> <p>On the service page, if you have the service running, will see only the Stop Service button enabled. If not you can start hitting the checkbox “Activate Service”, once you have checked that box, all others components from the screen will be enabled, less “Stop service” button if you don’t have any service running.</p> <p><a href="http://lh4.ggpht.com/-3NRLQZW3hYU/T13WH9k7HRI/AAAAAAAAAIM/fVH7OFkYAXE/s1600-h/activateServiceNew%25255B2%25255D.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="activateServiceNew" border="0" alt="activateServiceNew" src="http://lh3.ggpht.com/-lJsQOMrdtXA/T13WI6OStgI/AAAAAAAAAIU/dSad8GAHxWE/activateServiceNew_thumb.png?imgmax=800" width="164" height="244"></a></p> <p>After prepare the service enabling the checkbox, it’s time to select the time interval, that might be from 5 minutes up to 7 days, this will be the interval time that between one update and the next.</p> <p><a href="http://lh3.ggpht.com/-ouPnJ0J9FSg/T13WKKrNrlI/AAAAAAAAAIc/H6rDFPBFy_k/s1600-h/activeServiceEnabled%25255B2%25255D.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="activeServiceEnabled" border="0" alt="activeServiceEnabled" src="http://lh6.ggpht.com/-bE9ww7tH5xo/T13WLJt4pmI/AAAAAAAAAIk/57_p9A_QAcg/activeServiceEnabled_thumb.png?imgmax=800" width="164" height="244"></a></p> <p>After that to in fact start the service, it’s just hit “Start Service”. After hit the button one notification on your notification bar will be displayed letting you know that the service it’s up and running. You can remove it opening the notification bar and clear.</p> <p><a href="http://lh3.ggpht.com/-AdCVLOaUtA8/T13WMEpx4sI/AAAAAAAAAIs/nabUW3QuUTg/s1600-h/notificationRunning%25255B2%25255D.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="notificationRunning" border="0" alt="notificationRunning" src="http://lh5.ggpht.com/-IH5YwUkVBFY/T13WNLuzayI/AAAAAAAAAI0/yiTbn-odLLY/notificationRunning_thumb.png?imgmax=800" width="164" height="244"></a></p> <p>Once you want to stop that service, it’s just open the application (if it’s not opened yet) select at least two images, hit start and then “Stop service” that will update your notification for the status Stopped.</p> <p>The button Deselect All unmark all pictures that you had previously marked, and the Quit finish the application.</p> <p>If you have started a service, you can finish the application, because the service will be running on the background.</p> Anonymoushttp://www.blogger.com/profile/00908564854719054075noreply@blogger.com0tag:blogger.com,1999:blog-4729831854233341997.post-26267453826097327172012-01-14T05:14:00.001-08:002012-01-14T05:14:33.274-08:00Ice Cream Sandwich 4.0.3 RC3–Update from RC2.11<p>Now it looks faster and more responsive than the last RC2.11 version, a few things got better also, one it’s that you have use the Samsung USB driver now and everything will be fine.</p> <p>That means if you have RC3 flashed on your mobile, you need just the Samsung USB driver from my last post, everything works fine just with the Samsung USB driver, though has to be the one that it’s been used for the Nexus version (<a title="http://www.samsung.com/us/support/downloads/SCH-I515MSAVZW" href="http://www.samsung.com/us/support/downloads/SCH-I515MSAVZW">http://www.samsung.com/us/support/downloads/SCH-I515MSAVZW</a>).</p> <p>Thanks</p> Anonymoushttp://www.blogger.com/profile/00908564854719054075noreply@blogger.com0tag:blogger.com,1999:blog-4729831854233341997.post-2192445596801320432012-01-10T03:27:00.001-08:002012-01-10T03:31:03.860-08:00Ice Cream Sandwich 4.0.3 RC2.11 for Samsung Galaxy S - Connecting the device on Windows 7/Vista<p> </p> <p><font size="2">To get ICS for SGS main page (</font><a href="http://code.google.com/p/ice-cream-sandwich-sgs/" target="_blank"><font size="2">http://code.google.com/p/ice-cream-sandwich-sgs/</font></a><font size="2"> ) or for the download page (</font><a href="http://code.google.com/p/ice-cream-sandwich-sgs/downloads/list" target="_blank"><font size="2">http://code.google.com/p/ice-cream-sandwich-sgs/downloads/list</font></a><font size="2">).</font></p> <p><font size="2">If you want instructions of how to to install can be found on this link : </font><a href="http://phanse.wordpress.com/2012/01/02/android-ics-4-0-3-rc2-1-by-onecosmic-installation-tutorial-for-sgs-gt-i9000/" target="_blank"><font size="2">http://phanse.wordpress.com/2012/01/02/android-ics-4-0-3-rc2-1-by-onecosmic-installation-tutorial-for-sgs-gt-i9000/</font></a></p> <p><font size="2">If you want to root it, here are a couple of links : </font><a href="http://ics.samsung-updates.com/ICSI9000/"><font size="2">http://ics.samsung-updates.com/ICSI9000/</font></a><font size="2"> , </font><a href="http://ics.samsung-updates.com/kernels/"><font size="2">http://ics.samsung-updates.com/kernels/</font></a></p> <p><font size="2">Google USB driver link : </font><a href="http://developer.android.com/sdk/win-usb.html" target="_blank"><font size="2">http://developer.android.com/sdk/win-usb.html</font></a><font size="2"> , if you want to try a Samsung driver you can try that one from Samsung Nexus, in this </font></p> <p><font size="2">link : </font><a href="http://www.samsung.com/us/support/downloads/SCH-I515MSAVZW" target="_blank"><font size="2">http://www.samsung.com/us/support/downloads/SCH-I515MSAVZW</font></a><font size="2"> , for me it doesn’t have worked, though may it work for you.</font></p> <p><font size="2">After you flash it and if it can’t get connected with your PC, you can follow those steps to make it work.</font></p> <p><font size="2">1. Remove Samsung USB Driver;</font></p> <p><font size="2">2. Uninstall Kies and restart PC;</font></p> <p><font size="2">3. After restart, plug the USB cable in your PC and on your SGS;</font></p> <p><font size="2">4. Open your device manager (<em>Control Panel –> Hardware and Sound –> Device Manager</em>), then you will see the exclamation signal in yellow on the nod named Portable Devices, it will have the name GT-i9000;</font></p> <p><font size="2">5; Right click on it (assuming that you have already installed the USB driver), go to Update Driver, choose select the option <font color="#0000ff">Browse my computer for driver software</font> , then go to the place where you have installed the Android-SDK or the Google USB driver that should have a similar path as this one </font></p> <p><code><font color="#0000ff" size="2"><sdk>\extras\google\usb_driver\</font></code></p> <p><code><font color="#000000" face="Arial"><font size="2"><font color="#333333">and click ok, hold</font> <font color="#333333">for a minute or two and Windows should install the driver, and it will recognize you SGS for the ADB, that means you can get connected on Eclipse (or similar IDE for development).</font></font></font></code></p> <p><code><font size="1" face="Arial"><font size="2">6. If you can’t get it connected as USB storage, and your handset is rooted, download the Terminal Emulator from the Android Market (it’s free) and insert those commands</font>:</font></code></p> <p><code><font face="Arial"><font size="2"><strong>su</strong> <enter></font></font></code></p> <p><font size="2"><strong>setprop persist.sys.usb.config mass_storage,adb</strong> <enter></font></p> <p><font size="2"><strong>reboot</strong> <enter></font></p> <p><font size="2">Your mobile will restart and then from notification bar you will have enabled the option to enable USB storage and will be able do copy/move/delete files/folders from your handset. If it doesn’t work, try those other commands :</font></p> <p><font size="2"><strong>su</strong> <enter></font></p> <p><font size="2"><strong>setprop persist.sys.usb.config mtp,adb</strong> <enter></font></p> <p><font size="2"><strong>reboot</strong> <enter></font></p> <p><font size="2">This should make the final trick.</font></p> <p><font size="2">For my experience the ICS rocks even on a handset that has some age on the back as SGS, it’s fast, though not as with Gingerbread 2.3.5, this release candidate it’s pretty stable, after nearly 4 days (did have install it hours after they put it available to download), I still do have only one issue, that’s I can’t access my external_sd card. This ICS doesn’t have the TouchWiz, what it’s quite good, due that I never liked of it, it’s too similar with IOS and quite few customisable. I’m enjoying it and hope that you also have joy with ICS on SGS. </font></p> <p><font size="2">For those guys that are doing the working on the ICS for SGS, my CONGRATULATIONS for such good product (even on RC phase) in a such short time. Well done.</font></p> Anonymoushttp://www.blogger.com/profile/00908564854719054075noreply@blogger.com0tag:blogger.com,1999:blog-4729831854233341997.post-91450267905621545692011-12-04T20:54:00.001-08:002013-05-18T02:15:03.335-07:00Wallpaper Star Trek and Wallpaper Star Trek HD - Paid version<div dir="ltr" style="text-align: left;" trbidi="on">
As the previous version to browse through the gallery, just swipe your finger to left or right, and tap to choose, then you will be prompted with a dialog box asking if you want set that picture as wallpaper or not.<br />Once you hit the button to set the new wallpaper, the application will take some time to do it.<br />The sound when starting, and ending (via return/exit button) the application it’s the media volume, that you can set as you want.<br />If you have browsed through several wallpapers and set one to see if it’s what you want, and after that you want to come back to pick an other picture, just press the home button once you have chosen the wallpaper, and hold home button for a second and release it, then choose the application from the Android task manager, that you will back to the exact picture that you where before press the home button.<br />As new features, now the application has a menu: <br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgT9C2sy8ZP293e_sOLj9wNYcFdVbMZc4PDt2dE-4eb6NSU-A_LLFheYkl17oG226ebqwcDkllegQP2BSAW9pfnnzVngMCk8iAqtTE0Go7Ff3NhYs0RmZuQuouQNdtZvfYm7eA4EdzGaRE/s1600/Screenshot_2013-05-18-18-48-54.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgT9C2sy8ZP293e_sOLj9wNYcFdVbMZc4PDt2dE-4eb6NSU-A_LLFheYkl17oG226ebqwcDkllegQP2BSAW9pfnnzVngMCk8iAqtTE0Go7Ff3NhYs0RmZuQuouQNdtZvfYm7eA4EdzGaRE/s320/Screenshot_2013-05-18-18-48-54.png" width="192" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3QFQ2R4QDVX6hkks3dfg-K0tkIpscSAhC74ZVoXPD71TR4emG6oxcQb5If5o1Tae6PWVcjTiGK8zu6eGgPpzXwoJ8YEhvjLl_Dd7FQN3YATh1PnpyKYdl9vk-JFzpab77gb9YTg5cI-0/s1600/Screenshot_2013-05-18-18-48-58.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3QFQ2R4QDVX6hkks3dfg-K0tkIpscSAhC74ZVoXPD71TR4emG6oxcQb5If5o1Tae6PWVcjTiGK8zu6eGgPpzXwoJ8YEhvjLl_Dd7FQN3YATh1PnpyKYdl9vk-JFzpab77gb9YTg5cI-0/s320/Screenshot_2013-05-18-18-48-58.png" width="192" /></a></div>
<br />
Image above are from Star Trek wallpapers<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDmMY5iUM3bBVCK-Uwb8LGgbmYUQ1mT615fdYr2s_B1188aGa8YYqWPAgE7MC6IFceYbDddOLZ6sg18MoQYigDJLV1qV6dbe2u_-enqpI9AGKNY_Lm_J-uvU9O9hIQ3mDYhXroZlpa-HE/s1600/Screenshot_2013-05-18-18-51-07.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDmMY5iUM3bBVCK-Uwb8LGgbmYUQ1mT615fdYr2s_B1188aGa8YYqWPAgE7MC6IFceYbDddOLZ6sg18MoQYigDJLV1qV6dbe2u_-enqpI9AGKNY_Lm_J-uvU9O9hIQ3mDYhXroZlpa-HE/s320/Screenshot_2013-05-18-18-51-07.png" width="200" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhaRw0DZXQJ69X1kgdv6wjw19YulMaT_ffroftTYh2gvv_Znv4hrkLFLwvsm-VRhPym4nuDsScFl5dS2IFyxbY4eDEJlS4ghgptc8d5Q0OMrFLYDdhHb1rwC1sEpjHWu0_UHb4H46fqncc/s1600/Screenshot_2013-05-18-18-51-11.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhaRw0DZXQJ69X1kgdv6wjw19YulMaT_ffroftTYh2gvv_Znv4hrkLFLwvsm-VRhPym4nuDsScFl5dS2IFyxbY4eDEJlS4ghgptc8d5Q0OMrFLYDdhHb1rwC1sEpjHWu0_UHb4H46fqncc/s320/Screenshot_2013-05-18-18-51-11.png" width="200" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
Image above are from Star Trek wallpapers HD<br />
Where exist the ordinary About, Service Settings and Gallery Settings. <br />
<strong><br /></strong>
<strong>Service Settings</strong> <br />
Once you click on it will be prompted with this screen : <br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-b8oo0FOd5QoQWYKhkDRhB8kFqYHQGDDGaj4Z10uYBV5fmA6VDXIS2iONuWoUe45_ty6zfhzQO70pzBMJQJ-MSixkWbLf4rZZXfM22uCj94JHLFdzNtq5NMI3xx_Qjuuo3W4y2XQwP-g/s1600/Screenshot_2013-05-18-18-49-03.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-b8oo0FOd5QoQWYKhkDRhB8kFqYHQGDDGaj4Z10uYBV5fmA6VDXIS2iONuWoUe45_ty6zfhzQO70pzBMJQJ-MSixkWbLf4rZZXfM22uCj94JHLFdzNtq5NMI3xx_Qjuuo3W4y2XQwP-g/s320/Screenshot_2013-05-18-18-49-03.png" width="192" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
Image above from normal resolution</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgoEraiNmxijEUj6nX_UmGM5HqbzagzQzbiuhgofNMyudKqJ2NHqtrnSanAvIBYi6baLrWorP49H719OwwkKLnaHk1vuoZVNaTz2wld9vZzk1eOAUmBDQn9KL2GyVxYZngPNX6-sx2imlc/s1600/Screenshot_2013-05-18-18-51-24.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgoEraiNmxijEUj6nX_UmGM5HqbzagzQzbiuhgofNMyudKqJ2NHqtrnSanAvIBYi6baLrWorP49H719OwwkKLnaHk1vuoZVNaTz2wld9vZzk1eOAUmBDQn9KL2GyVxYZngPNX6-sx2imlc/s320/Screenshot_2013-05-18-18-51-24.png" width="200" /></a></div>
<br />
Image above is from the HD version.<br />
<br />
<br />
Where to enable a background service, you will need to tap on the check-box labelled “Activate Service” to start select those settings that you want. Then you can tap at the button Choose Pictures, to be taken to a thumbnail screen, where will be displayed all wallpapers and you will be able to select up to 10 of it.<br />
<br />
To make the selection, it’s pretty simple, just swipe up/down to scroll through those wallpapers thumbnails and tap on those check-boxes to enable the wallpaper that you want be rotate as your background. When finished just click select to come back. <br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgMQikvkyiDIwkk-rfP64HzJkH9OPHXk3HpKOvkm9qjSc5DhMVYwOVUG8VjbO90kfUYPHBluQv9ULV1weQQ4MNMVO3DQVDRadbzfjVxrmNFbsPHgAC-x-WopEwGe2rkMpH4wRwHUOEa-aQ/s1600/Screenshot_2013-05-18-18-49-11.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgMQikvkyiDIwkk-rfP64HzJkH9OPHXk3HpKOvkm9qjSc5DhMVYwOVUG8VjbO90kfUYPHBluQv9ULV1weQQ4MNMVO3DQVDRadbzfjVxrmNFbsPHgAC-x-WopEwGe2rkMpH4wRwHUOEa-aQ/s320/Screenshot_2013-05-18-18-49-11.png" width="192" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5BbEPV5QYAeTSgQe9nMQLNFZ_adRqGqt5UHgZt6QWXrgrD33sGA_PWgcIf_1rdlXiuWKBpimyiQr8rg7Qh_pQADCADOs11oOZMnX8ponFc0PPlXTKlQ2rYAYj2CDJro8gHuUZFzjqADo/s1600/Screenshot_2013-05-18-18-49-18.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5BbEPV5QYAeTSgQe9nMQLNFZ_adRqGqt5UHgZt6QWXrgrD33sGA_PWgcIf_1rdlXiuWKBpimyiQr8rg7Qh_pQADCADOs11oOZMnX8ponFc0PPlXTKlQ2rYAYj2CDJro8gHuUZFzjqADo/s320/Screenshot_2013-05-18-18-49-18.png" width="192" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOVirYJk0xlRri3TNPZgEIiHvDavP6nEC4IfDTeODr1NRxN3GDfegxBEl8EuIZpv4LemUf51LO55DuCGhtDUimBZA7ShtqhJISjcy1-5QQA87dH-SkuaLzg_5PKdpjbDMHAYYiIofRjJA/s1600/Screenshot_2013-05-18-18-49-25.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOVirYJk0xlRri3TNPZgEIiHvDavP6nEC4IfDTeODr1NRxN3GDfegxBEl8EuIZpv4LemUf51LO55DuCGhtDUimBZA7ShtqhJISjcy1-5QQA87dH-SkuaLzg_5PKdpjbDMHAYYiIofRjJA/s320/Screenshot_2013-05-18-18-49-25.png" width="192" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHlDibl50RonobyzrwArJy2bymjlnQ07tqyE-UR9xyphyphenhyphenAKIIdyyZ0c5yaOP_HyvKmaGFEEr6GIHpvRSKaUavQxe7VepR-VwQlA1ozwFTkJbXt5-6LDzin6sMgrRZjgR4rk0ISATMaweg/s1600/Screenshot_2013-05-18-18-49-28.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHlDibl50RonobyzrwArJy2bymjlnQ07tqyE-UR9xyphyphenhyphenAKIIdyyZ0c5yaOP_HyvKmaGFEEr6GIHpvRSKaUavQxe7VepR-VwQlA1ozwFTkJbXt5-6LDzin6sMgrRZjgR4rk0ISATMaweg/s320/Screenshot_2013-05-18-18-49-28.png" width="192" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjivNbEedkqOhE5HFsoH0efZ0kccUtX0ICAkr2FiT84LHCbIwQAqBQ89JMqc9IGOKuD2Y4JjWslpxPGIDwZmWs2fL_gPY8WfYR6cp7ESdSyic597iDJplolgSvSW4JNOihHzSpfLmajJYI/s1600/Screenshot_2013-05-18-18-49-34.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjivNbEedkqOhE5HFsoH0efZ0kccUtX0ICAkr2FiT84LHCbIwQAqBQ89JMqc9IGOKuD2Y4JjWslpxPGIDwZmWs2fL_gPY8WfYR6cp7ESdSyic597iDJplolgSvSW4JNOihHzSpfLmajJYI/s320/Screenshot_2013-05-18-18-49-34.png" width="192" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhuj68twDQxNn2Gn-VQHcjS3sXFRPBK_rg9C81WT3ZH0Cnq_LCBnMi2NkIRD_xIHf9PSkzQB8sL81YOr_SifWD4T11ZkKWmfJcXE2MVOnyexaytmV7A8U88El4SK8frmEjRGqpX_oNzUd0/s1600/Screenshot_2013-05-18-18-49-38.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhuj68twDQxNn2Gn-VQHcjS3sXFRPBK_rg9C81WT3ZH0Cnq_LCBnMi2NkIRD_xIHf9PSkzQB8sL81YOr_SifWD4T11ZkKWmfJcXE2MVOnyexaytmV7A8U88El4SK8frmEjRGqpX_oNzUd0/s320/Screenshot_2013-05-18-18-49-38.png" width="192" /></a></div>
<br />
<br />
After selected and came back to the previous screen, it’s time to select the interval time, that it’s the time between wallpaper changes, this can be from 5 minutes up to 7 days. Once selected the interval just hit the back button to come back to the main screen and activate the service.<br />
After you have selected all those options, just hit the back button that it will activate the background service. Be aware that in this version the application doesn't save these settings. This means that if you go again from main screen to the service settings screen everything will be like the first time, with all thumbnails to be selected. Though doesn't mean that the service it’s not running in background, but once you hit the back button to come back, the service will stop straight away.<br />
The background services is very savvy in memory and with the battery, of course if you choose update the wallpaper at each 5 min it'll consume more battery than each day option.<br />
If you click back button (and not the select) from select screen, will come back without save the selected state, means a plain back to the previous screen. <br />
If you want to switch off the service it’s just select the Service Setting and hit back, without enable the service, doing this the applications will stop the service.<br />
<br />
<strong>Gallery Settings</strong><br />
You will be taken to an other screen where will be able to choose the orientation for the application between just portrait to have landscape also and to select the size in % from the X axis, from the gallery pictures. That’s the one you see when scrolling from choose a wallpaper. After you have insert your settings, just hit the back button to save your changes.<br />
To enable landscape orientation you must enable the button where it’s write Deactivated Landscape, that will change to Activate Landscape.<br />
If you want to come back to the default settings, hit the Reset to Default button and back button.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-b8oo0FOd5QoQWYKhkDRhB8kFqYHQGDDGaj4Z10uYBV5fmA6VDXIS2iONuWoUe45_ty6zfhzQO70pzBMJQJ-MSixkWbLf4rZZXfM22uCj94JHLFdzNtq5NMI3xx_Qjuuo3W4y2XQwP-g/s1600/Screenshot_2013-05-18-18-49-03.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-b8oo0FOd5QoQWYKhkDRhB8kFqYHQGDDGaj4Z10uYBV5fmA6VDXIS2iONuWoUe45_ty6zfhzQO70pzBMJQJ-MSixkWbLf4rZZXfM22uCj94JHLFdzNtq5NMI3xx_Qjuuo3W4y2XQwP-g/s320/Screenshot_2013-05-18-18-49-03.png" width="192" /></a></div>
<br />
Now the background services is part of Star Trek Wallpapers and of HD version as well.<br />
That’s all, I hope that you have good times with these new features, if have any issue, doubt or ideas, it’s just drop a email to me that I’ll answer it as soon as possible, and “Live longer and Prosper”.<br />
<br />
<br />
<br />
<br />
<br />
</div>
Anonymoushttp://www.blogger.com/profile/00908564854719054075noreply@blogger.com0tag:blogger.com,1999:blog-4729831854233341997.post-30836174744606985552011-11-06T04:23:00.000-08:002011-11-06T04:23:39.016-08:00Updates coming till December<div dir="ltr" style="text-align: left;" trbidi="on">
Hi,<br />
<br />
At moment I'm working on three updates, one for DataSafe that this new release will be able to work with rooted phones, one new release of the Tactical Console where will have direction to the phasers and aft phasers and torpedoes, apart that will have two sort of torpedoes (Photon and Quantun) and for last in one update for the Star Trek Wallpaper, this so far will have the option to the user choose the size of the gallery to select those pictures, one background services that you can enable/disable and you will be able to choose among up to 10 wallpapers and with time frame from 5min. to 7 days to update the wallpaper, rotating it, and one that would make a lot people happy though all pre-paid ones not very happy, that it's the download option, that in first instance is make the application smaller and faster, apart that the application would only download those wallpapers size that fits to your mobile, like for one with less than 3.2 inches would be pictures quite smaller then the medium, high and extra large (tablets), and with that I could put more pictures than today that it's packed with all pics for three different sizes.<br />
This one should come out soon, than DataSafe and for last the Tactical console, that honestly I'm thinking in stop with it, due Android fragmentation, doesn't work well in many handsets, even using the Android compatibility package.<br />
If you have time to leave a comment could you please let me know if the download option it's a good option for you or not, because I'll use those comments to create the next update.<br />
Thank you<br />
<br /></div>Anonymoushttp://www.blogger.com/profile/00908564854719054075noreply@blogger.com0tag:blogger.com,1999:blog-4729831854233341997.post-90112463006985859302011-09-06T05:12:00.001-07:002013-05-18T02:41:15.428-07:00Express User Guide: Notes Safe<div dir="ltr" style="text-align: left;" trbidi="on">
It’s a simple notepad that encrypt all data that it’s inserted. You can have a cypher from 64bits up to 256bits (paid version). This application has two layers of encryption, you will not be able to read the database even if have a rooted phone and use some sort of SQL client, however the title will be easy to read.<br />
When in the first time running it, you will be asked to insert one password, the minimum size allowed it’s with 8 chars (64bits), and the maximum 32 chars (256bits). After that just hit the diskette to save it.<br />
<strong>Main screen</strong>: In the main screen you will have four options that are create note, delete, update/view and exit application.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2AdNbXd9ls6dC7EEhVLJWVt5FIXTE88KrtpszHSFIEiMcQTi7y8QvNy76RA-SjAsdLyuYmF6wEkREkXmsWopiSGESbI_ieJnbvCgJ-ERn5olMZSGvlaBF1eYQbWkHjWQC3sLvyOz4hXw/s1600/Screenshot_2013-05-18-19-27-50.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2AdNbXd9ls6dC7EEhVLJWVt5FIXTE88KrtpszHSFIEiMcQTi7y8QvNy76RA-SjAsdLyuYmF6wEkREkXmsWopiSGESbI_ieJnbvCgJ-ERn5olMZSGvlaBF1eYQbWkHjWQC3sLvyOz4hXw/s320/Screenshot_2013-05-18-19-27-50.png" width="200" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
Above : The login page</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzuMQtF593r29wWPK_VHQEXexiLJNrsa13BeQmy1mzUL6IMD213JpVuam99qCR99XddJ2G9rJB1d0ft6iTsSGpuWYgQrhpfJZhWRncaelKU0YnnnlhBGkraYyjW3g_iWooPzkeL-E_Kfs/s1600/Screenshot_2013-05-18-19-28-09.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzuMQtF593r29wWPK_VHQEXexiLJNrsa13BeQmy1mzUL6IMD213JpVuam99qCR99XddJ2G9rJB1d0ft6iTsSGpuWYgQrhpfJZhWRncaelKU0YnnnlhBGkraYyjW3g_iWooPzkeL-E_Kfs/s320/Screenshot_2013-05-18-19-28-09.png" width="200" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
Above : The main screen</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<u><em>Creating</em></u>: Will be asked a title for the note, and you will have a body part where you should insert your notes, please note that the title will not be encrypted, due that, you will be able to read what means each one, please if you want safe data, don’t put your notes in there. After done, hit the disk, or the red X if you want to leave without save.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiplHIabsW5rRJvl2Wvci9h7RBF_vWMm-vip8cQK6F3iBVpfm0SmPvuMqk7faONDof0u-kU_iHjogwPXYXz4i3uBeW2JXgV_HdwjpgrN8NjC3zWg7cigkpBIZ8L1N3sPyYxWb99De81lUQ/s1600/Screenshot_2013-05-18-19-28-37.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiplHIabsW5rRJvl2Wvci9h7RBF_vWMm-vip8cQK6F3iBVpfm0SmPvuMqk7faONDof0u-kU_iHjogwPXYXz4i3uBeW2JXgV_HdwjpgrN8NjC3zWg7cigkpBIZ8L1N3sPyYxWb99De81lUQ/s320/Screenshot_2013-05-18-19-28-37.png" width="200" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<br />
<u><em>Deleting, Updating and View</em></u>: You will be redirected to one other page with a table where will contain all your notes, ordered by title, where you can pick one, tapping on it. If deleting you will be asked to confirm, if updating/view the note will be displayed and you will be able to tap where you want into the note area and insert data.Then it’s just save.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiugFIhM66gA-7ZfGPrGzjHUoujWYJyQZ6A6tGUp7481944Khv6Ht54fl9LDFnTzGtwPLTRqEUYfGlYs_dsK3nDycHIjSE2S0Kdp5jrlmlowVmajdksi191u6uZF_KPGhjAImptRgQ4gPE/s1600/Screenshot_2013-05-18-19-29-02.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiugFIhM66gA-7ZfGPrGzjHUoujWYJyQZ6A6tGUp7481944Khv6Ht54fl9LDFnTzGtwPLTRqEUYfGlYs_dsK3nDycHIjSE2S0Kdp5jrlmlowVmajdksi191u6uZF_KPGhjAImptRgQ4gPE/s320/Screenshot_2013-05-18-19-29-02.png" width="200" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
Above : List with all items</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjLIK7Etkm02RhA1ueYoatq9DIM5yS6NeRcBTyaU2NHD0RaJS5IsWjq-bq4SrsdwjkVGz1HGPwz9zxtkA5Bwo5dPxYDlR_uAiz14x81VWb2fwS-0p1ZV_VxQg3Ezc7QBInDhsrQ0XwJrxo/s1600/Screenshot_2013-05-18-19-28-53.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjLIK7Etkm02RhA1ueYoatq9DIM5yS6NeRcBTyaU2NHD0RaJS5IsWjq-bq4SrsdwjkVGz1HGPwz9zxtkA5Bwo5dPxYDlR_uAiz14x81VWb2fwS-0p1ZV_VxQg3Ezc7QBInDhsrQ0XwJrxo/s320/Screenshot_2013-05-18-19-28-53.png" width="200" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
Above : Deleting</div>
<br />
To update the detail, it's pretty simple, just touch the item desired and you will see the same screen as when creating a new one displaying the data, then it's just update and save it.<br />
<br />
Leaving the application: It’s the last icon from left to right, once you hit it, the application will exit.<br />
If you have doubts please send me a email to <u><a href="mailto:kv.android.app@gmail.com">kv.android.app@gmail.com</a></u></div>
Anonymoushttp://www.blogger.com/profile/00908564854719054075noreply@blogger.com0tag:blogger.com,1999:blog-4729831854233341997.post-13457868471212264652011-09-06T03:38:00.001-07:002011-10-16T02:00:51.869-07:00Express User Guide: Wallpapers (Star Trek, Cars) all versions<div dir="ltr" style="text-align: left;" trbidi="on">To browse through the gallery, just swipe your finger to left or right, and tap to choose, then you will be prompted with a dialog box asking if you want set that picture as wallpaper or not. <br />
Once you hit the button to set the new wallpaper, the application will take some time to do it. <br />
The sound when starting, and ending (via return/exit button) the application it’s the media volume, that you can set as you want. <br />
If you have browsed through several wallpapers and set one to see if it’s what you want, and after that you want to come back to pick an other picture, just press the home button once you have chosen the wallpaper, and hold home button for a second and release it, then choose the application from the Android task manager, that you will back to the exact picture that you where before press the home button. <br />
<b>To Star Trek fans</b>: <span style="font-size: x-small;">Thank you very much for those downloads and for buy my application.</span> <br />
I’m still thinking in insert download pictures options, to increase even more the number of wallpapers available to the application, though I do need rent a server, what it’s not cheap and honestly the sales still doesn’t pay it, apart that I need to check for copyright infringement, if it’s ok or not. Because I don’t want have my application removed from the market. Soon will have one answer about that.<br />
<br />
If you have doubts please send me a email to <u><a href="mailto:kv.android.app@gmail.com">kv.android.app@gmail.com</a></u></div>Anonymoushttp://www.blogger.com/profile/00908564854719054075noreply@blogger.com0tag:blogger.com,1999:blog-4729831854233341997.post-28281478790765270642011-09-06T03:28:00.001-07:002011-09-06T04:44:30.660-07:00Express User Guide: Data Safe<p>Data Safe it’s a Android application that enables you to encrypt any file that you want from your device. You can have different types and strength of passwords from 64 till 256bits. Today the version available doesn’t have support for ROOT devices, though soon it will have this feature and will be updated to Android 2.2, SD storage, and other emails available rather than just Gmail. <p><b>Menu:</b> <p>I’ll be available after you have created one password and logged in. <p>From main screen press the menu button. <p>There will have these three options: <p><i><u>Settings </u></i>: Here it’s where you will set for what email you want to send the application information, and if you want send just the password, the source file, as attach file, both, and if want to delete the source file or not after conversion. This will generate a file in your Data Safe application folder with those options set, though it’s also an encrypted file. <p><a href="http://lh4.ggpht.com/-WuQfhabKRk0/TmYHkDNVumI/AAAAAAAAAGU/ScHed4cN97U/s1600-h/SettingsPage%25255B2%25255D.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="SettingsPage" border="0" alt="SettingsPage" src="http://lh5.ggpht.com/-xtq0qsUdAQU/TmYHk7STpMI/AAAAAAAAAGY/PXLMDQHD-Vk/SettingsPage_thumb.png?imgmax=800" width="164" height="244"></a> <p>Here after set the email/password you can just hit send password, and the application will send it to the email account inserted there. <p>After have done all settings that you want, don’t forget to hit Save. This will take you back to the main screen. <p><i><u>Delete Password</u></i>: Touching this options, you’ll be prompted with a dialog box asking if you really want delete the password. If you cancel the applications will return, normally though if you choose yes, the application will delete your password and close. <p><i><u>About</u></i>: It’s one about the application, with an Ok button. <p><b>Main Screen</b>: <p><a href="http://lh4.ggpht.com/-zlcgKkDZk4M/TmYHlTPEJpI/AAAAAAAAAGc/fXwer2tiBoQ/s1600-h/NewGUIMainPage%25255B2%25255D.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="NewGUIMainPage" border="0" alt="NewGUIMainPage" src="http://lh4.ggpht.com/-KA0zgsnUGMs/TmYHmBzZFvI/AAAAAAAAAGg/ifwb20ILldA/NewGUIMainPage_thumb.png?imgmax=800" width="164" height="244"></a> <p>From here you can start work with it: <p><i><u>Button From</u></i>: Hit it and you will be directed to one screen where you will browse through the Android file system. To do it you just need to move your fingers up or down, and to go into folders or select the file, it’s just a tap, if the folder that you are going it’s a system or protected nothing will be displayed. Choosing a file to encrypt or decrypt, just tap in the file, and you will be prompted if you want use that file. <p>Clicking <b>Return</b> will come back to the folders browser, and <b>Yes</b> will take you back to the main screen with the path in the text field proper filled with the path and file name. If you wish you can also type the path that you want. <p>Once the file has been chosen those icons under will be enabled or disabled, this will depend of the file type, means if to encrypt or decrypt. <p>If you are decrypting a file, the chosen file will populate the original path automatically in the text field form To button, other else not. <p><i><u>Button To</u></i>: Like the Button From, you will also be taken to a screen to browse through the system file to one destination for your file. In this folder browser, you can navigate just like the previous one, moving finger up and down, one tap to get into folders, though in this button you will not be allowed to select a file, just the folder where you will put your file, and to do it just hit and hold a little bit over the folder name, and the application will prompt you asking if you want to use that path to your file, like previous one, yes return and fill text field after the To button and as the above button you can if wish type the path, since that it’s a valid one, you must have read and write privileges to do that in that folder. <p><b>Icons</b>: <p><a href="http://lh5.ggpht.com/-Wa7ejFt3WCc/TmYHmi8YuBI/AAAAAAAAAGk/cLh9RKa34Bs/s1600-h/icons%25255B2%25255D.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="icons" border="0" alt="icons" src="http://lh6.ggpht.com/-8Vh2Mo_GQJs/TmYHnb3-YcI/AAAAAAAAAGo/z_L5hv6EL9g/icons_thumb.png?imgmax=800" width="241" height="66"></a> <p>You have a locked pad lock, one open, other with two arrows making a circle and one with the open dor and the arrow point to it. <p><i><u>Locked pad lock</u></i>: This button will let you encrypt the file, if it’s not encrypted already, using those from, to paths provided previously. <p><i><u>Unlocked pad lock</u></i>: This button will let you decrypt the encrypted file, using as above the values into from, to text fields. <p><i><u>Two blue arrows circling</u></i>: Will clean both text fields. <p><i><u>Open door with arrow pointing to it</u></i>: Exit the application. <p>Three wrong tries and your password file will be wiped out from your mobile. If you remember the password, it’s just inserting again the same password, when starting the application. If you don’t remember but have received it via email, it’s just creating it once again. <p>Now, if you don’t remember it and don’t have set the application to send the password to the email. Then will not exist other way. What’s was encrypted will be lost. Doesn’t exist any sort of backdoors to re-acquire the password. <p>If you have doubts please send me a email to <u><a href="mailto:kv.android.app@gmail.com">kv.android.app@gmail.com</a></u></p> Anonymoushttp://www.blogger.com/profile/00908564854719054075noreply@blogger.com0