TALKING ANDROID

Android Development and talk

Hour 2 – Understanding an Android Activity

with 2 comments

This is a correction to the code in Hour 2.

In Listing 2.12, we handle the result from a call to startActivityForResult().
The idea is that one Activity will handle data entered in a second Activity.

To show this, the code updates a TextView in the initial Activity.  Unfortunately, when I transcribed the code for the book I left out the initialization of that TextView.  The error is also in the code for download.  There were great tech reviewer and editors on this book.  This is my mistake and it will be corrected.

The required line that was dropped is:

      t = (TextView) findViewById (R.id.textView1);

package com.bffmedia.hour2app;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class ActivityA extends Activity {
	TextView t;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_a_layout);
        Button b =  (Button)findViewById(R.id.button1);
        t = (TextView) findViewById (R.id.textView1);
        b.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
            	Intent intent = new Intent(ActivityA.this, ActivityB.class);
            	intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_CLEAR_TOP);
                Bundle b = new Bundle();
            	b.putString("GREETING", "Hello");
            	intent.putExtra("BUNDLE", b);
            	intent.putExtra("STRING", "World!");
            	intent.putExtra("BOOLEAN", true);
            	intent.putExtra("INT", 5);
            	startActivity(intent);           	
            }
        });

        Button getData =  (Button)findViewById(R.id.button2);
        getData.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
            	Intent intent = new Intent(ActivityA.this, ActivityC.class);
            	startActivityForResult(intent, 0);           	
            }
        });

    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data ) {
    	if (requestCode == 0 && resultCode == Activity.RESULT_OK){
    		String enteredData = data.getStringExtra("Data");
    		t.setText(enteredData);
    	}
        super.onActivityResult(requestCode, resultCode, data);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.activity_layout, menu);
        return true;
    }

}

Written by Carmen Delessio

December 2, 2013 at 3:31 am

New Book: Android Application Development in 24 Hours

leave a comment »

All new 3rd Edition of “Teach Yourself Android Application Development in 24 Hours” is      now available.

Updates and corrections will be made on this site.  Feel free to contact me or post    comments.

Sample Chapter and Source code are available.

Read Full Sample Chapter:  Hour 21, Android Media Basics: Images, Audio, and Video

Download Source code

Find it on Amazon

 

The sample chapter covers images, audio, and video.  The section on ImageViews has a discussion of scaleType and included the following images.

Figure 21.1

Base image for showing ScaleType (scaletest.png)

 Figure 21.2 ScaleTypes CENTER, CENTER_CROP, and CENTER_INSIDE

Figure 21.2
ScaleTypes CENTER, CENTER_CROP, and CENTER_INSIDE

Written by Carmen Delessio

December 2, 2013 at 3:12 am

Second Screen Apps – Android Developer Meetup NYC

leave a comment »

Written by Carmen Delessio

March 15, 2013 at 3:54 am

Posted in Uncategorized

Google TV, Really?

leave a comment »

In the past few days, there have been several reports of Google opening retail stores. Every report says that they’ll sell Google TV’s in those stores. Is it a good time to start Google TV development? Yes, yes, I think so. Here are 3 quick reasons:

  1. Google TV is a software platform
  2. Google TV has a market for apps
  3. Google TV is a place to create 2nd Screen Apps – right now

In this article, I expand on these reasons and give a detailed example of creating a simple Flickr 2nd screen app using the Anymote protocol.

Why It’s Time to Start Developing Apps for Google TV

The example app shows recent Flickr Photo on your phone. When you select a photo, it is displayed on your Google TV.

screenshot

To learn more, check out the book.

Sams Teach Yourself Google TV App Development in 24 Hours

Written by Carmen Delessio

February 20, 2013 at 5:42 am

BFF Photo & Video (Kindle Fire Edition)

leave a comment »


Your Facebook Photo & Video App.

Available on Amazon

Get the app in Amazon App Store

Written by Carmen Delessio

January 3, 2012 at 2:27 pm

Posted in Uncategorized

Adding the Aviary Mobile SDK to an Android App

with one comment

Aviary has made it pretty darn easy to add advanced photo editing features to Android apps.  Their Embeddable Photo Editor for Mobile was released today with support for both iOS and Android.    Check the developer site.

We added the editor to the BFFPhoto app.  More about the app at BffMedia.com.

The Aviary library includes effects, rotating, cropping, ability to draw or write on photos, and … more.

At the end of this post is a series of images showing edits on a photo that include adding the IndiGlow effect and adding text.

The Aviary sample code and documentation is very good.  The sample app has a single activity that lets the user pick and edit a photo. Since that will be the basic flow for many apps, it is a great head start for adding the photo editor to your app.

I recommend following the documentation, but at a high-level, you will need to:

  1. Add the Aviary library
  2. Add the Aviary external jar files
  3. Update your manifest file to include the Aviary Feather activity
  4. Incorporate the editor into your app

To make this easy for developers, Aviary has created the editor as an Activity.  It is called by adding an intent with the FeatherActivity and invoking the activity using “startActivityForResult.”

startActivityForResult( newIntent, ACTION_REQUEST_FEATHER );

The ACTION_REQUEST_FEATHER is handled in your onActivityResult method.  Using the result from the intent, you can access the edited photo.

BFFPhoto is an app that uploads photos to Facebook.  I added photo editing as part of the upload flow.  A user picks a photo and has the option to edit it before uploading.  The app saves the edited photo before uploading.  When to save photos is something to think about when adding an editor.

In BffPhoto, I used the default themes, but it is easy to customize the look and feel of the editor using standard Android themes.

Overall, this is a great ANDROID implementation of photo editing and should be familiar to Android developers.

Enjoy adding the Aviary Editor to your apps!

Unedited Photo

Basic Editor

Choose IndiGlow

Choose Text Tool

Add Text

Final Edited Photo - Ready for upload

Written by Carmen Delessio

September 13, 2011 at 4:14 pm

Posted in Uncategorized

On Android as a Platform

leave a comment »

Recently, Fred Wilson blogged about the future of Android as a a platform.

LatticeApps is providing a service to create data driven mobile apps. The Android platform is the cornerstone of our efforts.

Our comment on the blog is provided below:

iPhone and iPad fit the Steve Jobs model of making a product that amazes and is presented in perfect form. We appreciate an elegant product that works incredibly well and is truly beautiful.

Android is messier. It had adoption by tech’s who were interested in what it could do. It has become a real choice for actual consumers. Froyo might be the equivalent of Windows 3.0 – the first Window’s system that actually worked.

Android – as open as it is – has a better future to play on a range of devices and price points. It is better poised for a post-PC world. Fragmentation is a short-term issue – and always has been. A developer can pick a target OS and know they have 75% of the Android market. That may not be OK for Angry Birds, but it is OK for many. The problem gets smaller everyday.

The curation of the iOS path will limit it from being a platform for a full range of devices – and will keep it from ever being considered as a platform for a specific industry or specialized use.

Developer support is currently a critical resource. But as everything we do becomes mobile and connected, services will develop to move our daily needs to a mobile/tablet platform. It makes sense for Android to be the target platform for those services.

Written by Carmen Delessio

April 7, 2011 at 2:54 am

Posted in Uncategorized

Follow

Get every new post delivered to your Inbox.