Android 4 3 announced and Developer Tools updated

Android 4.3 of Jelly Bean announced, includes great new features for users and developers. Android 4.3 powers the new Nexus 7 tablet and it’s rolling out now as an update to Nexus 4, Nexus 7, Nexus 10, and Galaxy Nexus HSPA+ devices across the world.

For developers, Android 4.3 includes the latest performance enhancements to keep your apps fast, smooth, and efficient, together with new APIs and capabilities to use in your apps.

Know more: http://android-developers.blogspot.hk/2013/07/android-43-and-updated-developer-tools.html

Read More..

Learn Java for Android Development Second Edition


February 20, 2013  1430257229  978-1430257226 2

Android development is hot, and many programmers are interested in joining the fun. However, because this technology is based on Java, you should first obtain a solid grasp of the Java language and its foundational APIs to improve your chances of succeeding as an Android app developer. After all, you will be busy learning the architecture of an Android app, the various Android-specific APIs, and Android-specific tools. If you do not already know Java fundamentals, you will probably end up with a massive headache from also having to quickly cram those fundamentals into your knowledge base.

Learn Java for Android Development, Second Edition teaches programmers of any skill level the essential Java language and foundational Java API skills that must be learned to improve the programmer’s chances of succeeding as an Android app developer. Each of the book’s 14 chapters provides an exercise section that gives you the opportunity to reinforce your understanding of the chapter’s material. Answers to the book’s more than 500 exercises are provided in an appendix. A second appendix provides a significant game-oriented Java application, which you can convert into an Android app.

Once you complete this book, you should be ready to dive into beginning Android app development.  Maybe, start that journey with ApressBeginning Android.

What you’ll learn

  • The Java language:  This book provides complete coverage of nearly every pre-Java version 7 language feature (native methods are briefly mentioned but not formally covered). Starting with basic language features (e.g., comments, types, expressions, and statements), you progress to those features related to classes and objects, followed by object-oriented features related to inheritance, polymorphism, and interfaces. You then explore the advanced language features for nested types, packages, static imports, exceptions, assertions, annotations, generics, and enums. Continuing, you investigate strictfp, synchronized, volatile, the enhanced for loop statement, autoboxing/unboxing, and transient fields.
  • Java APIs:  In addition to Object and APIs related to exceptions, you explore Math, StrictMath, BigDecimal, BigInteger, String, StringBuffer/StringBuilder, Boolean, Character, Byte, Short, Integer, Long, Float, Double, Number, the Threads API, System, Runtime, Process, the Collections Framework, the Concurrency Utilities, Date, Formatter, Random, Scanner, the ZIP and JAR APIs, File, RandomAccessFile, stream classes, and writer/reader classes, InetAddress, SocketOptions, Socket, ServerSocket, DatagramSocket, MulticastSocket, URL, URLConnection, URLEncoder, URLDecoder, NetWorkInterface, InterfaceAddress, CookieHandler, CookieManager, CookieStore, CookiePolicy, Buffer, ByteBuffer, CharBuffer, DoubleBuffer,FloatBuffer, IntBuffer, LongBuffer, ShortBuffer, MappedByteBuffer, Channel, WritableByteChannel, ReadableByteChannel,ScatteringByteChannel, GatheringByteChannel, FileChannel, the Regular Expressions API, JDBC, and more.
  • Applying these:  You will learn how to use the JDK’s javac (compiler), java (application launcher), javadoc (Java documentation generator), and jar (Java archive creator, updater, and extractor) tools. You will also receive an introduction to the Eclipse integrated development environment, which is the official standard for developing Android apps.

Who this book is for

This book is for any programmer - including existing Java programmers and Objective-C-based iPhone and iPad programmers - of any skill level who needs to obtain a solid understanding of the Java language and foundational Java APIs before jumping into Android app development.

Table of Contents

