Limit EditText to accept signed decimal numbers only in xml and java

| 0 comments |

layout/activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout


android_layout_width="match_parent"
android_layout_height="match_parent"
android_padding="16dp"
android_orientation="vertical"
tools_context=".MainActivity">

<TextView
android_layout_width="wrap_content"
android_layout_height="wrap_content"
android_layout_gravity="center_horizontal"
android_autoLink="web"
android_text="http://android-er.blogspot.com/"
android_textStyle="bold" />

<EditText
android_id="@+id/edittext1"
android_layout_width="match_parent"
android_layout_height="wrap_content"
android_inputType="numberSigned|numberDecimal"/>
<EditText
android_id="@+id/edittext2"
android_layout_width="match_parent"
android_layout_height="wrap_content"/>

</LinearLayout>


MainActivity.java
package com.blogspot.android_er.androiddecimalnumberedittext;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.text.InputType;
import android.widget.EditText;

public class MainActivity extends AppCompatActivity {

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

EditText editText1 = (EditText)findViewById(R.id.edittext1);
EditText editText2 = (EditText)findViewById(R.id.edittext2);
editText2.setInputType(InputType.TYPE_CLASS_NUMBER
| InputType.TYPE_NUMBER_FLAG_DECIMAL
| InputType.TYPE_NUMBER_FLAG_SIGNED);
}
}

Read More..

Parsing JSON respone

| 0 comments |

if we have a JSON web service response like this:
"persons"
[
{
"person"{
"firstName": "John",
"lastName": "Smith",
"age": 25
}
}
{
"person"{
"firstName": "Catherine",
"lastName": "Jones",
"age": 35
}
}
]
this response is a JSON Array with the name "persons", this array consists of "person" JSON Objects.
to parse such a reponse:
public ArrayList<Person> getMessage(String response){
JSONObject jsonResponse;
ArrayList<Person> arrPersons=new ArrayList<Person>;
try {
// obtain the reponse
jsonResponse = new JSONObject(response);
// get the array
JSONArray persons=jsonResponse.optJSONArray("persons");
// iterate over the array and retrieve single person instances
for(int i=0;i<persons.length();i++){
// get person object
JSONObject person=persons.getJSONObject(i);
// get first name
String firstname=person.optString("firstname");
// get last name
String lastname=person.optString("lastname");
// get the age
int age=person.optInt("age");

// construct the object and add it to the arraylist
Person p=new Person();
p.firstName=firstname;
p.lastName=lastname;
p.age=age;
arrPersons.add(p);
}

} catch (JSONException e) {

e.printStackTrace();
}

return arrPersons;
}

notice that we used the methods optJSONArray,optString,optInt instead of using getString,getInt because the opt methods return empty strings or zero integers if no elements are found. while the get methods throw an exception if the element is not found.
Read More..

Table of contents

