Free eBook: First preview: Programming Windows Store Apps with HTML, CSS, and JavaScript, Second Edition

Microsoft Press provide a First Preview of the upcoming second edition of Kraig Brockschmidt’s Programming Windows Store Apps with HTML, CSS, and JavaScript!

First preview: Programming Windows Store Apps with HTML, CSS, and JavaScript, Second Edition

The 255-page PDF itself can be downloaded here: http://aka.ms/SecondEdition/FirstPreview (5.57 MB)

FYI, EPUB and MOBI for the ebook’s final release will be provided, not for the two preliminary releases.

Also, please remember that this material is in DRAFT form. This content will not be final until the ebook’s final release.

Source: Microsoft Press Blog

Android Studio 0.1.8 just released

Android Studio 0.1.8 just released to address several bugs in 0.1.7 around gradle builds. In addition, there are the following changes:
  • Support for running instrumentation tests on device. Tests should be created in the folder "src/instrumentTest/java" (of the main application or a library) following the conventions described at http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Testing
    • To run them, simply right click on the test and click on Run as type Android Junit test.
    • You can also create a new run configuration of type "Android Test" and specify whether you want to run all the tests in a module, package, class or just a single test.
    • NOTE: Debugging tests will be supported in the next release
  • 0.1.8 also comes with a brand new implementation of a resource manager in the IDE, used for layout preview, editor resource folding, etc. This should address many bugs reported in earlier versions (such as @id attributes not being handled properly in RelativeLayouts, bugs with opening layouts after making edits, etc, and should be more performant.
  • New lint check validating device admin receivers

Details: Android Tools Project Site - Android Studio 0.1.8 Released

Introducing Google Play for Education

BizDevBytes: Introducing Google Play for Education
As Google expands its education offering to Android, Shazia Makhdumi provides an overview of the Google Play for Education program. Developers will learn how the program works and how to leverage the unique business opportunities in creating educational apps for the K-12 market.

To learn more visit developer.android.com/edu

java.lang.RuntimeException: Unable to instantiate activity ComponentInfo

Problem on Java Build Path again...! similar to the case of Unexpected namespace prefix "xmlns" found for tag fragment on xmlns:map="http://schemas.android.com/apk/res-auto".

Somebody report that my old exercise "Share IntentService among Fragments" not work. So I try to import the downloaded project in a new installed Android ADT, and the following error...sss reported in LogCat:

06-20 23:34:38.358: W/dalvikvm(26472): Unable to resolve superclass of Lcom/example/androidyahooweatherdom/MainActivity; (10)
06-20 23:34:38.358: W/dalvikvm(26472): Link of class 'Lcom/example/androidyahooweatherdom/MainActivity;' failed
06-20 23:34:38.358: W/dalvikvm(26472): threadid=1: thread exiting with uncaught exception (group=0x40cb92d0)
06-20 23:34:38.363: E/AndroidRuntime(26472): FATAL EXCEPTION: main
06-20 23:34:38.363: E/AndroidRuntime(26472): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.androidyahooweatherdom/com.example.androidyahooweatherdom.MainActivity}: java.lang.ClassNotFoundException: com.example.androidyahooweatherdom.MainActivity
06-20 23:34:38.363: E/AndroidRuntime(26472): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2267)
06-20 23:34:38.363: E/AndroidRuntime(26472): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
06-20 23:34:38.363: E/AndroidRuntime(26472): at android.app.ActivityThread.access$600(ActivityThread.java:151)
06-20 23:34:38.363: E/AndroidRuntime(26472): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1331)
06-20 23:34:38.363: E/AndroidRuntime(26472): at android.os.Handler.dispatchMessage(Handler.java:99)
06-20 23:34:38.363: E/AndroidRuntime(26472): at android.os.Looper.loop(Looper.java:155)
06-20 23:34:38.363: E/AndroidRuntime(26472): at android.app.ActivityThread.main(ActivityThread.java:5485)
06-20 23:34:38.363: E/AndroidRuntime(26472): at java.lang.reflect.Method.invokeNative(Native Method)
06-20 23:34:38.363: E/AndroidRuntime(26472): at java.lang.reflect.Method.invoke(Method.java:511)
06-20 23:34:38.363: E/AndroidRuntime(26472): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1028)
06-20 23:34:38.363: E/AndroidRuntime(26472): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:795)
06-20 23:34:38.363: E/AndroidRuntime(26472): at dalvik.system.NativeStart.main(Native Method)
06-20 23:34:38.363: E/AndroidRuntime(26472): Caused by: java.lang.ClassNotFoundException: com.example.androidyahooweatherdom.MainActivity
06-20 23:34:38.363: E/AndroidRuntime(26472): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
06-20 23:34:38.363: E/AndroidRuntime(26472): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
06-20 23:34:38.363: E/AndroidRuntime(26472): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
06-20 23:34:38.363: E/AndroidRuntime(26472): at android.app.Instrumentation.newActivity(Instrumentation.java:1069)
06-20 23:34:38.363: E/AndroidRuntime(26472): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2258)
06-20 23:34:38.363: E/AndroidRuntime(26472): ... 11 more


