Android Address Book Search

by mike » Wed, 02 Jun 2010 01:15:14 GMT


Sponsored Links
 hi guys,

i have developed a application which loads all the contacts in the
native address book.
since i have many contacts i created a search.

my address book contains contacts like this.

Alan
Bill

and then again

Alex
Cooper
Dillon

1. even in the native address book it's the same. may i know the
reason for that. (All my contacts are in phone book)

2. i using phones.CONTENT_URI to load all the contacts. that's how i
want to do it

and assume that i have search for Alan or Bill search query returns
nothing

but if i search foe Alex,Cooper or Dillon it will return the correct
result

this is my query

        private Cursor searchItems(String query) {
                Cursor cur = getContentResolver().query(Phones.CONTENT_URI , 
null,
                                Phones.NAME + "='" + query.trim() + "'", null, 
null);
                startManagingCursor(cur);
                int x = cur.getCount();
                if (cur == null || x == 0) {
                        // alert("Address Book", "Empty Address Book");
                }
                if (cur.moveToNext()) {
                        do {
                                Log.d("CURSOR_SSSS", Integer.toString(x));
                        } while (cur.moveToNext());
                }
                columns = new String[] { Phones.NAME, Phones.NUMBER };
                names = new int[] { R.id.contactName, R.id.number };
                return cur;
        }

could somebody help me out??

regards,
Mike

--



Other Threads

1. To make the listed items clickable

Hi all,

         I am a beginner  in the field of android.I just displayed the
items from the database using the webservice through  SOAP .Currently
the displayed items are in tex view. I wanna to make it them
clickable.How can i do that??  plz somone help me..

Thanks in advance,

Here is the code i used:

package grid.test;
import java.util.Vector;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.AndroidHttpTransport;
import grid.test.R;
import android.app.Activity;
//import android.content.Intent;
import android.os.Bundle;
//import android.widget.ArrayAdapter;
import android.widget.Button;
//import android.widget.ListView;
import android.widget.TextView;
import android.view.*;

import android.widget.TextView;

public class screen2 extends Activity
{

        /** Called when the activity is first created. */
        private static final String SOAP_ACTION = "getMessage";
    private static final String METHOD_NAME = "getMessage";
    private static final String NAMESPACE = "";
    // !!!!! IMPORTANT!!!!! THE URL OF THE CoLDFUSION WEBSERVER NOT
LOCALHOST BECAUSE LOCALHOST IS THE ANDROID EMULATOR !!!!!

   public void onCreate(Bundle icicle)
   {

      super.onCreate(icicle);
      setContentView(R.layout.screen2);
      Bundle extras = getIntent().getExtras();
      TextView tv = new TextView(this);

      tv.setText(extras.getString("keyName"));

      TextView mytitletext = (TextView) findViewById(R.id.text);
      mytitletext.setText(extras.getString("keyName"));
      final String URL = "http://www.bestindiancooking.com/
get_user_submitted_recipes.php?id="+extras.getString("keyName");


    //CALL the web service method with the two parameters vname and
nname
      SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
        request.addProperty("nname", "Christian");
        request.addProperty("itemdescription", "Braun");


      SoapSerializationEnvelope envelope = new
SoapSerializationEnvelope(SoapEnvelope.VER11);
      envelope.setOutputSoapObject(request);
      AndroidHttpTransport androidHttpTransport = new
AndroidHttpTransport (URL);
      try {
        androidHttpTransport.call(SOAP_ACTION, envelope);

        // Get the SAOP Envelope back and the extract the body
        SoapObject resultsRequestSOAP = (SoapObject) envelope.bodyIn;

        Vector XXXX = (Vector)
resultsRequestSOAP.getProperty("getMessageReturn");

             //Count of the arrays beneath starting from 0
        //You can see the buildup with the php site with nusoap
http://localhost/DA/nusoapclient_test2.php
        int testat = XXXX.size();

        // It depends on how many arrays we  have we can get to the
attributs of one of them with get(0), get(1) ....
        Integer i;
        String rec_count;

        SoapObject test_cnt = (SoapObject) XXXX.get(0);
        rec_count= (String) test_cnt.getProperty("ncount");


   ((TextView)findViewById(R.id.lblStatus)).append(rec_count.toString()
+"\n");



       for(i=1;i< 10;i++)
        {


        SoapObject test = (SoapObject) XXXX.get(i);

        String rec_name,preparation_time;


        rec_name=(String) test.getProperty("recipe_name");
        preparation_time=(String)
test.getProperty("preparation_time");


 
((TextView)findViewById(R.id.lblStatus)).append(rec_name.toString()
+"\t");
 
((TextView)findViewById(R.id.lblStatus)).append(preparation_time.toString()
+"\n");

         /*final ListView lv = getListView();

         setListAdapter(new ArrayAdapter<String>(this,
R.layout.screen2,XXXX));

         View ListView;
         lv.setTextFilterEnabled(true);*/
        }



      } catch(Exception E) {

        ((TextView)findViewById(R.id.lblStatus)).setText("ERROR:" +
E.getClass().getName() + ": " + E.getMessage()+"error");

      }


      Button b = (Button) findViewById(R.id.btnClick2);
      b.setOnClickListener(new View.OnClickListener() {
         public void onClick(View arg0) {

         setResult(RESULT_OK);
         finish();
         }
      });

   }

        }

-- 

2. Make the Video size play in full screen (stretch to fit width and height)

Hello Everyone,
  I have this question regarding on how to create a player in my application 
to play a video in fullscreen(stretch to fit width and height).
  I have this in my code already and setting the layout width and height in 
the ui xml file to fill parent but still does not stretch to fit the width.
protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        Log.v( TAG , "onCreate");
        super.onCreate(savedInstanceState);        
        this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
                                  WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.player);
        
        Bundle extra = this.getIntent().getExtras();
this.mVideo = extra.getBundle(VIDEO);
                
        VideoView vidView = (VideoView)this.findViewById(R.id.vidView);
vidView.setVideoPath(this.mVideo.getString(URL));
        vidView.setOnPreparedListener(this);
        MediaController ctrl = new MediaController(this);
        ctrl.setMediaPlayer(vidView);
        vidView.setMediaController(ctrl);
        vidView.requestFocus();        
    }

Thanks,
-Brian


      

-- 

3. WPA-EAP support in Android

4. Namespaces and custom widgets

5. 0xlab released new 0xdroid: beagle-eclair-0x4, devkit8k-eclair-0x4

6. Device Driver access via native functions called via JNI

7. T-Mobile myTouch 3G Slid