Posts

Showing posts from July, 2012

Text to Speech Example in Android

Image
TEXTTOSPEECH:

this code text to speech simple example code 

SOURCE CODE


public class MainActivity extends Activity implements OnInitListener {

    TextToSpeech textTalker;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        Button tv=(Button)findViewById(R.id.button1);


        textTalker = new TextToSpeech(this, this);

        tv.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                // TODO Auto-generated method stub
                 EditText et=(EditText)findViewById(R.id.editText1);
                 textTalker.speak(et.getText().toString(), TextToSpeech.SUCCESS, null);//if it not work with this use below commented line

                //textTalker.speak(intentDataHolder.getString("MsgTxt"), TextToSpeech.QUEUE_ADD, null);
            }

        });
    }

    @Override
    public void onDestroy() {
        if (textTalker != null) {
            tex…

XMLResource Parser With Custem Listiew From Local XML In Android.

Image
XMLResource Parser With Custem Listiew From Local XML In Android. XMLResource Parser With Custem Listiew From Local XML In Android.


 Xml Resource parser from local xml in android

it's parsing data from localxml


 anylocation.xml
from xml foder

<?xml version="1.0" encoding="UTF-8"?>
<jointData>
    <city>
            <option value="">Any Location</option>
            <option value="1">Salem</option>
            <option value="2">Chennai</option>
            <option value="3">Kovai</option>
            <option value="4">Bangalore</option>
            <option value="5">Triandrum</option>
            <option value="6">Madurai</option>
            <option value="7">Salem</option>
            <option value="8">Chennai</option>
            <option value=&qu…

Pull to refresh ListView in Android

Image
Pull to Refresh ListView in Android. Pull to Refresh ListView in Android. It will allow to user pulling down  and releasing from the top of the list. Then come to basic coding part PulltoRefresh.
Here you can fine some better example for pulltorefresh. https://github.com/chrisbanes/Android-PullToRefresh Custem ListView pull_to_refresh_listview.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"     android:orientation="vertical"     android:layout_width="fill_parent"     android:layout_height="fill_parent"     >        <com.pulltorefresh.mad.PullToRefreshView         xmlns:ptr="http://schemas.android.com/apk/res/com.pulltorefresh.mad"         android:id="@+id/pull_refresh_list"         android:layout_height="fill_parent"         android:layout_width="fill_parent"         ptr:ptrMode="both"         /> </LinearLayo…

Android interview questions and Answers

What is Android?
Android is a stack of software for mobile devices which includes an Operating System, middleware and some key applications. The application executes within its own process and its own instance of Dalvik Virtual Machine. Many Virtual Machines run efficiently by a DVM device. DVM executes Java languages byte code which later transforms into .dex format files.


What is an Activity?
A single screen in an application, with supporting Java code.

What is an Intent?
A class (Intent) which describes what a caller desires to do. The caller will send this intent to Android's intent resolver, which finds the most suitable activity for the intent. E.g. opening a PDF document is an intent, and the Adobe Reader apps will be the perfect activity for that intent (class).

What is a Sticky Intent?
sendStickyBroadcast() performs a sendBroadcast(Intent) known as sticky, i.e. the Intent you are sending stays around after the broadcast is complete, so that others can quickly retrieve that data …

Java Interview questions and answers

Q1.WhatisthedifferencebetweenanAbstractclassandInterface?
1. Abstract classes may have some executable methods and methods left
unimplemented. Interfaces contain no implementation code.
2. An class can implement any number of interfaces, but subclass at most one abstract class.
3. An abstract class can have nonabstract methods. All methods of an interface are
abstract.
4. An abstract class can have instance variables. An interface cannot.
5. An abstract class can define constructor. An interface cannot.
6. An abstract class can have any visibility: public, protected, private or none
(package). An interface's visibility must be public or none (package).
7. An abstract class inherits from Object and includes methods such as clone() and
equals().
Q2.Whatarecheckedanduncheckedexceptions?
Java defines two kinds of exceptions :
• Checkedexceptions:Exceptions that inherit from the Exceptionclassare
checkedexceptions. Client code has to handle the checked exceptions thrown by
the API, either in a catch c…