Finally, I solve it by correcting Java Build Path - right clicking project -> Java Build Path, select Order and Export tab, check to include both Android 4.2.2 and Android Private Libraries, and click OK.

correct Java Build Path

Actually, I don't know what happen! May be there are something changed in new Android Developer Tools.

Register your app using YouTube Android Player API and obtain API Key

To use YouTube Android Player API in your app, you have to register it and obtain API key. This post show you the steps to do so.

- Login with your Google account in Google APIs Console.

- Pull-down the Slection on left, and click Create... under Other Projects.



- Enter name of your project.



- Enable YouTube Data API v3 to ON.



- And then click to select API Access, and you will found you API key. You have to insert it in your code to use YouTube Android Player API.





To develop Android apps with YouTube Android Player API, read the posts in YouTube Android Player API step-by-step.

Unexpected namespace prefix "xmlns" found for tag fragment on xmlns:map="http://schemas.android.com/apk/res-auto"

This post share my experience on the error of Unexpected namespace prefix "xmlns" found for tag fragment on xmlns:map="http://schemas.android.com/apk/res-auto".

Recently, I re-check my old project using Google Maps Android API v2, it work without error before. But LogCat show error:

...
E/AndroidRuntime(20411): Caused by: android.app.Fragment$InstantiationException: Unable to instantiate fragment com.google.android.gms.maps.MapFragment: make sure class name exists, is public, and has an empty constructor that is public
...
E/AndroidRuntime(20411): Caused by: java.lang.ClassNotFoundException: com.google.android.gms.maps.MapFragment
...

Then I re-visit the layout xml with MapFragment, error message show Unexpected namespace prefix "xmlns" found for tag fragment on the statement  xmlns:map="http://schemas.android.com/apk/res-auto".



To solve it, correct Java Build Path by right clicking on your project -> Java Build Path, select Order and Export tab, check both Android 4.2.2 and Android Private Libraries, and click OK.


And then clean and build the project.


Similar to the case: java.lang.RuntimeException: Unable to instantiate activity ComponentInfo


Download and import YouTube Android Player API

YouTube Android Player API enables you to incorporate video playback functionality into your Android applications. The API defines methods for loading and playing YouTube videos (and playlists) and for customizing and controlling the video playback experience.

I will show the steps to develop Android App with YouTube Android Player API step-by-step, please refer the post YouTube Android Player API step-by-step.

To develop Android apps with YouTube Android Player API, you have to download and import the YouTube Android Player API jar to your project.

- New a Android Application Project.

- Download and unzip YouTube Android Player API here.

- Copy the unzipped YouTubeAndroidPlayerApi.jar file to /libs folder in your project. The YouTubeAndroidPlayerApi.jar file should be in /libs sub-folder of your unzipped files.

import YouTubeAndroidPlayerApi.jar

- Right click your project, select , then select Java Build Path and click Add JARs... button.


- Select YouTubeAndroidPlayerApi.jar, and click OK.


Android Studio 0.1.5 Released

Android Studio 0.1.5 just Released. This release contains only bug fixes and infrastructure work, as well as a merge with the latest IntelliJ 13 development branch.

