Archive

Tag Archives: iphone

Thank you for checking out this tutorial. Reading the discussions in this post, seems like there is quite a number of people having troubles to take screenshots with Galaxy S2. To clear any confusions, I summarized some information and added as followings. Hope you could make it too. Fingers crossed.

First, make sure your Galaxy S2 is running Android version 4 or above.

Volume Down + Power Key will work fine.
Press both keys at the same time gently. In about 1 second, screen capture would be done. A notification and an animation would be shown too.

Edited on 12 July.


Press and hold power and volume down button together. This is the way to take screenshot in the new Android system 4.0 Ice Cream Sandwich. After the Samsung Galaxy S2 updated to this new version, it uses this method instead of the way mentioned in my old post.

To begin with, we need to understand that in the HTTP protocol, browser send its identity called user agent to the server to request the wanted webpage. Every browser has its only unique user agent value, and therefore we can check that value to identify the user browser. So, first we have to take a look at some examples of user agents of mobile devices.

iPhone user agent

Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A543a Safari/419.3

iPod Touch user agent

Mozilla/5.0 (iPod; U; CPU like Mac OS X; en) AppleWebKit/420.1 (KHTML, like Gecko) Version/3.0 Mobile/3A101a Safari/419.3

iPad user agent

Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.10

Android user agent

Mozilla/5.0 (Linux; U; Android 1.1; en-gb; dream) AppleWebKit/525.10+ (KHTML, like Gecko) Version/3.0.4 Mobile Safari/523.12.2
Mozilla/5.0 (Linux; U; Android 2.1; en-us; Nexus One Build/ERD62) AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 Mobile Safari/530.17

BlackBerry user agent

BlackBerry9000/4.6.0.266 Profile/MIDP-2.0 Configuration/CLDC-1.1 VendorID/120

After all, in programming, we gather these data to do the checking. First in JavaScript:

if (/(iPhone|iPod|iPad)/.test(navigator.userAgent)) {
    /* This is iOS */
}
if (/Android/.test(navigator.userAgent)) {
    /* This is Android */
}
if (/BlackBerry)/.test(navigator.userAgent)) {
    /* This is BlackBerry */
}
if (/(iPhone|iPod|iPad|BlackBerry|Android)/.test(navigator.userAgent)) {
    /* This is one of the mentioned mobile device browsers */
}

And this is how it works in PHP:

if (preg_match('/iPhone|iPod|iPad/', $_SERVER['HTTP_USER_AGENT'])) {
    /* This is iOS */
}
if (preg_match('/Android/', $_SERVER['HTTP_USER_AGENT'])) {
    /* This is Android */
}
if (preg_match('/BlackBerry/', $_SERVER['HTTP_USER_AGENT'])) {
    /* This is BlackBerry */
}
if (preg_match('/iPhone|iPod|iPad|BlackBerry|Android/', $_SERVER['HTTP_USER_AGENT'])) {
    /* This is one of the mentioned mobile device browsers */
}

Ssh is a very convenient way to remotely command or control other devices. We use ssh to push commits to git server, to access remote server, and even to manipulate the content of our iphones and ipads. However it’s usually distributing to type your long and elusive password every time. Therefore here I would like introduce a way to create a steady relationship between your computer and the remote server you wanna connect with.

The principle is this, ssh connection establishments requires verification using the computer unique key of both devices. in order to simplify this step, we can generate a public key of your computer in advanced and which allows other to identify you. While you put that public key in the remote device as authorized key, you can kinda fast forward the process.

step 1: open terminal and “ssh-keygen -t dsa”
step 2: open “.ssh/id_dsa.pub” and copy content inside
step 3: open new tab in terminal and ssh server
step 4: paste all content into /home//.ssh/authorized_keys

a@A:~> ssh-keygen -t rsa
a@A:~> ssh b@B mkdir -p .ssh
a@A:~> cat .ssh/id_rsa.pub | ssh b@B ‘cat >> .ssh/authorized_keys’

I have been working with Cocos2D for a while and I am still a newbie. The way to deal with animations in Cocos2D 1.0.0 – the stable version currently – is different from the way before using CCSpriteSheet. Now Cocos2D adapts animations as cache shared in the project using CCSpriteFrameCache. It also requires a plist file as well as a texture file.

First, put the following assets into the project “Resources” folder to let the program use.

  • grossini.plist – The file contain the animation information such as frame details.
  • grossini.pvr.gz – The texture file in pvr format which allow better performance in Cocos2D.

Second, add the following codes into the function init. Take a look at the comments for program explanation. =]

// Capture the window size
CGSize size = [[CCDirector sharedDirector] winSize];

// Load the plist into the cache
CCSpriteFrameCache *cache = [CCSpriteFrameCache sharedSpriteFrameCache];
[cache addSpriteFramesWithFile:@"grossini.plist"];

// Create sprite with the first frame
CCSprite *sprite = [CCSprite spriteWithSpriteFrameName:@"grossini_dance_01.png"];
sprite.position = ccp( size.width/2, size.height/2);
sprite.anchorPoint = ccp(0.5f, 0.5f);

// Create array for the animation frames
NSMutableArray *animFrames = [NSMutableArray array];
for(int i = 0; i < 14; i++) {
    CCSpriteFrame *frame = [cache spriteFrameByName:[NSString stringWithFormat:@"grossini_dance_%02d.png",(i+1)]];
    [animFrames addObject:frame];
}

// Convert the array into animation
CCAnimation *animation = [CCAnimation animationWithFrames:animFrames];

// Run the sprite with the created animation and display it by adding it to the scene
[sprite runAction:[CCRepeatForever actionWithAction: [CCAnimate actionWithDuration:2.8f animation:animation restoreOriginalFrame:NO] ]];
[self addChild:sprite z:0];

After all, don’t forget to deallocate the resources loaded in cache in function dealloc.

// Deallocate the resource in cache
CCSpriteFrameCache *cache = [CCSpriteFrameCache sharedSpriteFrameCache];
[cache removeSpriteFramesFromFile:@"animations/grossini.plist"];

Finally, this is a screenshot. Enjoy. XD

Press and hold home and tap the power button. This is the magic key for Samsung Galaxy S2 to take a screenshot. It has been such a good news for users like me who used to use iPhone. Somehow it is just the same as the iPhone setting. Actually some of the recent released mobile phone adapt this feature too, including Samsung Galaxy S2, LG Optimus 2X, LG Optimus 3D, HTC Cha Cha. Enjoy!

Open default.smurfmap with Hex Editor from your Documents. Edit it according to the screenshot. PS. This is only for version 1.0.0.

It comes finally. I have been hearing friends have their Hotmail upgraded for a long time. However, I was disappointed every time when I log in. But I would be more appreciated if they offer IMAP or MS Exchange that allowing people access their mailbox any other software like Apple Mail or iPhone.

%d bloggers like this: