10 Billion Android Downloads and Counting

Google is celebrating 10 billion app downloads from android market this week with a pretty amazing promotion: they are selling 10 different premium apps for 10 cents each. There are 10 new apps each day. I apready picekd up two today, including Minecraft portable, usually $6.99!

Check it out yourself.

Posted in News | Tagged | Leave a comment

Android: Clearing The Android Activity Stack

Activty Flow

Click to Enlarge

I was building my first real android app for a client and had a situation in which I did not want the back button to take you back to the immediate last step. The app starts with the user entering information, a list of names in this case, and then clicking start. Once you click start, it would be impossible for the app to go back and make changes, so I wanted to make sure that clicking back after that just took you to the splash page. But the default android behavior is to go back to the last activity used.

It was tricky to figure out how to get this to do what I wanted. There are a lot of very smart ways to manage the Activity Stack and Tasks. But it turns out, no way to clear all the items in the history list except for the first. To make it happen you have to override the onBackPressed() method of the activty you are launching. That way intead of going back to the last Activity in the history stack, that screen creates an Intent to go back to the home screen.

The code to do that is really simple. The activity stack is not cleared, but by calling this, you essentially achieve the same thing. The history contains a loop now. And the intervening screens can no longer be reached by the back button.

	@Override
	public void onBackPressed() {
		// TODO Auto-generated method stub
		//super.onBackPressed();
		startActivity(new Intent(this, HomeScreenActivity.class));
	}
Posted in Code Snippets, Tutorials | Tagged , , , , , | Leave a comment

Worst Episode Ever…

Did you attend Adobe Max 2011 this year? Well, let’s hope not. It was without a doubt the worst conference I ever attended. Maybe there was some great stuff if you were a photoshop user. But if you’re a flash developer there was one clear message from Adobe: Capitulation.

In the big kerfluffle between Adobe and Apple, it would appear that Adobe has hoisted the white flag, and wants us to all just move on to HTML5.
And I’m not the only one who was surprised to see Adobe have nothing to offer to flash developers but excuses and broken promises.
One of my favorite flash bloggers, John Lindquist also noticed that all was not well in the house of Adobe.
Were you at MAX? Tell me what you thought in the comments.

Posted in News, Opinion | 1 Comment

Making A Like-Gate For A Facebook Fan Page

Want to know how to make a fan page tab that shows one thing to users who like the page, and something different to those who do not? This is called a “like gate” and is pretty easy to implement using PHP on the server side to do the hard part. Be sure to download a copy of the facebook PHP SDK. The file is required by the script below.

*Update* Source is now avaiable from github.

First, create a new facebook app. You will need the appID and App Secret to customize the code below.

Then make a fan page. Add you app to the fan page. You can do this by navigating the the application description page and clicking “Add to my page”. A list of pages owned by you will show up. Click the page you want to add the app to.

Now the app is in a tab. Copy that url. You’ll need that too. That will be your $loginNextPage – the page the user will be directed to after clicking like – which we want to be our tab again.

Finally, use the code below to detect whether the user likes the fan page or not.

<?php
 
require 'facebook.php';
 
$app_id = "YOUR APP ID";
$app_secret = "YOUR APP SECRET";
 
$loginNextPage = 'PATH TO YOUR FAN PAGE ON FACEBOOK'.'?sk=app_'.$app_id;
 
$facebook = new Facebook(array(
        'appId' => $app_id,
        'secret' => $app_secret,
        'cookie' => true
));
 
$signed_request = $facebook->getSignedRequest();
 
$like_status = $signed_request["page"]["liked"];
 
 
if ($like_status) {
	// FOR FANS
	$session = $facebook->getSession();
    $loginUrl = $facebook->getLoginUrl(
            array(
            'canvas'    => 1,
            'fbconnect' => 0,
			'next' => $loginNextPage
            /*'req_perms' => 'publish_stream,photo_upload,user_photos,user_photo_video_tags'			*/
            )
    );
 
    $fbme = null;
 
	if (!$session) {
		echo "<script type='text/javascript'>top.location.href = '$loginUrl';</script>";	
        exit;	
	}
	else {
 
		try {
            $access_token = $facebook->getAccessToken();
			$vars = "access_token=$access_token&pathToServer=$pathToServer&appName=$appName";
        } catch (FacebookApiException $e) {
            echo "<script type='text/javascript'>top.location.href = '$loginUrl';</script>";
            exit;
        }
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">	
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">
<head>
</head>
 <body>
 <h1>You Liked The Page</h1>
</body>
</html>
<?php
	}	
}
else {
	// FOR NON FANS	
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">	
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">
<head>
  </head>
  <body>
  <h1>You Don't Like the Page</h1>
	</body>
</html>
<?php
 
}
 
?>
Posted in Tutorials | 11 Comments

Flash 11 Out October 4, And A really cool Stage 3D API to make it work!

Starling Framework Particles

Adobe is set to release FLash 11 and AIR 3 during the upcoming adobe max event. And just in time for that release comes the Starling Framework. This is the framework I have been dreaming of – one that extends all our familiar display list API calls and lays it on top of blazing fast Stage3d graphics.

I am finally, excited about Adobe Max. Its like waiting for christmas!

Posted in Tutorials | 1 Comment