~ source: https://sites.google.com/a/android.com/tools/recent/studio015released

Install/Update Android Studio:

If you are already running Android Studio, just restart it, or manually check for updates via Help > Check for Update... (on OSX, look in the Android Studio menu).

If you do not already have Android Studio, install the latest full install from
http://developer.android.com/sdk/installing/studio.html#download

Options for DatePicker to display or hide calendar view and spinners

The former exercise show a "Simple example of using DatePicker with both calendar view and spinners". We can show/hide calendar view and spinners individually in XML with android:calendarViewShown and android:spinnersShown attributes. Introduced in API level 11, we can also program it using Java code with setCalendarViewShown() and setSpinnersShown() methods.

Options for DatePicker to display or hide calendar view and spinners


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:orientation="vertical"
tools:context=".MainActivity" >

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
<RadioGroup
android:id="@+id/optGroup"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<RadioButton
android:id="@+id/optCalendar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="CalendarView"
android:checked="true" />
<RadioButton
android:id="@+id/optSpinners"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Spinners" />
<RadioButton
android:id="@+id/optBoth"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Both" />
</RadioGroup>
<DatePicker
android:id="@+id/pickerdate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:calendarViewShown="true"
android:spinnersShown="false" />

</LinearLayout>


package com.example.androiddatepickershown;

import android.os.Bundle;
import android.widget.DatePicker;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;
import android.app.Activity;

public class MainActivity extends Activity {

RadioGroup groupBtn;
RadioButton btnCalendar, btnSpinners, btnBoth;
DatePicker pickerDate;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
groupBtn = (RadioGroup)findViewById(R.id.optGroup);
btnCalendar = (RadioButton)findViewById(R.id.optCalendar);
btnSpinners = (RadioButton)findViewById(R.id.optSpinners);
btnBoth = (RadioButton)findViewById(R.id.optBoth);
pickerDate = (DatePicker)findViewById(R.id.pickerdate);

groupBtn.setOnCheckedChangeListener(new OnCheckedChangeListener(){

@Override
public void onCheckedChanged(RadioGroup arg0, int arg1) {
if(btnCalendar.isChecked()){
pickerDate.setCalendarViewShown(true);
pickerDate.setSpinnersShown(false);
}else if(btnSpinners.isChecked()){
pickerDate.setCalendarViewShown(false);
pickerDate.setSpinnersShown(true);
}else{
pickerDate.setCalendarViewShown(true);
pickerDate.setSpinnersShown(true);
}
}});
}

}


YouTube Android Player API step-by-step

The YouTube Android Player API enables you to incorporate video playback functionality into your Android applications. The API defines methods for loading and playing YouTube videos (and playlists) and for customizing and controlling the video playback experience.

Using the API, you can load or cue videos into a player view embedded in your application's UI. You can then control playback programmatically. For example, you can play, pause, or seek to a specific point in the currently loaded video.

You can also register event listeners to get callbacks for certain events, such as the player loading a video or the player state changing. Finally, the API has helper functionality to support orientation changes as well as transitions to fullscreen playback.






Develop Android App with YouTube Android Player API step-by-step:

Related:

How to use the new Google Maps: A map built for you



Get smarter recommendations with the new Google Maps.
http://maps.google.com/preview

Motion Design Presentation for Ubuntu Mobile

This is a presentation of 'Paper' Motion theme which has been applied to some of the core movements on Ubuntu Mobile.



Know more: OMG! Ubuntu! New Interface Animations Demoed for Ubuntu Touch

NineOldAndroids, Android library for using the Honeycomb animation API on old versions

In the post "Apply animations on layout changes using LayoutTransition" apply animation for deveice with API level 11 or higher. To apply Android 3.0 animation API on old devices, NineOldAndroids is an alternative.

remark: NineOldAndroids doesn't have LayoutTransition currently

NineOldAndroids


NineOldAndroids is a Android library for using the Honeycomb (Android 3.0) animation API on all versions of the platform back to 1.0!

Animation prior to Honeycomb was very limited in what it could accomplish so in Android 3.x a new API was written. With only a change in imports, we are able to use a large subset of the new-style animation with exactly the same API.

