Tuesday, September 27, 2011

English Speaking Tips

English Speaking Tips You Must KnowVisiting a new place can be a scary experience for a lot of people, not only because it could entail speaking in a language that most people are not comfortable with – English. If you are born a native English speaker, then you will have no problem speaking English naturally. But for those people whose mother tongue is not English, this can be a problem. So how can you avoid this kind of situation? Learn how to speak English fluently. Most people think that this is easier said than done, but in reality, it is actually easy to speak fluent English. English is the universal language, and this universal concept makes it one of the easiest languages to master. Here are 7 English speaking tips you must know to become a more confident English speaker.

1. Listen first

One of the best English speaking tips is to listen carefully to understandable English EVERY DAY. Most people turn to textbooks to study English grammar rules, but you cannot learn the correct English pronunciation of the words by just mere reading them.

Instead, listen to how native English speakers enunciate their words and observe their mouth movements. Try to imitate the intonation and rhythm of their speech. Also watch English shows and movies to build on your English accent and improve your vocabulary.

2. Do not be too conscious on the grammar

Yes, it is important to learn the basic grammar rules in English. However, you do not need to learn grammar in detail because this can distract you from speaking English fluently. Most people tend to concentrate more on not committing any grammatical errors while talking, so oftentimes, their accents become stilted. Grammar rules make you think about English when what you want to do is to speak better English naturally without sounding too forced.

3. Practice makes perfect

The cardinal rule in English speaking – practice, practice, practice! Studies show that you’ll probably spend three months of practice everyday in order to have strong mouth muscles and get the hang of in speaking a new language. Read aloud in English for 15 to 20 minutes a day in front of the mirror. Try the articulation exercises which help in accent reduction or neutralization in order for you to improve your English communication skills.
Also, practice with your friends and family. Talking with a good English speaker can help improvise your usage of words and formation of sentences.

4. Think in English

One of the most effective English speaking tips is to think in English. What most English learners do in the early stages of learning is that they think of what they have to say in their native language, translate and then tell it in English. This can be mentally exhausting and time consuming. And oftentimes, the English sentences that are constructed are flawed.

If your goal is to speak English fluently, you need to learn “thinking “in English. Construct the sentences in English as you think about them before saying them. With practice, you will be able to respond automatically in English.

5. Be more confident

All these English speaking tips will be in vain if you are not that confident on your English speaking skills. It is quite natural to commit errors when learning a new language. Even native English speakers commit grammatical errors every now and then. Do not be too hesitant when speaking because this can make you stammer or make the conversation sound stilted and too forced. But, do not also speak too fast because it will be difficult for people to understand you.
Try to relax if you’re speaking in English. When you speak at a normal speed, you’ll discover that you will be able to pronounce the words correctly and automatically. And if ever you did make a mistake, do not dwell on it so much. Most of the time, the person you are talking to is not even aware of your errors.

6. Find English lessons online

Some people like to invest their money in tutorials and other English courses, but you can learn how to speak English fluently from the comforts of your own home! Learn English online by signing up with schools that offer online tutorials or just download English books for self-study purposes. Online English lessons will allow you to learn English at your own pace. Plus, the prices are generally far lower than an in-person course.

One of online English lessons is “Effortless English (Power English Lesson)” which is a digital information product for learning English speaking.  Effortless English actually provides audio materials and guide hand outs which will help you in learning American English or help you improve English speaking skills.

7.  Be patient

Just remember to be patient. Learning English does not happen overnight. It takes a lot of time, effort and practice. Don’t get too frustrated and never give up. Follow these English speaking tips and practice daily. Soon, you would learn to speak English fluently as if it is your own dialect.

What are the differences between HashMap and Hashtable?

Both provide key-value access to data. The Hashtable is one of the original collection classes in Java. HashMap is part of the new Collections Framework, added with Java 2, v1.2.
The key difference between the two is that access to the Hashtable is synchronized on the table while access to the HashMap isn't. You can add it, but it isn't there by default.
Another difference is that iterator in the HashMap is fail-safe while the enumerator for the Hashtable isn't. If you change the map while iterating, you'll know.
And, a third difference is that HashMap permits null values in it, while Hashtable doesn't.

