Thursday, July 26, 2012

Android & Twitter - OAuth authentation

http://automateddeveloper.blogspot.com/2011/06/android-twitter-oauth-authentication.html

I’ve seen a lot of questions about connecting Android apps with Twitter using OAuth and thought I would write up a walk-through of how it can be done. The example will be done using Twitter4J which is a great library for connecting Java apps with Twitter and provides a simple interface to connect to the public Twitter Web Services.

First thing you will need to do is to register your new app (even though you haven’t made it yet!). Do this by heading to https://dev.twitter.com/apps/new (you will need an existing Twitter account sign up). You should complete the form with the relevant details for your app:


Spring Social Twitter Oauth

http://stackoverflow.com/questions/7968641/spring-social-twitter-oauth

Tuesday, July 24, 2012

Android VM and application

Dalvik performs a host of other optimizations, such as utilizing shared memory to allow objects being used by more than one application. This results in less memory consumption and fewer garbage collector cycles (again saving computing time and therefore battery). To achieve this, Android starts a special Dalvik VM instance on system boot, called Zygote, which preloads data into the shared memory that will likely be used by all applications (such as the core libraries). The Zygote VM then forks a new Dalvik instance from itself for each new application that’s about to start. Each child process (which is also a separate Linux process) can then access the shared data.



Sunday, July 22, 2012

Java Classloaders



The Java platform ships with a number of typical classloaders, which are used to do different jobs during the startup and normal operation of the platform:

Primordial (or bootstrap) classloaderThis is instantiated very early in the process of starting up the VM, and is usually implemented as native code. It’s often best to think of it as being a part of the VM itself. It’s typically used to get the basic system JARs—basically rt.jar—loaded and it does no verification.


Extension classloader—This is used to load installation-wide standard extensions. This often includes security extensions.

Application (or system) classloader—This is the most widely used classloader. It’s the one that will load the application classes and do the majority of the work in in most SE environments.


Custom classloader—In more complex environments, such as EE or the more sophisticated SE frameworks, there will often be a number of additional (a.k.a. custom) classloaders. Some teams even write classloaders that are specific to their individual applications. In addition to their core role, classloaders are also often used to load resources (files that aren’t classes, such as images or config files) from JAR files or other locations on the classpath.

Android inter-/intra-process communication


Android offers a unique collection of mechanisms for inter- (and intra-) application
communication. This chapter discusses the following:

Intents
Specify what you intend to do next: either to invoke a particular class within your
application, or to invoke whatever application the user has configured to process
a particular request on a particular type of data
Broadcast receivers
In conjunction with intent filters, allow you to define an application as able to
process a particular request on a particular type of data (i.e., the target of an intent)
AsyncTask
Allows you to specify long-running code that should not be on the “GUI thread”
or “main event thread” to avoid slowing the app to the point that it gets ANR
(“Application Not Responding”) errors
Handlers
Allow you to queue up messages from a background thread to be handled by an-
other thread such as the main activity thread, usually to cause information to up-
date the screen safely

Sunday, July 15, 2012

Shell tips



filename="all you need is love - the beatles.mp3"
ext=$(echo $filename | grep -o '\....$')
title=$(echo $filename | sed 's/ - .*//; s/\b\w/\u&/')
artist=$(echo $filename | sed "s/.* - \(.*\)$ext/\1/; s/\b\w/\u&/g")
echo $title - $artist$ext

All you need is love - The Beatles.mp3