This library also includes support for animating rotation, translation, alpha, and scale on platforms prior to Honeycomb!

Getting Started with Java 8 in IntelliJ IDEA 12.1

A quick overview of Java 8 support in IntelliJ IDEA 12.1.


Detect touch event in Processing for Android

Last exercise demonstrate the basic "Hello World of Processing for Android". This exercise show to to detect touch event, by implement surfaceTouchEvent() method.

Detect touch event in Processing for Android


import android.view.MotionEvent;

boolean showEvent = false;
int evAction;
int evX, evY;

void setup()
{
size(displayWidth, displayHeight);
background(0);

stroke(255);
strokeWeight(3);
}

void draw()
{
if(showEvent){
text("Action: " + str(evAction), 10, 50);
ellipse(evX, evY, 10, 10);

showEvent = false;
}
}

public boolean surfaceTouchEvent(MotionEvent event)
{
evAction = event.getAction();
evX = mouseX;
evY = mouseY;
showEvent = true;

return super.surfaceTouchEvent(event);
}


When Android Meets Maps, Google I/O 2013 video



Build intuitive and compelling mobile map apps with the Google Maps Android API. This session will demonstrate innovative ways to integrate maps and Android sensors with Google services on Android. We will explore concepts on visualizing contextual, personalized and timely information.



Related: A simple example using Google Maps Android API v2

Hello World of Processing for Android

With Download and install Processing software and Setup Processing for Android development, we can noe prepare our first Hello World using Processing for Android.

- Start Processing and switch to Android Mode, by selection on the top-right pull-down box.

switch to Android Mode

Enter the code:

void setup()
{
size(displayWidth, displayHeight);
background(0);
}

void draw()
{
fill(204, 102, 0);
rect(30, 20, 55, 55);
text("hello Android + Processing", 100, 100);
}

Hello World of Processing for Android

With Android device connected, you can save and Run on Device under Sketch menu selection.

Run on Device

Hello World of Processing for Android run on device


Next:
- Detect touch event in Processing for Android
- Another example code: Processing on desktop vs Processing for Android


Setup Processing for Android development

Processing for Android project is aim to make it foolishly easy to create Android apps using the Processing API.

To setup Processing development tool for Android development, you have to install Android Developer Tools (ADT) in your system in advance.

Also you have to configure your Android SDK Manager to install Android 2.3.3 (API 10) - in Eclipse for Android Developer Tools, select Window -> Android SDK Manager:

Install Android 2.3.3 (API 10) in Android SDK Manager

otherwise you will have error of Unable to resolve project target 'android-10' when compile your Processing sketch.

Unable to resolve project target 'android-10'

- Download and install Processing software

Setup Processing for Android development:

Start Processing software:
- in Ubuntu, open Terminal, switch to your installed directory of Processing, type the command:
$./processing

- Select Add Mode in the Top-Right pull-down box.

Add Mode


- Select Android Mode, and click Install.

Add Android Mode

- You will be asked to select Android SDK installed location, click Yes.

select Android SDK installed location

- In the next dialog, select your installed location of Android SDK.
In my case of running on Ubuntu 13.04 with Xubuntu desktop, I cannot open sub-directory of Android in Folders box by clicking on Android, but I can direct enter Android/sdk/ in Selection box.

Select Android/sdk/

- Now you can switch to Android Mode in Top-Right pop-down box.

Switch to Android Mode


Android Mode of Processing


Next:
- Hello World of Processing for Android
- Another example code: Processing on desktop vs Processing for Android


Download and install Processing software

Processing is an open source programming language and environment for people who want to create images, animations, and interactions. Initially developed to serve as a software sketchbook and to teach fundamentals of computer programming within a visual context, Processing also has evolved into a tool for generating finished professional work. Today, there are tens of thousands of students, artists, designers, researchers, and hobbyists who use Processing for learning, prototyping, and production.

To download and install is very straightforward:

Visit http://processing.org/, select Download, download the Mac, Windows, or Linux version, depending on what machine you have.

Download Processing software


Reference: Getting Started

Next:
- Setup Processing for Android development
- Hello World of Processing for Android