For new code, I would tend to always use HashMap. 


Difference between HashMap and HashTable?
A: The HashMap class is roughly equivalent to Hashtable, except that it is unsynchronized and permits nulls. (HashMap allows null values as key and value whereas Hashtable doesnt allow). HashMap does not guarantee that the order of the map will remain constant over time. HashMap is unsynchronized and Hashtable is synchronized.

1. The HashMap class is roughly equivalent to Hashtable, except that it is non synchronized and permits nulls. (HashMap allows null values as key and value whereas Hashtable doesn't allow nulls).
2. HashMap does not guarantee that the order of the map will remain constant over time.
3. HashMap is non synchronized whereas Hashtable is synchronized.
4. Iterator in the HashMap is  fail-fast  while the enumerator for the Hashtable is not and throw ConcurrentModificationException if any other Thread modifies the map structurally  by adding or removing any element except Iterator's own remove()  method. But this is not a guaranteed behavior and will be done by JVM on best effort.

Note on Some Important Terms
1)Synchronized means only one thread can modify a hash table at one point of time. Basically, it means that any thread before performing an update on a hashtable will have to acquire a lock on the object while others will wait for lock to be released.

2)Fail-safe is relevant from the context of iterators. If an iterator has been created on a collection object and some other thread tries to modify the collection object "structurally", a concurrent modification exception wjavascript:void(0)ill be thrown. It is possible for other threads though to invoke "set" method since it doesn't modify the collection "structurally". However, if prior to calling "set", the collection has been modified structurally, "IllegalArgumentException" will be thrown.

3)Structurally modification means deleting or inserting element which could effectively change the structure of map.

HashMap can be synchronized by

Map m = Collections.synchronizeMap(hashMap);

 

Java Interview Questions

Q: What is the difference between an Interface and an Abstract class?
A: An abstract class can have instance methods that implement a default behavior. An Interface can only declare constants and instance methods, but cannot implement default behavior and all methods are implicitly abstract. An interface has all public members and no implementation. An abstract class is a class which may have the usual flavors of class members (private, protected, etc.), but has some abstract methods.
.

Q: What is the purpose of garbage collection in Java, and when is it used?
A: The purpose of garbage collection is to identify and discard objects that are no longer needed by a program so that their resources can be reclaimed and reused. A Java object is subject to garbage collection when it becomes unreachable to the program in which it is used.

Q: Describe synchronization in respect to multithreading.
A: With respect to multithreading, synchronization is the capability to control the access of multiple threads to shared resources. Without synchonization, it is possible for one thread to modify a shared variable while another thread is in the process of using or updating same shared variable. This usually leads to significant errors. 

Q: Explain different way of using thread?
A: The thread could be implemented by using runnable interface or by inheriting from the Thread class. The former is more advantageous, 'cause when you are going for multiple inheritance..the only interface can help.

Q: What are pass by reference and passby value?
A: Pass By Reference means the passing the address itself rather than passing the value. Passby Value means passing a copy of the value to be passed. 

Q: What is HashMap and Map?
A: Map is Interface and Hashmap is class that implements that.

Q: Difference between HashMap and HashTable?
A: The HashMap class is roughly equivalent to Hashtable, except that it is unsynchronized and permits nulls. (HashMap allows null values as key and value whereas Hashtable doesnt allow). HashMap does not guarantee that the order of the map will remain constant over time. HashMap is unsynchronized and Hashtable is synchronized.

Q: Difference between Vector and ArrayList?
A: Vector is synchronized whereas arraylist is not.

Q: Difference between Swing and Awt?
A: AWT are heavy-weight componenets. Swings are light-weight components. Hence swing works faster than AWT.

