Tuesday, 29 November 2011
JavaFX apps will not run from a Browser on Windows 7 64 bit
Problem: After installing Java 6 or Java 7 and the Java FX Runtime on Windows 7 64 bit, you can not launch JavaFX applications from your browser. Any attempt to launch an application results in a request from the browser to install Java. Which is silly because it is already installed. Or is it?
Solution: Most web browsers are actually 32 bit applications. Consequently, you must install the 32 bit version of the Java Runtime Edition (JRE) and the 32 bit version of the JavaFX runtime. The first will install the needed Java plugin for your browsers. The second makes JavaFX available for 32 bit apps. After the install, restart your browser and voila, everything should work fine.
Monday, 28 November 2011
Cyber Monday
Sunday, 27 November 2011
Implement Pinch Zoom in OnTouchListener
package com.exercise.AndroidTouchPinchZoom;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.util.FloatMath;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.ImageView;
import android.widget.TextView;
public class AndroidTouchPinchZoomActivity extends Activity {
TextView myTouchEvent;
ImageView myImageView;
Bitmap bitmap;
int bmpWidth, bmpHeight;
//Touch event related variables
int touchState;
final int IDLE = 0;
final int TOUCH = 1;
final int PINCH = 2;
float dist0, distCurrent;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
myTouchEvent = (TextView)findViewById(R.id.touchevent);
myImageView = (ImageView)findViewById(R.id.imageview);
bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
bmpWidth = bitmap.getWidth();
bmpHeight = bitmap.getHeight();
distCurrent = 1; //Dummy default distance
dist0 = 1; //Dummy default distance
drawMatrix();
myImageView.setOnTouchListener(MyOnTouchListener);
touchState = IDLE;
}
private void drawMatrix(){
float curScale = distCurrent/dist0;
if (curScale < 0.1){
curScale = 0.1f;
}
Bitmap resizedBitmap;
int newHeight = (int) (bmpHeight * curScale);
int newWidth = (int) (bmpWidth * curScale);
resizedBitmap = Bitmap.createScaledBitmap(bitmap, newWidth, newHeight, false);
myImageView.setImageBitmap(resizedBitmap);
}
OnTouchListener MyOnTouchListener
= new OnTouchListener(){
@Override
public boolean onTouch(View view, MotionEvent event) {
// TODO Auto-generated method stub
float distx, disty;
switch(event.getAction() & MotionEvent.ACTION_MASK){
case MotionEvent.ACTION_DOWN:
//A pressed gesture has started, the motion contains the initial starting location.
myTouchEvent.setText("ACTION_DOWN");
touchState = TOUCH;
break;
case MotionEvent.ACTION_POINTER_DOWN:
//A non-primary pointer has gone down.
myTouchEvent.setText("ACTION_POINTER_DOWN");
touchState = PINCH;
//Get the distance when the second pointer touch
distx = event.getX(0) - event.getX(1);
disty = event.getY(0) - event.getY(1);
dist0 = FloatMath.sqrt(distx * distx + disty * disty);
break;
case MotionEvent.ACTION_MOVE:
//A change has happened during a press gesture (between ACTION_DOWN and ACTION_UP).
myTouchEvent.setText("ACTION_MOVE");
if(touchState == PINCH){
//Get the current distance
distx = event.getX(0) - event.getX(1);
disty = event.getY(0) - event.getY(1);
distCurrent = FloatMath.sqrt(distx * distx + disty * disty);
drawMatrix();
}
break;
case MotionEvent.ACTION_UP:
//A pressed gesture has finished.
myTouchEvent.setText("ACTION_UP");
touchState = IDLE;
break;
case MotionEvent.ACTION_POINTER_UP:
//A non-primary pointer has gone up.
myTouchEvent.setText("ACTION_POINTER_UP");
touchState = TOUCH;
break;
}
return true;
}
};
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />
<TextView
android:id="@+id/touchevent"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<ImageView
android:id="@+id/imageview"
android:layout_gravity="center"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="center" />
</LinearLayout>
Download the files.
Related article:
- Scale bitmap according to ScaleGestureDetector
Saturday, 26 November 2011
Implement OnTouchListener to handle multi-touch event
ACTION_DOWN: A pressed gesture has started, the motion contains the initial starting location.
ACTION_POINTER_DOWN: A non-primary pointer has gone down.
ACTION_MOVE: A change has happened during a press gesture (between ACTION_DOWN and ACTION_UP).
ACTION_UP: A pressed gesture has finished.
ACTION_POINTER_UP: A non-primary pointer has gone up.
It will be used to implement our pinch zoom in coming exercise.
package com.exercise.AndroidTouchPinchZoom;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.ImageView;
import android.widget.TextView;
public class AndroidTouchPinchZoomActivity extends Activity {
TextView myTouchEvent;
ImageView myImageView;
Bitmap bitmap;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
myTouchEvent = (TextView)findViewById(R.id.touchevent);
myImageView = (ImageView)findViewById(R.id.imageview);
bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
myImageView.setImageBitmap(bitmap);
myImageView.setOnTouchListener(MyOnTouchListener);
}
OnTouchListener MyOnTouchListener
= new OnTouchListener(){
@Override
public boolean onTouch(View view, MotionEvent event) {
// TODO Auto-generated method stub
switch(event.getAction() & MotionEvent.ACTION_MASK){
case MotionEvent.ACTION_DOWN:
//A pressed gesture has started, the motion contains the initial starting location.
myTouchEvent.setText("ACTION_DOWN");
break;
case MotionEvent.ACTION_POINTER_DOWN:
//A non-primary pointer has gone down.
myTouchEvent.setText("ACTION_POINTER_DOWN");
break;
case MotionEvent.ACTION_MOVE:
//A change has happened during a press gesture (between ACTION_DOWN and ACTION_UP).
myTouchEvent.setText("ACTION_MOVE");
break;
case MotionEvent.ACTION_UP:
//A pressed gesture has finished.
myTouchEvent.setText("ACTION_UP");
break;
case MotionEvent.ACTION_POINTER_UP:
//A non-primary pointer has gone up.
myTouchEvent.setText("ACTION_POINTER_UP");
break;
}
return true;
}
};
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />
<TextView
android:id="@+id/touchevent"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<ImageView
android:id="@+id/imageview"
android:layout_gravity="center"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="center" />
</LinearLayout>
Download the files.
Thursday, 24 November 2011
Scale bitmap according to ScaleGestureDetector
package com.exercise.AndroidPinchZoom;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.ScaleGestureDetector;
import android.view.ScaleGestureDetector.SimpleOnScaleGestureListener;
import android.widget.ImageView;
import android.widget.TextView;
public class AndroidPinchZoomActivity extends Activity {
TextView scaleGesture;
ImageView myImageView;
float curScale = 1F;
Bitmap bitmap;
int bmpWidth, bmpHeight;
ScaleGestureDetector scaleGestureDetector;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
scaleGesture = (TextView)findViewById(R.id.ScaleGesture);
myImageView = (ImageView)findViewById(R.id.imageview);
bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
bmpWidth = bitmap.getWidth();
bmpHeight = bitmap.getHeight();
drawMatrix();
scaleGestureDetector = new ScaleGestureDetector(this, new simpleOnScaleGestureListener());
}
private void drawMatrix(){
curScale = ((curScale - 1) * 10) + 1;
if (curScale < 0.1){
curScale = 0.1f;
}
Bitmap resizedBitmap;
int newHeight = (int) (bmpHeight * curScale);
int newWidth = (int) (bmpWidth * curScale);
resizedBitmap = Bitmap.createScaledBitmap(bitmap, newWidth, newHeight, false);
myImageView.setImageBitmap(resizedBitmap);
}
@Override
public boolean onTouchEvent(MotionEvent event) {
// TODO Auto-generated method stub
scaleGestureDetector.onTouchEvent(event);
return true;
}
public class simpleOnScaleGestureListener extends SimpleOnScaleGestureListener {
@Override
public boolean onScale(ScaleGestureDetector detector) {
// TODO Auto-generated method stub
curScale = detector.getScaleFactor();
scaleGesture.setText(String.valueOf(curScale));
drawMatrix();
return true;
}
@Override
public boolean onScaleBegin(ScaleGestureDetector detector) {
// TODO Auto-generated method stub
return true;
}
@Override
public void onScaleEnd(ScaleGestureDetector detector) {
// TODO Auto-generated method stub
super.onScaleEnd(detector);
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />
<TextView
android:id="@+id/ScaleGesture"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<ImageView
android:id="@+id/imageview"
android:layout_gravity="center"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="center" />
</LinearLayout>
Download the files.
Related article:
- Implement Pinch Zoom in OnTouchListener
Wednesday, 23 November 2011
Set Up Apache Web Server on OS X Lion
This post documents the steps for setting up Apache on OS X Lion. Now the way I setup the server is a little different, but I will try to explain why.
- Start Apache Web Server
- Choose System Preferences in the Dock.
- Under Internet and Wireles and choose Sharing.
- Check Web Sharing.
Apache should start up. If it does not, see the Troubleshooting section.
- Uncheck Web Sharing. This stops the Apache server. The server should be stopped so changes can be made to the directory structure.
- Set up the Apache home directory.
The Apache home directory is located at /Library/WebServer/Documents. Of course you can set up your website and do your development there. However, if you perform an
ls -l
on the directory you will see the permissions set to 755 with user ofroot
and a group ofwheel
. So effectively, you have no access to the directory. So you can either make files as root, or add yourself to thewheel
group. Neither is very convenient, so this is the approach I take.- Open a terminal window
- Switch to the root user:
sudo bash
- In your home directory, create a directory to hold your web pages (e.g., www). Note that the permissions will be set to 775 with a user of
root
and a group ofstaff
. Since you are a member of the staff group by default, you have read and execute rights to the directory. - Add write permissions to the directory:
chmod 775 www
. Now this directory can be edited by both the web server and by you. Now we can have the web server point at this directory as its document directory. - Change to web server directory:
cd /Library/WebServer
- Rename the Documents directory:
mv Documents Documents.bk
- Link to the directory our created:
ln -s ~/www Documents
- Type
exit
to exit from your root shell.
- Now enable PHP
- Open a terminal window
- Switch to the root user:
sudo bash
- Change to the configuration directory:
cd /etc/apache2
- Change the permissions so you can edit the configuration directory:
chmod 744 httpd.conf
- Edit the file with your editor of choice.
vi httpd.conf
. Note: If you do not know how to usevi
, learning it is highly recommended as it is almost always available on Unix based systems. - Uncomment this line:
LoadModule php5_module libexec/apache2/libphp5.so
- Restart the Web Server
This should setup the server to work with PHP and allows you to easily edit and manipulate files.
Troubleshooting Tips
Problem: Apache will not start after upgrading from OS X Snow Leopard to Lion
Solution: The first thing to do is find out what error messages are being generated by Apache when it starts. This can be found in the Console application found in the Applications > Utilities > Console. This should list the error messages generated. In my case, the errors were related to directives in the Apache configuration file located at /etc/apache2/httpd.conf. Just commenting out the specific lines indicated in the console solved the startup problems for me.
Detect pinch zoom using ScaleGestureDetector
package com.exercise.AndroidScaleGestureDetector;
import android.app.Activity;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.ScaleGestureDetector;
import android.view.ScaleGestureDetector.SimpleOnScaleGestureListener;
import android.view.View;
import android.widget.TextView;
public class AndroidScaleGestureDetectorActivity extends Activity {
TextView scaleGesture;
ScaleGestureDetector scaleGestureDetector;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
scaleGesture = (TextView)findViewById(R.id.ScaleGesture);
scaleGestureDetector = new ScaleGestureDetector(this, new simpleOnScaleGestureListener());
}
@Override
public boolean onTouchEvent(MotionEvent event) {
// TODO Auto-generated method stub
scaleGestureDetector.onTouchEvent(event);
return true;
}
public class simpleOnScaleGestureListener extends
SimpleOnScaleGestureListener {
@Override
public boolean onScale(ScaleGestureDetector detector) {
// TODO Auto-generated method stub
scaleGesture.setText(String.valueOf(detector.getScaleFactor()));
return true;
}
@Override
public boolean onScaleBegin(ScaleGestureDetector detector) {
// TODO Auto-generated method stub
scaleGesture.setVisibility(View.VISIBLE);
return true;
}
@Override
public void onScaleEnd(ScaleGestureDetector detector) {
// TODO Auto-generated method stub
scaleGesture.setVisibility(View.INVISIBLE);
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />
<TextView
android:id="@+id/ScaleGesture"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
Download the files.
next:
- Scale bitmap according to ScaleGestureDetector
Tuesday, 22 November 2011
Beginning Building Mobile Application Development in the Cloud
Learn to build mobile apps on the major cloud platforms
Serving as a practical guide for building mobile apps and cloud services, this book is essential reading for web developers eager to create cross-platform applications for mobile devices that are supported by the power of cloud-based services such as Amazon Web Services. Author Richard Rodger walks you through building your first app with HTML5, setting it up in the cloud, and working with cloud databases. Packed with examples that show you how to build complete apps, this book elevates your already-existing skills while also acting as a stepping stone for making the leap into mobile and cloud development.
Beginning Mobile Application Development in the Cloud:
Demonstrates how to get the right look and feel for your mobile apps
Highlights ways to enhance the user experience
Addresses app caching, touch events, and data storage
Details ways to create hybrid apps that run natively
Looks at how best to use JSON, REST, Oauth, jQuery, AJAX, and more
Shares insight as to how the Apple App Store and the Android Marketplace work
Offers advice for marketing, advertising, and selling your apps
Monday, 21 November 2011
MacLife: Apple MD - Troubleshooting your Mac and iOS Apps
Here are the best ones I could find:
- How to Diagnose Mac Problems | Mac|Life
- How to Reset iOS Apps | Mac|Life
- Why's My Mac Slow? | Mac|Life
- How to Boot Your Mac in Safe Mode | Mac|Life
- How to Fix Your Fonts | Mac|Life
- How to Recover Your Passwords | Mac|Life
- How to Sweep Your Drive Clean with Software | Mac|Life
I highly recommend a subscription.
Saturday, 19 November 2011
Dolphin Browser for iPad and iPhone
Definitely worth a look. Check it out here.
Toshiba Satellite L745 S4310 Laptop Review, Specs and Price
- Processor : Intel� Core� i3-2330M processor
- Operating System : Genuine Windows 7 Home Premium (64-bit)*
- Graphics Engine : Mobile Intel� HD Graphics
- Graphics Memory : 64MB-1696MB dynamically allocated shared graphics memory
- Memory : 4GB DDR3 1333MHz memory
- Hard Drive : 500GB HDD (5400rpm)
- Optical Drive : DVD-SuperMulti drive (+/-R double layer)
- Display Size : 14.0" widescreen
- Display Type : HD TruBrite� LED Backlit display
- Display Resolution : Supports 720p content, 1366x768 (HD), 16:9 aspect ratio
- Audio : Microphone jack (mono), MaxxAudio� LE, Standard stereo speakers, Headphone jack (stereo)
- Webcam : Webcam and microphone built into LCD bezel
- Wireless LAN : Wi-Fi� Wireless networking (802.11b/g/n)
- Bluetooth : Bluetooth� V3.0 + HS
- Modem : No Modem port
- LAN : 10/100 Ethernet LAN
- AC Adapter : 65W (19V 3.42A) Auto-sensing, 100-240V / 50-60Hz input
- Battery : Li-Ion (48Wh, 6-Cell)
- Battery Life : Up to 5.85 hours
- PC Express Slot : No PC Express Slot
- SmartCard Reader : No SmartCard Reader slot
- Media : Memory Card Reader
- USB Ports : 2-USB (2.0) ports, 1-USB (2.0) port with Sleep and Charge*
- HDMI : HDMI output port
- Inputs and Controls : Touch pad pointing device with multi touch control, Premium US keyboard (Black)
- Weight : Starting at 4.98 lbs.
- Color : Fusion� Finish in Matrix Graphite
Thursday, 17 November 2011
Detect swipe using SimpleOnGestureListener
package com.exercise.AndroidSimpleGesture;
import android.app.Activity;
import android.os.Bundle;
import android.view.GestureDetector;
import android.view.GestureDetector.SimpleOnGestureListener;
import android.view.MotionEvent;
import android.widget.TextView;
public class AndroidSimpleGestureActivity extends Activity {
TextView gestureEvent;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
gestureEvent = (TextView)findViewById(R.id.GestureEvent);
}
@Override
public boolean onTouchEvent(MotionEvent event) {
// TODO Auto-generated method stub
return gestureDetector.onTouchEvent(event);
}
SimpleOnGestureListener simpleOnGestureListener
= new SimpleOnGestureListener(){
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
float velocityY) {
String swipe = "";
float sensitvity = 50;
// TODO Auto-generated method stub
if((e1.getX() - e2.getX()) > sensitvity){
swipe += "Swipe Left\n";
}else if((e2.getX() - e1.getX()) > sensitvity){
swipe += "Swipe Right\n";
}else{
swipe += "\n";
}
if((e1.getY() - e2.getY()) > sensitvity){
swipe += "Swipe Up\n";
}else if((e2.getY() - e1.getY()) > sensitvity){
swipe += "Swipe Down\n";
}else{
swipe += "\n";
}
gestureEvent.setText(swipe);
return super.onFling(e1, e2, velocityX, velocityY);
}
};
GestureDetector gestureDetector
= new GestureDetector(simpleOnGestureListener);
}
Download the files.
Toshiba Portege Z830-S8302 Laptop Review, Specs and Price
Toshiba Portege Z830-S8302 Entertainment Laptops Specification :
Performance
- Processor : Intel� Core� i7-2677M processor
- Operating System : Genuine Windows� 7 Professional 64-bit, SP1
- Genuine Windows� 7 Professional 32-bit, SP1
- Graphics Engine : Mobile Intel� HD Graphics
- Graphics Memory : 64MB-1696MB dynamically allocated shared graphics emory
- Memory : 6GB DDR3 1333MHz memory
- Hard Drive : 128GB Solid State Drive (Serial ATA, SSD)*
- Optical Drive : Sold Separately: Toshiba USB Portable DVD SuperMulti Drive
- Display Size : 13.3" widescreen
- Display Type : HD TFT LED Backlit display with Intel� Wireless Display Technology
- Display Resolution : 1366x768 (HD), 16:9 aspect ratio, Supports 720p content
- Audio : Waves MaxxAudio� 3, Standard stereo speakers, Microphone jack (mono), Headphone jack (stereo)
- Webcam : 1.3 MP Webcam and microphone
- Wireless LAN : Intel� Centrino� Advanced-N 6230 (802.11a/g/n + WiDi Capable)
- Bluetooth : Bluetooth� V3.0 + EDR
- Modem : No Modem port
- LAN : Intel� 82579LM Gigabit Network Connection
- AC Adapter : 45W (19V 2.37A) Auto-sensing, 100-240V / 50-60Hz input
- Battery : Li-Ion (47Wh, 8-Cell)
- Battery Life : Up to 8.28 hours
- PC Express Slot : No PC Express Slot
- SmartCard Reader : No SmartCard Reader slot
- Media : Memory Card Reader
- USB Ports : 1-USB (2.0) port, 1-USB (3.0) port*, 1-USB (2.0) port with Sleep and Charge
- HDMI : HDMI� output port
- Inputs and Controls :
- TOSHIBA eco utility� (Energy-saving mode), Premium Spill-resistant Raised Tile Backlit Keyboard (black), Touch pad pointing device with multi touch control, Touch pad on/off, Presentation Button
- Weight : Starting at 2.47 lbs.
- Color : Ultimate Silver
Using GestureDetector with SimpleOnGestureListener
package com.exercise.AndroidSimpleGesture;
import android.app.Activity;
import android.os.Bundle;
import android.view.GestureDetector;
import android.view.GestureDetector.SimpleOnGestureListener;
import android.view.MotionEvent;
import android.widget.TextView;
public class AndroidSimpleGestureActivity extends Activity {
TextView gestureEvent;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
gestureEvent = (TextView)findViewById(R.id.GestureEvent);
}
@Override
public boolean onTouchEvent(MotionEvent event) {
// TODO Auto-generated method stub
return gestureDetector.onTouchEvent(event);
}
SimpleOnGestureListener simpleOnGestureListener
= new SimpleOnGestureListener(){
@Override
public boolean onDoubleTap(MotionEvent e) {
// TODO Auto-generated method stub
gestureEvent.setText("onDoubleTap: \n" + e.toString());
return super.onDoubleTap(e);
}
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
float velocityY) {
// TODO Auto-generated method stub
gestureEvent.setText("onFling: \n" + e1.toString() + "\n" + e2.toString() +"\n"
+ "velocityX= " + String.valueOf(velocityX) + "\n"
+ "velocityY= " + String.valueOf(velocityY) + "\n");
return super.onFling(e1, e2, velocityX, velocityY);
}
@Override
public void onLongPress(MotionEvent e) {
// TODO Auto-generated method stub
gestureEvent.setText("onLongPress: \n" + e.toString());
super.onLongPress(e);
}
@Override
public boolean onSingleTapConfirmed(MotionEvent e) {
// TODO Auto-generated method stub
gestureEvent.setText("onSingleTapConfirmed: \n" + e.toString());
return super.onSingleTapConfirmed(e);
}
};
GestureDetector gestureDetector
= new GestureDetector(simpleOnGestureListener);
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />
<TextView
android:id="@+id/GestureEvent"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
Download the files.
next:
- Detect swipe using SimpleOnGestureListener
Wednesday, 16 November 2011
App Inventor for Android: Build Your Own Apps - No Experience Required!
Create Android mobile apps, no programming required!
Even with limited programming experience, you can easily learn to create apps for the Android platform with this complete guide to App Inventor for Android. App Inventor for Android is a visual language that relies on simple programming blocks that users can drag and drop to create apps. This handy book gives you a series of fully worked-out apps, complete with their programming blocks, which you can customize for your own use or use as a starting point for creating the next killer app. And it's all without writing a single line of code. Don't miss the book's special section on Apps Inventor Design Patterns, which explains computer terms in simple terms and is an invaluable basic reference.
- Teaches programmers and non-programmers alike how to use App Inventor for Android to create Android apps
- Provides a series of fully worked-out apps that you can customize, download, and use on your Android phone or use as a starting point for building the next great app
- Includes a valuable reference section on App Inventor Design Patterns and general computer science concepts
- Shows you how to create apps that take advantage of the Android smartphone?s handy features, such as GPS, messaging, contacts, and more
With App Inventor for Android and this complete guide, you'll soon be creating apps that incorporate all of the Android smartphone's fun features, such as the accelerometer, GPS, messaging, and more.
Tuesday, 15 November 2011
Tentative iOS 5.0.1 Support
As soon as more information is available I will update.
Monday, 14 November 2011
Microsoft not Apple Killing Flash
A quick Google search confirmed this:
Microsoft revealed this week that Internet Explorer 10 Metro will not support browser based plug-ins.Full Story Here
�For the web to move forward and for consumers to get the most out of touch-first browsing, the Metro style browser in Windows 8 is as HTML5-only as possible, and plug-in free,� revealed Internet Explorer chief Dean Hachamovitch, in a blog post earlier this week. Microsoft is removing the ability to use plug-ins on the Metro style IE version of Windows 8 to improve security, reliability and battery life for end users. �Plug-ins were important early on in the web�s history,� admits Hachamovitch. �The web has come a long way since then with HTML5.�
Although I do find it hard to believe there will be no plug-in or add on capability in Internet Explorer. It looks like Flash really is gonna be dead soon. The times are changing fast.
Saturday, 12 November 2011
NDK updated for Android 4.0
details: Updated NDK for Android 4.0
Friday, 11 November 2011
How do I update my iPhone/iPad to iOS 5 without Syncing?
To update your device do the following:
- Click Settings
- Click General
- Click Software Update
HP Pavilion DV7 6101sa Entertaiment Laptop Review, Spec and Price
- Operating System : Windows 7 Home Premium Edition 64-bit
- Display Screen : 17.3" (HP BrightView, LED High Definition 1600x900 Resolution)
- Processor : AMD A4-3310MX Dual Core (2.1GHz, 2MB Cache, Up to 2.5GHz in Boost Mode)
- Memory : RAM 6GB (DDR3)
- Hard Drive : 1000GB (2 x 500GB HDD)
- Optical Drive : DVD Rewriter (Records DVDs 8x & CDs 24x & Dual Layer Super Multi)
- Graphics : Dedicated (AMD Radeon HD 6515G2 Dual GPU with 512MB Dedicated Memory)
- Wireless LAN : Wireless (802.11b/g/n Wireless)
- Network Card : 10/100/1000 Gigabit Fast Ethernet
- Integrated Webcam : Integrated Webcam with Microphone
- Card Reader : 2-in-1 card reader ( SD, MMC )
- Speakers : Integrated Beats Sound System with Integrated Subwoofer
- Interfaces : - 1 x VGA
- Warranty : 2 Month Warranty (Also use for Consumer Compaq's)
- Dimensions : (W) 41.6 cm x (D) 27.5 cm x (H) 3.6 cm
- Battery : Life 3-4 Hours (up to 4 hours with power management)
- Weight : 3-4 Kg (This Model 3.01 Kg)
- 1 x HDM
- 2 x headphone-out
- 1 x microphone-in
- 2 x USB 2.0
- 2 x USB 3.0
- 1 x RJ45
Wednesday, 9 November 2011
Ding dong Flash is Dead?
Flash: Crippled but alive...for now
Although Steve Jobs is no longer with us, his will is done. He stated early on that Flash wasn't a good fit for mobile devices and Apple would focus on HTML5. As of today, Adobe agrees with him. But don't make too big a deal out of this, Adobe will still support mobile apps using their Air platform. In addition, the story points out that most of us are still using PCs rather than iPhones or iPads.
Finally, in the end, Adobe is a tools vendor. Whether their tools target Flash or HTML5, they make money either way.
Tuesday, 8 November 2011
Cancel ProgressDialog
It's modified to be cancelable, such that user can cancel the waiting by BACK key. And a OnCancelListener is implemented to stop BackgroundThread. Also, a OnDismissListener is implemented. OnCancelListener will be called only when the dialog is canceled, if you needs to know when it is dismissed in general, use OnDismissListener.
package com.exercise.AndroidProgressDialog;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnCancelListener;
import android.content.DialogInterface.OnDismissListener;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.Window;
import android.widget.Toast;
public class AndroidProgressDialogActivity extends Activity {
ProgressDialog progressDialog;
BackgroundThread backgroundThread;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
setContentView(R.layout.main);
setProgressBarIndeterminateVisibility(true);
progressDialog = ProgressDialog.show(AndroidProgressDialogActivity.this,
"ProgressDialog", "Wait!");
backgroundThread = new BackgroundThread();
backgroundThread.setRunning(true);
backgroundThread.start();
progressDialog.setCancelable(true);
progressDialog.setOnCancelListener(new OnCancelListener(){
public void onCancel(DialogInterface dialog) {
// TODO Auto-generated method stub
backgroundThread.setRunning(false);
Toast.makeText(AndroidProgressDialogActivity.this,
"ProgressDialog Cancelled!",
Toast.LENGTH_LONG).show();
}});
progressDialog.setOnDismissListener(new OnDismissListener(){
public void onDismiss(DialogInterface dialog) {
// TODO Auto-generated method stub
Toast.makeText(AndroidProgressDialogActivity.this,
"ProgressDialog Dismissed!",
Toast.LENGTH_LONG).show();
}});
}
public class BackgroundThread extends Thread{
volatile boolean running = false;
int cnt;
void setRunning(boolean b){
running = b;
cnt = 10;
}
@Override
public void run() {
// TODO Auto-generated method stub
while(running){
try {
sleep(1000);
if(cnt-- == 0){
running = false;
}
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
handler.sendMessage(handler.obtainMessage());
}
}
Handler handler = new Handler(){
@Override
public void handleMessage(Message msg) {
// TODO Auto-generated method stub
setProgressBarIndeterminateVisibility(false);
progressDialog.dismiss();
boolean retry = true;
while(retry){
try {
backgroundThread.join();
retry = false;
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Toast.makeText(AndroidProgressDialogActivity.this,
"dismissed", Toast.LENGTH_LONG).show();
}
};
}
Dell Inspiron 15N 2657OBK Cheap Laptop Review, Specs and Price
Dell Inspiron 15N-2657OBK Laptops Specification :
- 15.6-inch LED high-definition display
- Powered by a 2.53GHz Intel Core i3-380M processor, 3MB cache
- 4GB DDR3 memory, expandable up to 8GB
- 500GB Serial ATA hard drive (5400 rpm)
- Intel HD graphics
- Multiformat DVD�RW/CD-RW drive with double-layer support
- Built-in 0.3 megapixel webcam
- 3-in-1 media reader
- Three high-speed USB 2.0 ports
- Built-in Dell Wireless 1502 WLAN (802.11n)
- Built-in 100/1000 Gigabit Ethernet LAN
- With TrueLife technology and 720p resolution
- Microsoft Windows 7 Home Premium 64-bit operating system
Price Range : $399.99
HP Pavilion dv6 6b00 Amazing Laptops Review, Specs and Price
This HP Pavilion dv6-6b00 will begin delivery at the begining of December for a starting selling price of 43,050 Yen or around $550.HP Pavilion dv6-6b00 15.6 Inch Laptops Specification :
- Display : 15.6" Full HD Anti-glare LED Display (1920 x 1080)
- Processors : 2.4 GHz Intel� Core� i7-2760QM
- Chipset : Intel HM65 Express
- Hard drive : 1 TB SATA (5400 rpm)
- Optical drive : Blu-ray �R/RW with SuperMulti DVD�R/RW Double Layer
- Graphics : AMD Radeon HD 6770M (2 GB GDDR5 dedicated)
- Ports :
- 1 VGA
- 1 RJ45
- 1 HDMI
- 1 microphone-in
- 2 headphone-out
- 2 USB 2.0
- 2 USB 3.0- Slots : Multi-Format Digital Media Card Reader for Secure Digital cards, Multimedia cards
- Webcam : HP TrueVision HD Webcam with Integrated Digital Microphone (High Definition low-light)
- Audio features : Internal Speakers and Audio playback with Beats Audio
- Networking : Integrated 10/100/1000 Gigabit Ethernet LAN
- Wireless : 802.11 b/g/n Bluetooth
- Dimensions (W x D x H) : 37.8 x 24.68 x 3.52 cm
- Weight : Starting at 2.63 kg
- Warranty : 1 year, parts and labour
Monday, 7 November 2011
More on onSaveInstanceState() and onRestoreInstanceState()
package com.exercise.AndroidSaveState;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class AndroidSaveStateActivity extends Activity {
TextView textOnPause;
TextView textOnResume;
TextView textOnRestoreInstanceState;
TextView textOnSaveInstanceState;
int cntOnPause;
int cntOnResume;
int cntOnRestoreInstanceState;
int cntOnSaveInstanceState;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
textOnPause = (TextView)findViewById(R.id.onPause);
textOnResume = (TextView)findViewById(R.id.onResume);
textOnRestoreInstanceState = (TextView)findViewById(R.id.onRestoreInstanceState);
textOnSaveInstanceState = (TextView)findViewById(R.id.onSaveInstanceState);
}
@Override
protected void onPause() {
// TODO Auto-generated method stub
cntOnPause++;
super.onPause();
}
@Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
cntOnResume++;
textOnPause.setText("cntOnPause: " + String.valueOf(cntOnPause));
textOnResume.setText("cntOnResume: " + String.valueOf(cntOnResume));
textOnRestoreInstanceState.setText("cntOnRestoreInstanceState: " + String.valueOf(cntOnRestoreInstanceState));
textOnSaveInstanceState.setText("cntOnSaveInstanceState: " + String.valueOf(cntOnSaveInstanceState));
}
@Override
protected void onSaveInstanceState(Bundle outState) {
// TODO Auto-generated method stub
cntOnSaveInstanceState++;
outState.putInt("CNT_OnPause", cntOnPause);
outState.putInt("CNT_OnResume", cntOnResume);
outState.putInt("CNT_OnRestoreInstanceState", cntOnRestoreInstanceState);
outState.putInt("CNT_OnSaveInstanceState", cntOnSaveInstanceState);
super.onSaveInstanceState(outState);
}
@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
// TODO Auto-generated method stub
if (savedInstanceState != null){
if(savedInstanceState.containsKey("CNT_OnPause")){
cntOnPause = savedInstanceState.getInt("CNT_OnPause");
}
if(savedInstanceState.containsKey("CNT_OnResume")){
cntOnResume = savedInstanceState.getInt("CNT_OnResume");
}
if(savedInstanceState.containsKey("CNT_OnRestoreInstanceState")){
cntOnRestoreInstanceState = savedInstanceState.getInt("CNT_OnRestoreInstanceState");
}
if(savedInstanceState.containsKey("CNT_OnSaveInstanceState")){
cntOnSaveInstanceState = savedInstanceState.getInt("CNT_OnSaveInstanceState");
}
}
cntOnRestoreInstanceState++;
super.onRestoreInstanceState(savedInstanceState);
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />
<TextView
android:id="@+id/onPause"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/onResume"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/onRestoreInstanceState"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/onSaveInstanceState"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
Asus U24E 11.6 Inch Notebooks Review, Specs and Price
- Display : 11.6-inch 1366 x 768 (most likely glossy)
- Processor : Core i5-2430M processor + Intel HD 3000 gfx
- Webcam : 0.3 MP VGA
- Memory : 4GB DDR3 at 1333 MHz
- Graphic system : 750 GB HDD
- Operating System : Windows 7 Home Premium 64-bit
- Ports: -1 x USB2.0,
- Wi-Fi: 802.11 b/g/n
- Bluetooth: 3.0 + HS
- Battery: 6 cell, 6.8 hours
- Dimension : 11.46 (W) x 8.15 (D) x 1.09 (H) inches
- weight : 1.5 kg / 3.31 pounds
-2 x USB3.0,
-1 x Ethernet,
-1 x VGA,
-1 x HDMI,
-1 x 3.5mm headphone jack
Sunday, 6 November 2011
HTML5 and LocalStorage
Free Tutorials
Found a couple of free tutorials.
HTML5 Offline Application Cache
Dive in Javascript: Simple Address Book App
PaperKilledRock: HTML5 LocalStorage
Library
Of course, with new features like this, new libraries are always welcome. I have not tried this yet, but I intend to.
JStorage
Books
Finally, we have a book by one of the folks working on the spec.
Friday, 4 November 2011
Gigabyte released P2532F and P2532H Laptops Review 2011
Price about : [ not available ]