1. Getting Started with Java
2. Learning Language Fundamentals
3. Discovering Classes and Objects
4. Discovering Inheritance, Polymorphism, and Interfaces
5. Mastering Advanced Language Features Part 1
6. Mastering Advanced Language Features Part 2
7. Exploring the Basic APIs Part 1
8. Exploring the Basic APIs Part 2
9. Exploring the Collections Framework
10. Exploring Additional Utility APIs
11. Performing Classic I/O
12. Accessing Networks
13. Migrating to New I/O
14. Accessing Databases
A. Appendix A: Solutions to Exercises
B. Appendix B: Four of a Kind
C. Appendix C: Odds and Ends***


***NOTE:  Appendix C is not included in the physical book. Instead, its distributed as a PDF file thats bundled with the books code.  As well as covering updated topics from the previous edition of this book (e.g., References, Reflection, and Preferences), this 138-page appendix includes new content.
Read More..

Install repo on Ubuntu

Repo is a tool that makes it easier to work with Git in the context of Android.

- Before install repo, we have to install curl and git.

To install curl, enter the command in Terminal.

$sudo apt-get install curl

To install git, enter the command.

$sudo apt-get install git

- Then create bin/ directory in home directory, and include it in your path.

$ mkdir ~/bin
$ PATH=~/bin:$PATH

- Download the Repo script and ensure it is executable

$ curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
$ chmod a+x ~/bin/repo


To know more about how to download the source code od Android, read here.



Read More..

Add MenuItem to ActionBarCompat using Java

We are going to add MenuItem, menuItem_Info, to ActionBarCompat using Java code.

With new menuItem_Info
New MenuItem of menuItem_Info added using Java code
Modify exercise from last exercise "Example of using ActionBarCompat with android-support-v7-appcompat".

To add new MenuItem dynamically, we have to assign new id to it. Create a new file, /res/values/ids.xml, to define our of ID:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item name="menuid_info" type="id"/>
</resources>


Modify onCreateOptionsMenu() method in MainActivity.java to add new MenuItem using Java code:
package com.example.testactionbarcompat;

import android.os.Bundle;
import android.support.v4.view.MenuItemCompat;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;

public class MainActivity extends ActionBarActivity {

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


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

//add MenuItem(s) to ActionBar using Java code
MenuItem menuItem_Info = menu.add(0, R.id.menuid_info, 0, "Info");
menuItem_Info.setIcon(android.R.drawable.ic_menu_info_details);
MenuItemCompat.setShowAsAction(menuItem_Info,
MenuItem.SHOW_AS_ACTION_IF_ROOM|MenuItem.SHOW_AS_ACTION_WITH_TEXT);

return true;
}

}

download filesDownload the files.



Visit: ActionBarCompat Step-by-step

Read More..

1000

Finally get +1000 at the day of End of the World:)


Read More..

Quick Action In Android

Description:
This example of will show how we can generate a Action list or a popup window on a button press.
Algorithm:
1.) Create a new project by File-> New -> Android Project name it QuickActionDemo.
2.) You will see some default code into your main.xml, strings.xml and android manifest file.
3.) Now write following code into your main.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:orientation="vertical"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent">
        <TextView

                android:layout_width="fill_parent"
        android:layout_height="wrap_content"            
        android:gravity="center"
        android:textSize="17dp"
        android:textStyle="bold"
        android:text="Popup Window Action Demo"/>
     
        <Button
                android:id="@+id/btn2"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:padding="30dp"
                android:text="Button" />
       
</LinearLayout>
4.) Create ActionItem.java and write following code:
package com.org.QuickActionActivity;
import android.graphics.drawable.Drawable;
import android.graphics.Bitmap;
public class ActionItem {
        private Drawable icon;
        private Bitmap thumb;
        private String title;
        private boolean selected;
     
        public ActionItem() {}
        public ActionItem(Drawable icon) {
                this.icon = icon;
        }
        public void setTitle(String title) {
                this.title = title;
        }
        public String getTitle() {
                return this.title;
        }
        public void setIcon(Drawable icon) {
                this.icon = icon;
        }
        public Drawable getIcon() {
                return this.icon;
        }
        public void setSelected(boolean selected) {
                this.selected = selected;
        }
        public boolean isSelected() {
                return this.selected;
        }
        public void setThumb(Bitmap thumb) {
                this.thumb = thumb;
        }
        public Bitmap getThumb() {
                return this.thumb;
        }
}
5.) Create NewQAAdapter.java and write following:
package com.org.QuickActionActivity;
import android.view.View;
import android.view.ViewGroup;
import android.view.LayoutInflater;
import android.content.Context;
import android.widget.BaseAdapter;
import android.widget.TextView;
public class NewQAAdapter extends BaseAdapter {
        private LayoutInflater mInflater;
        private String[] data;
     
