Saturday, October 29, 2011

Normally (in other language/system), we will generate random number with seek of current time, to try to make the pseudo-random un-predictable. But in case of Android, it's not necessary and not recommended - Because "It is dangerous to seed Random with the current time because that value is more predictable to an attacker than the default seed." - refer to Android document java.util.Random.

The default constructs, Random(), already come with an initial state that is unlikely to be duplicated by a subsequent instantiation.

Thursday, October 27, 2011

The XML parsing interface returned for an XML resource. This is a standard XmlPullParser interface, as well as an extended AttributeSet interface and an additional close() method on this interface for the client to indicate when it is done reading the resource.

Normally, xml file will be placed under /res/xml/ folder; as a example /res/layout/main.xml is used here.

// Install a SurfaceHolder.Callback so we get notified when the // underlying surface is created and destroyed. mHolder = getHolder(); mHolder.addCallback(this); // deprecated setting, but required on Android versions prior to 3.0 mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); }

@Override public void surfaceChanged(SurfaceHolder holder, int format, int weight, int height) { // If your preview can change or rotate, take care of those events here. // Make sure to stop the preview before resizing or reformatting it.

jdk-7u<version>-linux-i586.tar.gz1. Download the file. Before the file can be downloaded, you must accept the license agreement. The archive binary can be installed by anyone (not only root users), in any location that you can write to. However, only the root user can install the JDK into the system location.

2. Change directory to the location where you would like the JDK to be installed. Move the .tar.gz archive binary to the current directory.

3. Unpack the tarball and install the JDK.

% tar zxvf jdk-7u<version>-linux-i586.tar.gzThe Java Development Kit files are installed in a directory called jdk1.7.0_<version> in the current directory.

4. Delete the .tar.gz file if you want to save disk space.

Up to now, you have downloaded and installed JDK7 on your machine, but not yet installed in your system!

/usr/lib/jvm/ is the directory the JDK installed, on step 2; such that javac should be at /usr/bin/javac javac /usr/lib/jvm/jdk1.7.0/bin/javac.

The last number, 1, is an integer of "priority"; it should be work on any integer number.

Finally, may be you have to config your javac alternative, if you have more than one javac installed.$sudo update-alternatives --config javac

Note: Up to this minute, only JDK 5 and JDK 6 are officially supported for Android development, according to Android SDK document: System Requirements. May be, it will be officially support JDK 7 in short future.

// Install a SurfaceHolder.Callback so we get notified when the // underlying surface is created and destroyed. mHolder = getHolder(); mHolder.addCallback(this); // deprecated setting, but required on Android versions prior to 3.0 mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); }

3GPP Long Term Evolution (LTE) is a standard for wireless communication of high-speed data. It is based upon GSM/EDGE and Universal Mobile Telecommunications System/High Speed Packet Access (UMTS/HSPA) network technologies.[1][2] The standard is maintained as a project of the 3rd Generation Partnership Project (3GPP), operating under a name trademarked by one of the associations within the partnership, the European Telecommunications Standards Institute (ETSI).

The goal of LTE is to increase the capacity and speed of wireless data networks utilizing cutting-edge hardware and Digital Signal Processing (DSP) techniques that have recently been developed. Its wireless interface is incompatible with 2G and 3G networks, and so it must be operated on separate wireless spectrum.

Features of LTE include an all-IP flat network architecture, end-to-end QoS including provisions for low-latency communications, peak download rates nearing 300 Mbps and upload rates of 75 Mbps, capacity exceeding 200 active users per cell, the ability to manage fast-moving mobiles, and support for multi-cast and broadcast streams.

Thursday, October 20, 2011

The last exercise "Run Android Java code from Webpage" show how to call from WebView JavaScript to Android activity. Here will show how to call in reverse direction: Call JavaScript inside WebView from Android activity, with parameter passed.

Using JavascriptInterface you can create interfaces between webpage's JavaScript code and Android Java code. For example, your JavaScript code can call a method in your Android code to display a Dialog, or Toast.

To bind a new interface between your JavaScript and Android code, call addJavascriptInterface(), passing it a class instance to bind to your JavaScript and an interface name that your JavaScript can call to access the class.

Caution: Using addJavascriptInterface() allows JavaScript to control your Android application. This can be a very useful feature or a dangerous security issue. When the HTML in the WebView is untrustworthy (for example, part or all of the HTML is provided by an unknown person or process), then an attacker can include HTML that executes your client-side code and possibly any code of the attacker's choosing. As such, you should not use addJavascriptInterface() unless you wrote all of the HTML and JavaScript that appears in your WebView. You should also not allow the user to navigate to other web pages that are not your own, within your WebView (instead, allow the user's default browser application to open foreign links—by default, the user's web browser opens all URL links, so be careful only if you handle page navigation as described in the following section).

Sunday, October 16, 2011

The file in Internal Storage can be read using read() method of FileInputStream class.

Further work on last exercise "List the saved files in Internal Storage"; once any item in the ListView of saved files is clicked, the file will be opened using FileInputStream.read(), and the content will be displayed in a custom dialog.

Saturday, October 15, 2011

You can save files directly on the device's internal storage. By default, files saved to the internal storage are private to your application and other applications cannot access them (nor can the user). When the user uninstalls your application, these files are removed.

Thursday, October 13, 2011

Refer to the last exercise "Pass Bitmap between activities", pass Bitmap as extra is not recommended for large bitmap. Saving in Internal Storage and read in second activity is an alternative.

It's a example to save and read bitmap in Internal Storage. In AndroidBitmapActivity class, the bitmaps are saved in Internal Storage, in MODE_PRIVATE (where the created file can only be accessed by the calling application). The bitmaps will be read in SecondActivity class.