Q: What is the difference between a constructor and a method?
A: A constructor is a member function of a class that is used to create objects of that class. It has the same name as the class itself, has no return type, and is invoked using the new operator.
A method is an ordinary member function of a class. It has its own name, a return type (which may be void), and is invoked using the dot operator.

Q: What is an Iterator?
A: Some of the collection classes provide traversal of their contents via a java.util.Iterator interface. This interface allows you to walk through a collection of objects, operating on each object in turn. Remember when using Iterators that they contain a snapshot of the collection at the time the Iterator was obtained; generally it is not advisable to modify the collection itself while traversing an Iterator.

Q: State the significance of public, private, protected, default modifiers both singly and in combination and state the effect of package relationships on declared items qualified by these modifiers.
A: public : Public class is visible in other packages, field is visible everywhere (class must be public too)
private : Private variables or methods may be used only by an instance of the same class that declares the variable or method, A private feature may only be accessed by the class that owns the feature.
protected : Is available to all classes in the same package and also available to all subclasses of the class that owns the protected feature.This access is provided even to subclasses that reside in a different package from the class that owns the protected feature.
default :What you get by default ie, without any access modifier (ie, public private or protected).It means that it is visible to all within a particular package
.

Q: What is an abstract class?
A: Abstract class must be extended/subclassed (to be useful). It serves as a template. A class that is abstract may not be instantiated (ie, you may not call its constructor), abstract class may contain static data. Any class with an abstract method is automatically abstract itself, and must be declared as such.
A class may be declared abstract even if it has no abstract methods. This prevents it from being instantiated.

Q: What is static in java?
A: Static means one per class, not one for each object no matter how many instance of a class might exist. This means that you can use them without creating an instance of a class.Static methods are implicitly final, because overriding is done based on the type of the object, and static methods are attached to a class, not an object. A static method in a superclass can be shadowed by another static method in a subclass, as long as the original method was not declared final. However, you can't override a static method with a nonstatic method. In other words, you can't change a static method into an instance method in a subclass.

Q: What is final?
A: A final class can't be extended ie., final class may not be subclassed. A final method can't be overridden when its class is inherited. You can't change value of a final variable (is a constant).

Tuesday, September 20, 2011

Listview using checkbox resolved issue.

// itemChecked will store the position of the checked items.
public MyDataAdapter(Context context, int layout, Cursor c, String[] from,
        int[] to) {
    super(context, layout, c, from, to);
    this.c = c;
    this.context = context;

    for (int i = 0; i < this.getCount(); i++) {
        itemChecked.add(i, false); // initializes all items value with false
    }
}
public View getView(final int pos, View inView, ViewGroup parent) {
    if (inView == null) {
        LayoutInflater inflater = (LayoutInflater) context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        inView = inflater.inflate(R.layout.your_layout_file, null);
    }

    final CheckBox cBox = (CheckBox) inView.findViewById(R.id.bcheck); // your
    // CheckBox
    cBox.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {

            CheckBox cb = (CheckBox) v.findViewById(R.id.your_checkbox_id);

            if (cb.isChecked()) {
                itemChecked.set(pos, true);
                // do some operations here
            } else if (!cb.isChecked()) {
                itemChecked.set(pos, false);
                // do some operations here
            }
        }
    });
    cBox.setChecked(itemChecked.get(pos)); // this will Check or Uncheck the
    // CheckBox in ListView
    // according to their original
    // position and CheckBox never
    // loss his State when you
    // Scroll the List Items.
    return inView;
}}

Thursday, September 15, 2011

Google Map Example

http://www.vogella.de/articles/AndroidLocationAPI/article.html

