Posts

Showing posts from April, 2014

Android Shutdown Sequence

Image
What happened when I long press power button ? What is shutdown sequence ? How is it different from desktop linux shutdown sequence? How to change shutdown menu ? Many questions pop-up in mind when we think about Android shutdown sequence. Before you read about shutdown sequence I suggest you to read about  boot sequence article . Android is linux based open source operating system, x86 (x86 is a series of computer microprocessor instruction set architectures based on the Intel 8086 CPU.) is most likely system where linux kernel is deployed however all Android devices are running on ARM process (ARM (formerly Advanced RISC Machine, which was formerly Acorn RISC Machine)) except Intel’s Xolo device ( http://xolo.in/xolo-x900-features ). Xolo comes with Atom 1.6 GHz x86 processor. Android shutdown sequence is different from desktop linux like ubuntu, fedora, etc. In this article I am going to explain shutdown sequence for Android only. Please refer  “Linux Boot and Shutdown

Voice Recognition

Image
This post about how to search voice based search places instead typing the text. Source Code Call Voice recognition   Intent intent = new Intent ( RecognizerIntent . ACTION_RECOGNIZE_SPEECH);          intent . putExtra ( RecognizerIntent . EXTRA_LANGUAGE_MODEL, RecognizerIntent . LANGUAGE_MODEL_FREE_FORM);          intent . putExtra ( RecognizerIntent . EXTRA_PROMPT, "Tell me what you want"); Retrun  Result Method  @Override      protected  void onActivityResult ( int requestCode, int resultCode, Intent data) {         if(requestCode == REQUEST_RECOGNIZE && resultCode == Activity.RESULT_OK) {             ArrayList<String> matches = data . getStringArrayListExtra ( RecognizerIntent . EXTRA_RESULTS);             StringBuilder  sb  = new StringBuilder ( );              for ( String piece : matches) {                  sb . append ( piece);                 sb.append('\n');             }              if ( matches . size ( ) !=0){        

Run Multiple AsyncTask at the same time

Android Run Multiple AsyncTask Same Time Problem: I am trying to excute Multiple asynctask same time(Android Version 4.0.1) but onPreExcute method only called  after that nothing happen. Solution . AsyncTask uses a thread pool pattern for running the stuff from doInBackground(). The issue is initially (in early Android OS versions) the pool size was just 1, meaning no parallel computations for a bunch of AsyncTasks. But later they fixed that and now the size is 5, so at most 5 AsyncTasks can run simultaneously.  -->  if  (Build.VERSION. SDK_INT  >= Build.VERSION_CODES. HONEYCOMB ) { TestAsyncTask firstAsync =  new  TestAsyncTask(); firstAsync.executeOnExecutor(AsyncTask. THREAD_POOL_EXECUTOR ); } else { TestAsyncTask firstAsync =  new  TestAsyncTask(); firstAsync.execute(); }

Remove and Undo Listview Item with slide

Image
Screen Shot  Source Code  Activity Code : package  com.example.undo; import  java.util.ArrayList; import  android.app.ListActivity; import  android.content.Context; import  android.os.Bundle; import  android.view.LayoutInflater; import  android.view.View; import  android.view.ViewGroup; import  android.widget.TextView; public   class  MyListActivity  extends  ListActivity {         @Override         protected   void  onCreate(Bundle savedInstanceState) {                super .onCreate(savedInstanceState);               getListView().setDivider( null );        }         protected  ArrayAdapter<String> createListAdapter() {                return   new  MyListAdapter( this ,  getItems ());        }         public   static  ArrayList<String> getItems() {               ArrayList<String> items =  new  ArrayList<String>();                for  ( int  i = 0; i < 1000; i++) {