The New Digital Age: Reshaping the Future of People, Nations and Business


In an unparalleled collaboration, two leading global thinkers in technology and foreign affairs give us their widely anticipated, transformational vision of the future: a world where everyone is connected—a world full of challenges and benefits that are ours to meet and to harness.

Eric Schmidt is one of Silicon Valley’s great leaders, having taken Google from a small startup to one of the world’s most influential companies. Jared Cohen is the director of Google Ideas and a former adviser to secretaries of state Condoleezza Rice and Hillary Clinton. With their combined knowledge and experiences, the authors are uniquely positioned to take on some of the toughest questions about our future: Who will be more powerful in the future, the citizen or the state? Will technology make terrorism easier or harder to carry out? What is the relationship between privacy and security, and how much will we have to give up to be part of the new digital age?

In this groundbreaking book, Schmidt and Cohen combine observation and insight to outline the promise and peril awaiting us in the coming decades. At once pragmatic and inspirational, this is a forward-thinking account of where our world is headed and what this means for people, states and businesses.

With the confidence and clarity of visionaries, Schmidt and Cohen illustrate just how much we have to look forward to—and beware of—as the greatest information and technology revolution in human history continues to evolve. On individual, community and state levels, across every geographical and socioeconomic spectrum, they reveal the dramatic developments—good and bad—that will transform both our everyday lives and our understanding of self and society, as technology advances and our virtual identities become more and more fundamentally real.

As Schmidt and Cohen’s nuanced vision of the near future unfolds, an urban professional takes his driverless car to work, attends meetings via hologram and dispenses housekeeping robots by voice; a Congolese fisherwoman uses her smart phone to monitor market demand and coordinate sales (saving on costly refrigeration and preventing overfishing); the potential arises for “virtual statehood” and “Internet asylum” to liberate political dissidents and oppressed minorities, but also for tech-savvy autocracies (and perhaps democracies) to exploit their citizens’ mobile devices for ever more ubiquitous surveillance. Along the way, we meet a cadre of international figures—including Julian Assange—who explain their own visions of our technology-saturated future.

Inspiring, provocative and absorbing, The New Digital Age is a brilliant analysis of how our hyper-connected world will soon look, from two of our most prescient and informed public thinkers.

Simulate kill activity to test onSaveInstanceState() / onCreate()

In order to test the lifecycle behaviour of our apps, we always have to leave our apps to move it to background, wait sometime for the system to kill it...and restart it.

It's a alternative to simulate "kill activity" by the Immediately destroy activities (or called Don't keep activities/Do not keep activities) selection Development Settings:

Select Developer options in Setting
Select Developer options in Setting

Select Advanced

Check Don't keep activities


According to the Android Developer document of Using the Dev Tools App:

Immediately destroy activities
Tells the system to destroy an activity as soon as it is stopped (as if Android had to reclaim memory). This is very useful for testing the onSaveInstanceState(Bundle) / onCreate(android.os.Bundle) code path, which would otherwise be difficult to force. Choosing this option will probably reveal a number of problems in your application due to not saving state. For more information about saving an activity's state, see the Activities document.


Notice: This setting for developers only, NOT for general user.



Related: The lifecycle in Activity Killed

Google Play content policies have been updated




Google Play content policies have been updated. See "Content Policies" section of Google Play Developer Program Policies, which clarifies that "An app downloaded from Google Play may not modify, replace or update its own APK binary code using any method other than Google Play's update mechanism." Google Play is a trusted source for Android application downloads, and we are committed to providing a secure and consistent experience.

Allow navigate BACK through FragmentTransaction, by calling addToBackStack()

If you try last exercise "Handle onListItemClick() of ListFragment, to pass data between fragment" on phone FragmentTransaction, when you BACK in MyDetailFragment, it will exit the application, not back to MyListFragment as common expected. To allow the user to navigate backward through the fragment transactions, you must call addToBackStack() before you commit the FragmentTransaction.


package com.example.androiddualmode;

import android.os.Bundle;
import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentTransaction;
import android.app.ListFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.TextView;

