Hi developers...........................

                    First of all thanks for the greate replies. Now i
have a very strange problem. Now i can access all the sms those have
"hello" in their body. I want to send the content of each sms to
another program. But the problem is i can able to send only the the
content of last sms.I mean all the sms send the same thing the content
of last sms. I have tried a lot to solve the problem. But i cant send
the each content of each sms . I give u the coding.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

import android.app.Activity;
import android.app.ListActivity;
import android.content.ContentUris;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.provider.Contacts.People;
import android.provider.Telephony.Carriers;
import android.widget.LinearLayout;

import android.telephony.gsm.SmsMessage;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;
import android.widget.TextView;

public class tele extends Activity {

        TextView ms1;
        TextView ms2;
          String MyMsg = "";
     // Button ms1;
      /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        setContentView(R.layout.main);

       // ms1=(Button)findViewById(R.id.ms1);
        LinearLayout layout = (LinearLayout) findViewById(R.id.ms1);
        LinearLayout.LayoutParams p = new
        LinearLayout.LayoutParams(
                            LinearLayout.LayoutParams.FILL_PARENT,
                            LinearLayout.LayoutParams.WRAP_CONTENT
                    );

        Uri uri = Uri.parse("content://sms/inbox");
        Cursor c= getContentResolver().query(uri, null, "body like
'%hello%'",null,null);

       // Cursor c = getContentResolver().query(Carriers.CONTENT_URI,
null, null, null, null);
        startManagingCursor(c);

        if(c.getCount() !=0)
        {
                    String[] str = new String[c.getCount()];
                    int i = 0;
                    if(c.moveToFirst())
                    {
                        do
                        {

                                str[i] = (c.getString
(c.getColumnIndexOrThrow("body"))).toString();

                                i++;

                        }while(c.moveToNext());
                   }

                    ////////////////////
                    int j;
                   int Myi;
                   for (Myi=0; Myi < str.length; Myi++)
                   {

                           if ( str[Myi].indexOf("hello") >= 0 )
                           {
                                   MyMsg = str[Myi] ;
                                   Button buttonView = new Button(this);
                           buttonView.setText(  str[Myi]);
                           layout.addView(buttonView,p);


                           buttonView.setOnClickListener(
                                           new LinearLayout.OnClickListener() {
                                                public void onClick(View arg0) {
                                                        Intent myIntent = new 
Intent();
                                                        myIntent.setClassName
("com.android.tele", "com.android.tele.Hello2");
                                                        //myIntent.putExtra
("com.android.HelloBye.heby", "Hello Joe!"); // key/value pair, where
key needs current package prefix.
                                                        
myIntent.putExtra("nikvar", MyMsg);
                                                        
//myIntent.putExtra("niva",
"Martin");// key/value pair, where key needs current package prefix.
                                                        startActivity(myIntent);

                                                }
                                        }
                           );


                           }
                   }




         }
      /*  LinearLayout ms1=(LinearLayout)findViewById(R.id.ms1);
        ms1.setOnClickListener(new LinearLayout.OnClickListener() {
                public void onClick(View arg0) {
                        Intent myIntent = new Intent();
                        myIntent.setClassName("com.android.tele",
"com.android.tele.Hello2");
                        //myIntent.putExtra("com.android.HelloBye.heby", "Hello
Joe!"); // key/value pair, where key needs current package prefix.
                        myIntent.putExtra("nikvar", "Ricky");
                        //myIntent.putExtra("niva", "Martin");// key/value pair,
where key needs current package prefix.
                        startActivity(myIntent);

                }
        });

*/
    }



}


/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

I think u can understand my problem. I expect a good response. Thanks
in advance.

 
Suman.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to