        public NewQAAdapter(Context context) {
                mInflater = LayoutInflater.from(context);
        }
        public void setData(String[] data) {
                this.data = data;
        }
     
        @Override
        public int getCount() {
                return data.length;
        }
        @Override
        public Object getItem(int item) {
                return data[item];
        }
        @Override
        public long getItemId(int position) {
                return position;
        }
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
                ViewHolder holder;
             
                if (convertView == null) {
                        convertView     = mInflater.inflate(R.layout.listnull);
                     
                        holder          = new ViewHolder();
                     
                        holder.mTitleText       = (TextView)convertView.findViewById(R.id.t_name);
                     
                        convertView.setTag(holder);
                } else {
                        holder = (ViewHolder) convertView.getTag();
                }
                holder.mTitleText.setText(data[position]);
             
                return convertView;
        }
        static class ViewHolder {
                TextView mTitleText;
        }
}
6.) Click here to download full code content and other src and res files.
Steps:
1.) Create a project named QuickActionDemo and set the information as stated in the image.
Build Target: Android 2.1
Application Name: QuickActionDemo
Package Name: com.org. QuickActionDemo
Activity Name: QuickActionDemo
Min SDK Version: 7
2.) Open QuickActionDemo.java file and write following code there:
package com.org.QuickActionActivity;
import android.os.Bundle;
import android.app.Activity;
import android.widget.Button;
import android.widget.Toast;
import android.view.View;
import android.view.View.OnClickListener;
public class QuickActionActivity extends Activity {
        @Override
        protected void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
             
                setContentView(R.layout.main);
             
                //Add action item
        ActionItem addAction = new ActionItem();
             
                addAction.setTitle("Add");
                addAction.setIcon(getResources().getDrawable(R.drawable.ic_add));
                //Accept action item
                ActionItem accAction = new ActionItem();
             
                accAction.setTitle("Accept");
                accAction.setIcon(getResources().getDrawable(R.drawable.ic_accept));
             
                //Upload action item
                ActionItem upAction = new ActionItem();
             
                upAction.setTitle("Upload");
                upAction.setIcon(getResources().getDrawable(R.drawable.ic_up));
             
                final QuickAction mQuickAction  = new QuickAction(this);
             
                mQuickAction.addActionItem(addAction);
                mQuickAction.addActionItem(accAction);
                mQuickAction.addActionItem(upAction);
             
                //setup the action item click listener
                mQuickAction.setOnActionItemClickListener(newQuickAction.OnActionItemClickListener() {              
                        @Override
                        public void onItemClick(int pos) {
                             
                                if (pos == 0) { //Add item selected
                                        Toast.makeText(QuickActionActivity.this,"Add item selected", Toast.LENGTH_SHORT).show();
                                } else if (pos == 1) { //Accept item selected
                                        Toast.makeText(QuickActionActivity.this,"Accept item selected", Toast.LENGTH_SHORT).show();
                                } else if (pos == 2) { //Upload item selected
                                        Toast.makeText(QuickActionActivity.this,"Upload items selected", Toast.LENGTH_SHORT).show();
                                }    
                        }
                });
                Button btn2 = (Button) this.findViewById(R.id.btn2);
                btn2.setOnClickListener(new OnClickListener() {
                        @Override
                        public void onClick(View v) {
                                mQuickAction.show(v);
                                mQuickAction.setAnimStyle(QuickAction.ANIM_GROW_FROM_CENTER);
                        }
                });
        }
}
3.) Compile and build the project.
4.) Run on 2.1 simulator for the output.
Output
Read More..

Blog Archive

Powered by Blogger.