public class MainActivity extends Activity {

// if run on phone, isSinglePane = true
// if run on tablet, isSinglePane = false
static boolean isSinglePane;

static String[] month ={
"January", "February", "March", "April",
"May", "June", "July", "August",
"September", "October", "November", "December"};

public static class MyListFragment extends ListFragment {

@Override
public void onActivityCreated(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onActivityCreated(savedInstanceState);

ListAdapter myArrayAdapter =
new ArrayAdapter<String>(
getActivity(), android.R.layout.simple_list_item_1, month);
setListAdapter(myArrayAdapter);

}

@Override
public void onListItemClick(ListView l, View v, int position, long id) {

String clickedDetail = (String)l.getItemAtPosition(position);

if(isSinglePane == true){
/*
* The second fragment not yet loaded.
* Load MyDetailFragment by FragmentTransaction, and pass
* data from current fragment to second fragment via bundle.
*/
MyDetailFragment myDetailFragment = new MyDetailFragment();
Bundle bundle = new Bundle();
bundle.putString("KEY_DETAIL", clickedDetail);
myDetailFragment.setArguments(bundle);
FragmentTransaction fragmentTransaction =
getActivity().getFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.phone_container, myDetailFragment);

/*
* Add this transaction to the back stack.
* This means that the transaction will be remembered after it is
* committed, and will reverse its operation when later popped off
* the stack.
*/
fragmentTransaction.addToBackStack(null);

fragmentTransaction.commit();

}else{
/*
* Activity have two fragments. Pass data between fragments
* via reference to fragment
*/

//get reference to MyDetailFragment
MyDetailFragment myDetailFragment =
(MyDetailFragment)getFragmentManager().findFragmentById(R.id.detail_fragment);
myDetailFragment.updateDetail(clickedDetail);

}
}

}

public static class MyDetailFragment extends Fragment {

TextView textDetail;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// TODO Auto-generated method stub
View view = inflater.inflate(R.layout.layout_detailfragment, null);
textDetail = (TextView)view.findViewById(R.id.text_detail);

Bundle bundle = getArguments();
if(bundle != null){
String detail = bundle.getString("KEY_DETAIL", "no argument pass");
textDetail.setText(detail);
}

return view;
}

public void updateDetail(String detail) {
textDetail.setText(detail);
}

}

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

View v = findViewById(R.id.phone_container);
if(v == null){
//it's run on tablet
isSinglePane = false;
/*
* MyListFragment and MyDetailFragment have been loaded in XML,
* no need load.
*/

}else{
//it's run on phone
//Load MyListFragment programmatically
isSinglePane = true;

if(savedInstanceState == null){
//if's the first time created
MyListFragment myListFragment = new MyListFragment();
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
fragmentTransaction.add(R.id.phone_container, myListFragment);
fragmentTransaction.commit();
}
}
}

}


Next:
- Display UP icon on action bar and implement BACK navigation in Fragment Transaction


Handle different layout for phone and tablet, in seperated layout folder

For the first generation of tablets running Android 3.0, the proper way to declare tablet layouts was to put them in a directory with the xlarge configuration qualifier (for example, res/layout-xlarge/). In Android 3.2 introduces a new way to specify resources for more discrete screen sizes. The new technique is based on the amount of space your layout needs (such as 600dp of width), rather than trying to make your layout fit the generalized size groups (such as large or xlarge).

For other cases in which you want to further customize your UI to differentiate between sizes such as 7” and 10” tablets, you can define additional smallest width layouts:
  • res/layout/main_activity.xml:
    # For handsets (smaller than 600dp available width)
  • res/layout-sw600dp/main_activity.xml:
    # For 7” tablets (600dp wide and bigger)
  • res/layout-sw720dp/main_activity.xml:
    # For 10” tablets (720dp wide and bigger)
Read more: Supporting Multiple Screens

Exercise:

Create a new Android Application Project with Minimum Required SDK of API 13: Android 3.2 (Honeycomb).



Modify /res/layout/activity_main.xml for normal device.
<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="Normal" />

</LinearLayout>


Run on normal Android devices


Create /res/layout-sw600dp/activity_main.xml to define layout for tablet.
<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="sw600dp" />

</LinearLayout>

Run on tablet devices




More: Step-by-step to create dual mode app, single-pane for phone/dual-pane for tablet.


Related:
- Replace Fragment dynamically

Embedded Android: Porting, Extending, and Customizing