Action_Send display popup whatever you required.

 final Intent emailIntent = new Intent(
                                android.content.Intent.ACTION_SEND_MULTIPLE);

                        // Recording file send to mail
                        //emailIntent.setType("image/png");
                        //emailIntent.setType("audio/3gp");
                        emailIntent.putExtra("data", sourceImageBitmap);
                       emailIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                        //emailIntent.setType("application/email");
                        emailIntent.setType("vnd.android.cursor.dir/email");
                        emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] {"user@example.com"});

                        emailIntent.putExtra(
                                android.content.Intent.EXTRA_EMAIL,
                                new String[] { getSharedPreferences(
                                        "emailedittext", 0).getString(
                                        "emailedittext_value", "") });
                        emailIntent.putExtra(
                                android.content.Intent.EXTRA_SUBJECT,
                                "Complaint");
                        emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,
                                "Attached in the mail is the complaint for coordinate"
                                        + "\n" + "latitude "
                                        + issueLatitudeString + "\n"
                                        + "longitude " + issueLongitudeString
                                        + "\n" + "for place "
                                        + issueAddressString );
                       
                        String s = emailIntent.getPackage();
                        emailIntent.putParcelableArrayListExtra(
                                Intent.EXTRA_STREAM, uris);
                   
                        final PackageManager pm = getPackageManager();
                        final List<ResolveInfo> matches = pm
                                .queryIntentActivities(emailIntent, 0);
                        final ResolveInfo[] best = new ResolveInfo[matches
                                .size()];
                        ArrayList<String> emailList = new ArrayList<String>();
                        String space = "    ";
                        itemActivity = 0;
                        for (final ResolveInfo info : matches) {
                            if ( info.activityInfo.applicationInfo.className
                                            .toLowerCase().contains("mail")) {
                                best[itemActivity] = info;
                              
                                String res = info.activityInfo.applicationInfo.className;
                                emailList.add(space
                                        + res.substring(res.lastIndexOf(".") + 1));
                                                                    
                                itemActivity++;
                            }
                        }
                        int i = 0;
                        String item[] = new String[emailList.size()];
                        for (String string : emailList) {
                            item[i++] = string;
                        }
                      
                        if (item[0]!=null) {
                            AlertDialog.Builder builder = new AlertDialog.Builder(
                                    NewIssue.this);
                            builder.setTitle("Pick an item");
                            builder.setIcon(best[0].activityInfo.getIconResource());
                            builder.setItems(item,
                                    new DialogInterface.OnClickListener() {
                                        public void onClick(
                                                DialogInterface dialog, int item) {

                                            emailIntent
                                                    .setClassName(
                                                            best[item].activityInfo.packageName,
                                                            best[item].activityInfo.name);
                                            startActivity(emailIntent);
                                            finish();

                                        }
                                    });
                            //builder.setIcon(best[itemActivity-1].activityInfo.icon);
                            AlertDialog alert = builder.create();
                            alert.show();
                        } else {
                            startActivity(emailIntent);
                        }

android.database.sqlite.DatabaseObjectNotClosedException: Application did not close the cursor or database object that was opened here

simple used startManagingCursor(cursor);

Android Development

Welcome to viren savaliya's android blog.

SEND MAIL

Intent sendIntent = new Intent(Intent.ACTION_SEND);
// Add attributes to the intent
sendIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
sendIntent.putExtra(Intent.EXTRA_SUBJECT,"subject line");
sendIntent.putExtra(Intent.EXTRA_TEXT,"Body of email");
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File("Filename")));
sendIntent.setType("vnd.android.cursor.dir/email");

startActivity(Intent.createChooser(sendIntent,"Email:"));

Saturday, September 10, 2011

Auto Complete

Auto Complete

To create a text entry widget that provides auto-complete suggestions, use the AutoCompleteTextView widget. Suggestions are received from a collection of strings associated with the widget through an ArrayAdapter


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

    AutoCompleteTextView textView = (AutoCompleteTextView) findViewById(R.id.autocomplete_country);
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.list_item, COUNTRIES);
    textView.setAdapter(adapter);
setContentView(textView);}
.

Android designing tools

This tool was written to make my Java programming life easier. It can be used to build graphical user interfaces (GUI) for the Android cell phone platform. I hope you find it useful for whatever Android/Java cell phone software development projects you have planned!

download http://www.droiddraw.org/
content -->