| 0 comments |
Table of Contents:
  1. Android Fundamentals - Jargon Explained
  2. Preliminary Step: Eclipse set up / Create Android Project
  3. Android Explicit Intent Example
  4. Android Implicit Intent Example
  5. Invoking Android Pre-packaged Applications
  6. Fetching a result from a called activity
  7. Android Notifications Example
  8. Android Local Service Example
  9. Android Service and Notification Combined Example
  10. Android Remote Service Example
  11. Android Content Provider Example
  12. Android Broadcast Receiver Example
  13. Android SQLite DB Example
  14. Shared Preferences on Android
  15. Google Maps on Android
  16. Location Manager on Android
  17. Simple List View
  18. Custom List View
  19. Android Threads and Handlers
  20. Http Connection Using Threads
  21. Date Time Picker Views
  22. Auto Complete Text View
  23. Spinner View
  24. Gallery View
  25. Image Switcher View
  26. Creating Android UI Programmatically
  27. Android UI - Inflate from XML (Dynamic UI Creation)
  28. ListView of Data from SQLiteDatabase
  29. TabLayout or Tabbed View
  30. Options Menu
  31. Context Menu
  32. New Contacts Content Provider
    Titbits
    1. Simulating an incoming call on the Emulator
    2. Obtain Google Maps API Key
    3. Simulate Location Change in Android Emulator
    4. Updating to Android SDK 2.1
    5. Delete / Remove Applications deployed on the Android Emulator
    6. Disable Chinese / Japanese Characters on Emulator Keyboard
    7. Android Eclipse link Error - New Project
    All Sample code at One place / Alternate Download site for Code
    https://sites.google.com/site/saigeethamn/home/android-tutorial-code-for-download
    Read More..

    One year in and just getting started

    | 0 comments |


    What’s in a name? Last September, when we changed our name from Google Enterprise to Google for Work, it wasn’t just about what we call ourselves – it was about what we stand for. We want to build great products that help you with every aspect of your life – including work (where many waking hours are spent).

    Enterprise is old business. We believe in a new way of working with collaboration at the core. A world where we work how we choose. Where getting stuff done in the office doesn’t feel like traveling back in time. Where our work tools are just as good or even better than the ones we have in our personal lives.

    We bring the best of Google to work. The same cloud computing infrastructure that we use to run our search engine; powerful apps and services to help you get work done – fast; simple, secure platforms to access everything, wherever you are.

    While we have much more in store, it’s been a busy year and we’ve hit some great milestones over the last twelve months:

    • More than one million paying organizations are actively using Google Drive, including companies like The New York Times, Uber, Fossil, Wedding Wire and BBVA.
    • Google Apps for Work is proving to be the next generation tool of choice: according to a Better Cloud study, Millennials (aged 18-34) are 55% more likely to use Google Apps than alternatives. It’s cost effective, too: Forrester Research’s Total Economic Impact calculator shows that companies using Google Apps see a 304 percent return on investment.
    • We’ve introduced groundbreaking new services with Google Cloud Platform, such as Nearline and Cloud Bigtable for storage and Kubernetes, an open-source container orchestration system. In total, we’ve added over 30 products to our stack, and our online community has nearly doubled.
    • Chromebooks are now the best-selling device in the US for K-12 education, according to a report from IDC.
    • More than 10,000 companies are testing, trialling and using Android for Work following its launch in February. In July, we added carriers such as AT&T and Verizon to our partner program and introduced a new class of devices for regulated industries, like the Blackphone by Silent Circle and Samsungs KNOX devices.

    And the best is yet to come. Cloud computing will continue to get more powerful, and we’re only at the beginning of what machine learning can do to help businesses and people contextualize data.

    Imagine an even smarter digital assistant that can surface the information you need at just the right time and help you manage your schedule for stress-free productivity. Virtual reality products, such as Expeditions, are going to help us learn and work in exciting new ways. And finally, more and more of the objects around us will connect to the internet, enabling more efficient information transfer and actionable data for businesses than ever. These advances will affect all aspects of our lives, including work, and the possibilities are great. We’ll keep our focus forward, so that wherever we’re going, we’re always embarking on what’s next.
    Read More..

    Service Oriented Architecture

    | 0 comments |
    Hi,

    I am an Architect in the Software Industry. I know the need for such a role is hotly debated one. But for now, I can do with such a designation.

    Service Oriented Architecture is a buzz-word since almost 3-4 years now. I believe that it has not caught up as fast as it promised to. However, there is definitely benefits that can be derived out of its implementation (if done right) across large enterprises.

    My opinion on this is that it is almost a sure failure, if it is taken up in a big bang way for implementation. It has to be planned and taken up in phases with calculated but less risky applicaitons initially. Once the technical success of it is ascertained, the applications of business value need to be taken up to move towards this architecture.

    Though lot is said about this in various forums, I am yet to hear anyone say confidently that much of their enterprise has taken to SOA.

    Anyones thoughts on this?
    Do you think Business critical applications should be taken up to prove the business value to the enterprise for a pilot phase or less critical applications should be piloted, to absorb and risk of failure?
    Read More..

    Episode 34 Really Nearby

    | 0 comments |
    In this episode, we chat with Andrew Bunner and Akshay Kannan from the Nearby team. Nearby is a technology that allows devices that are, er, nearby to communicate in one of several ways (including ultrasonic frequencies, which is just kind of awesome).

    Favorite bits: "beeps and boops" (a technical term), "acoustical chamber" (sounds a lot cooler than it probably is), and the three most important things about Nearby: proximity, proximity, proximity.

    Subscribe to the podcast feed or download the audio file directly.

    Nearby Product Overview

    Andrew: google.com/+AndrewBunner
    Akshay: google.com/+AkshayKannan
    Tor: google.com/+TorNorbye
    Chet: google.com/+ChetHaase
    Read More..

    Get ready for even more material design

    | 0 comments |

    Posted by Monica Bagagem, Developer Marketing

    Google I/O 2015 starts tomorrow, and, like last year, we’ve got an exciting lineup of design-focused content for both developers and designers to experience in-person and online. Just a year ago, we announced material design - a system for cross-platform visual, motion, and interaction design. This year at I/O, we’ll see how material has been adopted and implemented by the community, and our approach on design across our platforms.

    Sessions

    At 4PM PDT on Thursday, May 28, join Matias Duarte’s “Material Now” session to recap where we’ve been and get a sneak peek of where we’re going with design at Google. We’ll be recognizing some of the phenomenal material design work from across the community, so definitely tune in if you’re an Android developer or designer. For more details, check Matias’ post on Google+.

    The session will be live streamed so you can follow along in real-time even if you’re not at Moscone. Recordings will also be available shortly after on the I/O website.

    Add Design Sessions to your I/O schedule

    Design Sandbox

    We’ve dedicated an entire section of Moscone West to design-related programming, including one-on-one and group UX reviews with members of the material design team. Appointments will be on a first-come, first-serve basis, but well also have Google designers on hand for more casual questions.

    Add Material Design Reviews to your I/O schedule

    Sandbox Talks

    Google designers and engineers will host several deep-dive, 20 minute tech talks in a breakout area within the Design Sandbox on Level 2. The space has been designed to facilitate conversation and discussion with small audiences, so come prepared with questions! We’ll be covering a range of topics such as cross-platform and responsive design, designing for platforms like Google Cast and Android Auto, and how to adapt material design to your brand. As an added bonus, most Sandbox Talks will take place twice throughout the conference giving you more flexibility to adjust your schedule.

    Add Design Sandbox Talks to your I/O schedule

    Explore the full Google I/O schedule here.

    Be sure to follow +GoogleDesign and @GoogleDesign, where we’ll be posting design-related announcements throughout the conference. You can also follow and join the general conversation about I/O at #io15. See you tomorrow!

    Read More..