Looking to port Android to other platforms such as embedded devices? This hands-on book shows you how Android works and how you can adapt it to fit your needs. You’ll delve into Android’s architecture and learn how to navigate its source code, modify its various components, and create your own version of Android for your particular device. You’ll also discover how Android differs from its Linux roots.
If you’re experienced with embedded systems development and have a good handle on Linux, this book helps you mold Android to hardware platforms other than mobile devices.
  • Learn about Android’s development model and the hardware you need to run it
  • Get a quick primer on Android internals, including the Linux kernel and Dalvik virtual machine
  • Set up and explore the AOSP without hardware, using a functional emulator image
  • Understand Android’s non-recursive build system, and learn how to make your own modifications
  • Use evaluation boards to prototype your embedded Android system
  • Examine the native user-space, including the root filesystem layout, the adb tool, and Android’s command line
  • Discover how to interact with—and customize—the Android Framework

android-webserver: Small webserver on your android phone


android-webserver is a open source project of small webserver on your android phone, hosted on Google Code. It understands "GET"-Requests and can handle ASCII and BINARY files. Works only when connected to a wifi-network.


CX-803 II Android 4.1 Google TV Box Dual core Rk3066 2G RAM 8G w/ BT HDMI external Antenna


  • Android TV Dongle with TF Card Slot and External Antenna
  • Dual Core RK3066 Cortex A9
  • 2D/3D GPU (4 x mali 400)
  • IEEE 802.11 b/g/n (Built-in Realtek 8189 Sdio WiFi Module)
  • Built-in microphone



Spec
-with the bluetooth - CPU: Rockchip RK3066 1.6 GHz Cortex A9
- GPU: 2D/3D GPU (4 x mali 400); 3D graphic with OpenGL ES2.0 and OpenVG 1.1
- Architecture: HD video decoder (1080p @ 60fps); HD video encoder (1080p @ 30fps);
- Strong Power Manage Unit(PMU); I2S Master & Slave Interface for Audio; HDMI 1.4
- RAM DDR3 2G; ROM Nand flash 8G (Android system and preinstalled will take some space)
- WiFi: IEEE 802.11 b/g/n (Built-in Realtek 8189 Sdio WiFi Module); DLNA: Digital Living Network Alliance
- Power consumption: Main unit + 2.4G sender(Mouse): no more than 700mA@5V
- Music format: MP3,WMA,WAV,OGG,AAC,FLAC,3GP...
- Video Player: MPEG2,MPEG4,AVI,WMV,MKV,MOV,RM,RMVB...
- Picture: JPG,BMP,PNG...
- Browser: Internet browse
- Play Store: Apps in Google Play Store
- Adobe Flash Player: V11.1
- Support HTML5
Ports
1 x OTG micro USB port; 1 x power supply micro USB port; 1 x USB port; 1 x hdmi; 1 x Micro SD card slot; 1 x Mic (Built-in microphone).

Package Includes 
1 x CX-803 mini tv box
1 x Micro USB cable
1 x Hdmi cable

Building New Experiences with Glass


Building New Experiences with Glass

Read and Write analog on Arduino Due from Android using ADK, with graphical display.

It's from my another blog for Arduino, http://arduino-er.blogspot.com/.



In this example, Android device can write analog output (DAC0/DAC1) and read analog input (A0) on Arduino Due board by using ADK, WITH GRAPHICAL DISPLAY on Android. The video show how it work, with DAC1 pin and A0 pin connected together, such that the analog out loop back to analog input.

To know how: Read analog input at Arduino Due, display on Android graphically@Arduino-er.

Display HTML format text in WebView

This example show how to display HTML format text in WebView, by calling WebView.loadData().

Display HTML format text in WebView


package com.example.androidhtmltext;

import android.os.Bundle;
import android.app.Activity;
import android.webkit.WebView;

public class MainActivity extends Activity {

WebView webView;

String mimeType = "text/html";
String encoding = "utf-8";
String htmlText = "<h1>It's in h1</h1><br/>"
+ "<h2>It's in h2</h2><br/>"
+ "<i>Italics</i><br/>"
+ "<b>Bold</b><br/>";

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

webView = (WebView)findViewById(R.id.webview);
webView.loadData(htmlText, mimeType, encoding);
}

}


<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" >

<WebView
android:id="@+id/webview"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />

</LinearLayout>