[android-developers] Re: Unique problem only for the EXPERTS.

2009-01-06 Thread Charlie Collins

Here is an example of getting the SmsMessage object:

http://unlocking-android.googlecode.com/svn/chapter7/trunk/TelephonyExplorer/src/com/msi/manning/telephonyexplorer/SmsReceiver.java

The SmsMessage has various methods to get at different parts of the
message, including the body as a String.

On Jan 6, 2:33 am, IPEG Student ipeg.stud...@gmail.com wrote:
 Hi,

 Thanks a lot for the problem, but I'm still unfortunately at square one.

 
 Here is what I need:

 Read an SMS into a string variable, then do some string operations.

 For example, how can I find the first character of an SMS?

 Thanks in advance for helping me out.

 ###

 On 1/6/09, Ninad mnina...@gmail.com wrote:



  Hi..

  All you need is simple SQL..

  Modify the Cursor as:

             Cursor c= getContentResolver().query(uri, null, body like
  '%hello%', null,null);

  Since the query takes the following argument:

  public final Cursor query(Uri uri, String[] projection, String
  selection, String[] selectionArgs, String sortOrder)
  .
  Arguments:

  uri:  The URI, using the content:// scheme, for the content to
  retrieve.
  projection:  A list of which columns to return. Passing null will
  return all columns, which is discouraged to prevent reading data from
  storage that isn't going to be used.
  selection:  A filter declaring which rows to return, formatted as an
  SQL WHERE clause (excluding the WHERE itself). Passing null will
  return all rows for the given URI.
  selectionArgs:  You may include ?s in selection, which will be
  replaced by the values from selectionArgs, in the order that they
  appear in the selection. The values will be bound as Strings.
  sortOrder:  How to order the rows, formatted as an SQL ORDER BY clause
  (excluding the ORDER BY itself). Passing null will use the default
  sort order, which may be unordered.

  I hope this solves your simple query for 'experts'!

  On Jan 6, 9:31 am, ipeg.stud...@gmail.com wrote:
   Hi! am Suman. I have a code by which i can access all the sms from
   inbox. The code is written below.

   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.telephony.gsm.SmsMessage;
   import android.view.View;
   import android.widget.ListAdapter;
   import android.widget.ListView;
   import android.widget.SimpleCursorAdapter;

   public class niceandroid8 extends ListActivity {

        private ListAdapter mAdapter;

         /** Called when the activity is first created. */
       @Override
       public void onCreate(Bundle icicle) {
           super.onCreate(icicle);
           Uri uri = Uri.parse(content://sms/inbox);
           Cursor c = getContentResolver().query(uri, null, null,
                           null,null);
          // Cursor c = getContentResolver().query(Carriers.CONTENT_URI,
   null, null, null, null);
           startManagingCursor(c);

           String[] columns = new String[]{body}; // Comment
           int[] names = new int[]{R.id.row_entry};

           mAdapter = new SimpleCursorAdapter(this, R.layout.con1, c,
   columns, names);

           this.setListAdapter(mAdapter);
       }

   }

   xml coding is..

   ?xml version=1.0 encoding=utf-8?

   LinearLayout xmlns:android=http://schemas.android.com/apk/res/
   android
       android:orientation=horizontal
       android:layout_width=fill_parent
       android:layout_height=wrap_content

   TextView
       android:layout_width=wrap_content
       android:layout_height=wrap_content
       android:text=Sms: 
       /
   TextView
       android:id=@+id/row_entry
       android:layout_width=wrap_content
       android:layout_height=wrap_content
       /
   /LinearLayout

  ///
  /
   Now my problem is i want to access those sms which have a specific
   string . As a example 
   if any sms contains Hello. So i want to search the string. i have
   tried a lot. But i cant do this beacause i cant convert the
   Listadapter to String. Please help me and give me the correct code.

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



[android-developers] Re: Unique problem only for the EXPERTS.

2009-01-06 Thread Al

Hi, once you read the SMS into a String, you can use the
String.substring() method to find the first character of the sms. E.g,
if the SMS is hello and it is stored in String foo, you would use
foo.substring(0,1) for the first char.

On Jan 6, 7:33 am, IPEG Student ipeg.stud...@gmail.com wrote:
 Hi,

 Thanks a lot for the problem, but I'm still unfortunately at square one.

 
 Here is what I need:

 Read an SMS into a string variable, then do some string operations.

 For example, how can I find the first character of an SMS?

 Thanks in advance for helping me out.

 ###

 On 1/6/09, Ninad mnina...@gmail.com wrote:



  Hi..

  All you need is simple SQL..

  Modify the Cursor as:

             Cursor c= getContentResolver().query(uri, null, body like
  '%hello%', null,null);

  Since the query takes the following argument:

  public final Cursor query(Uri uri, String[] projection, String
  selection, String[] selectionArgs, String sortOrder)
  .
  Arguments:

  uri:  The URI, using the content:// scheme, for the content to
  retrieve.
  projection:  A list of which columns to return. Passing null will
  return all columns, which is discouraged to prevent reading data from
  storage that isn't going to be used.
  selection:  A filter declaring which rows to return, formatted as an
  SQL WHERE clause (excluding the WHERE itself). Passing null will
  return all rows for the given URI.
  selectionArgs:  You may include ?s in selection, which will be
  replaced by the values from selectionArgs, in the order that they
  appear in the selection. The values will be bound as Strings.
  sortOrder:  How to order the rows, formatted as an SQL ORDER BY clause
  (excluding the ORDER BY itself). Passing null will use the default
  sort order, which may be unordered.

  I hope this solves your simple query for 'experts'!

  On Jan 6, 9:31 am, ipeg.stud...@gmail.com wrote:
   Hi! am Suman. I have a code by which i can access all the sms from
   inbox. The code is written below.

   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.telephony.gsm.SmsMessage;
   import android.view.View;
   import android.widget.ListAdapter;
   import android.widget.ListView;
   import android.widget.SimpleCursorAdapter;

   public class niceandroid8 extends ListActivity {

        private ListAdapter mAdapter;

         /** Called when the activity is first created. */
       @Override
       public void onCreate(Bundle icicle) {
           super.onCreate(icicle);
           Uri uri = Uri.parse(content://sms/inbox);
           Cursor c = getContentResolver().query(uri, null, null,
                           null,null);
          // Cursor c = getContentResolver().query(Carriers.CONTENT_URI,
   null, null, null, null);
           startManagingCursor(c);

           String[] columns = new String[]{body}; // Comment
           int[] names = new int[]{R.id.row_entry};

           mAdapter = new SimpleCursorAdapter(this, R.layout.con1, c,
   columns, names);

           this.setListAdapter(mAdapter);
       }

   }

   xml coding is..

   ?xml version=1.0 encoding=utf-8?

   LinearLayout xmlns:android=http://schemas.android.com/apk/res/
   android
       android:orientation=horizontal
       android:layout_width=fill_parent
       android:layout_height=wrap_content

   TextView
       android:layout_width=wrap_content
       android:layout_height=wrap_content
       android:text=Sms: 
       /
   TextView
       android:id=@+id/row_entry
       android:layout_width=wrap_content
       android:layout_height=wrap_content
       /
   /LinearLayout

  ///
  /
   Now my problem is i want to access those sms which have a specific
   string . As a example 
   if any sms contains Hello. So i want to search the string. i have
   tried a lot. But i cant do this beacause i cant convert the
   Listadapter to String. Please help me and give me the correct code.

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



[android-developers] Re: Unique problem only for the EXPERTS.

2009-01-06 Thread Ninad

Here you go.. You can get the SMS in the String Array as per below:

#

  Uri uri = Uri.parse(content://sms/inbox);
Cursor c= getContentResolver().query(uri, null, body like
'%hello%',
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
(songCursor.getColumnIndex(body))).toString();

i++;

}while(c.moveToNext());
}
}

#

Once u have the String array str, you can use the substring function
as described by Al to do what u need to do!!

Cheers
Ninad

On Jan 6, 7:17 pm, Al alcapw...@googlemail.com wrote:
 Hi, once you read the SMS into a String, you can use the
 String.substring() method to find the first character of the sms. E.g,
 if the SMS is hello and it is stored in String foo, you would use
 foo.substring(0,1) for the first char.

 On Jan 6, 7:33 am, IPEG Student ipeg.stud...@gmail.com wrote:

  Hi,

  Thanks a lot for the problem, but I'm still unfortunately at square one.

  
  Here is what I need:

  Read an SMS into a string variable, then do some string operations.

  For example, how can I find the first character of an SMS?

  Thanks in advance for helping me out.

  ###

  On 1/6/09, Ninad mnina...@gmail.com wrote:

   Hi..

   All you need is simple SQL..

   Modify the Cursor as:

              Cursor c= getContentResolver().query(uri, null, body like
   '%hello%', null,null);

   Since the query takes the following argument:

   public final Cursor query(Uri uri, String[] projection, String
   selection, String[] selectionArgs, String sortOrder)
   .
   Arguments:

   uri:  The URI, using the content:// scheme, for the content to
   retrieve.
   projection:  A list of which columns to return. Passing null will
   return all columns, which is discouraged to prevent reading data from
   storage that isn't going to be used.
   selection:  A filter declaring which rows to return, formatted as an
   SQL WHERE clause (excluding the WHERE itself). Passing null will
   return all rows for the given URI.
   selectionArgs:  You may include ?s in selection, which will be
   replaced by the values from selectionArgs, in the order that they
   appear in the selection. The values will be bound as Strings.
   sortOrder:  How to order the rows, formatted as an SQL ORDER BY clause
   (excluding the ORDER BY itself). Passing null will use the default
   sort order, which may be unordered.

   I hope this solves your simple query for 'experts'!

   On Jan 6, 9:31 am, ipeg.stud...@gmail.com wrote:
Hi! am Suman. I have a code by which i can access all the sms from
inbox. The code is written below.

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.telephony.gsm.SmsMessage;
import android.view.View;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;

public class niceandroid8 extends ListActivity {

     private ListAdapter mAdapter;

      /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        Uri uri = Uri.parse(content://sms/inbox);
        Cursor c = getContentResolver().query(uri, null, null,
                        null,null);
       // Cursor c = getContentResolver().query(Carriers.CONTENT_URI,
null, null, null, null);
        startManagingCursor(c);

        String[] columns = new String[]{body}; // Comment
        int[] names = new int[]{R.id.row_entry};

        mAdapter = new SimpleCursorAdapter(this, R.layout.con1, c,
columns, names);

        this.setListAdapter(mAdapter);
    }

}

xml coding is..

?xml version=1.0 encoding=utf-8?

LinearLayout xmlns:android=http://schemas.android.com/apk/res/
android
    android:orientation=horizontal
    android:layout_width=fill_parent
    android:layout_height=wrap_content

TextView
    android:layout_width=wrap_content
    android:layout_height=wrap_content
    android:text=Sms: 
    /
TextView
    android:id=@+id/row_entry
    android:layout_width=wrap_content
    android:layout_height=wrap_content
    /
/LinearLayout

   

[android-developers] Re: Unique problem only for the EXPERTS.

2009-01-05 Thread Ninad

Hi..

All you need is simple SQL..

Modify the Cursor as:

Cursor c= getContentResolver().query(uri, null, body like
'%hello%', null,null);

Since the query takes the following argument:

public final Cursor query(Uri uri, String[] projection, String
selection, String[] selectionArgs, String sortOrder)
.
Arguments:

uri:  The URI, using the content:// scheme, for the content to
retrieve.
projection:  A list of which columns to return. Passing null will
return all columns, which is discouraged to prevent reading data from
storage that isn't going to be used.
selection:  A filter declaring which rows to return, formatted as an
SQL WHERE clause (excluding the WHERE itself). Passing null will
return all rows for the given URI.
selectionArgs:  You may include ?s in selection, which will be
replaced by the values from selectionArgs, in the order that they
appear in the selection. The values will be bound as Strings.
sortOrder:  How to order the rows, formatted as an SQL ORDER BY clause
(excluding the ORDER BY itself). Passing null will use the default
sort order, which may be unordered.


I hope this solves your simple query for 'experts'!

On Jan 6, 9:31 am, ipeg.stud...@gmail.com wrote:
 Hi! am Suman. I have a code by which i can access all the sms from
 inbox. The code is written below.

 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.telephony.gsm.SmsMessage;
 import android.view.View;
 import android.widget.ListAdapter;
 import android.widget.ListView;
 import android.widget.SimpleCursorAdapter;

 public class niceandroid8 extends ListActivity {

      private ListAdapter mAdapter;

       /** Called when the activity is first created. */
     @Override
     public void onCreate(Bundle icicle) {
         super.onCreate(icicle);
         Uri uri = Uri.parse(content://sms/inbox);
         Cursor c = getContentResolver().query(uri, null, null,
                         null,null);
        // Cursor c = getContentResolver().query(Carriers.CONTENT_URI,
 null, null, null, null);
         startManagingCursor(c);

         String[] columns = new String[]{body}; // Comment
         int[] names = new int[]{R.id.row_entry};

         mAdapter = new SimpleCursorAdapter(this, R.layout.con1, c,
 columns, names);

         this.setListAdapter(mAdapter);
     }

 }

 xml coding is..

 ?xml version=1.0 encoding=utf-8?

 LinearLayout xmlns:android=http://schemas.android.com/apk/res/
 android
     android:orientation=horizontal
     android:layout_width=fill_parent
     android:layout_height=wrap_content
     
 TextView
     android:layout_width=wrap_content
     android:layout_height=wrap_content
     android:text=Sms: 
     /
 TextView
     android:id=@+id/row_entry
     android:layout_width=wrap_content
     android:layout_height=wrap_content
     /
 /LinearLayout

 /// 
 /
 Now my problem is i want to access those sms which have a specific
 string . As a example 
 if any sms contains Hello. So i want to search the string. i have
 tried a lot. But i cant do this beacause i cant convert the
 Listadapter to String. Please help me and give me the correct code.
 /// 
 /
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Unique problem only for the EXPERTS.

2009-01-05 Thread IPEG Student
Hi,

Thanks a lot for the problem, but I'm still unfortunately at square one.


Here is what I need:

Read an SMS into a string variable, then do some string operations.

For example, how can I find the first character of an SMS?

Thanks in advance for helping me out.

###


On 1/6/09, Ninad mnina...@gmail.com wrote:


 Hi..

 All you need is simple SQL..

 Modify the Cursor as:

Cursor c= getContentResolver().query(uri, null, body like
 '%hello%', null,null);

 Since the query takes the following argument:

 public final Cursor query(Uri uri, String[] projection, String
 selection, String[] selectionArgs, String sortOrder)
 .
 Arguments:

 uri:  The URI, using the content:// scheme, for the content to
 retrieve.
 projection:  A list of which columns to return. Passing null will
 return all columns, which is discouraged to prevent reading data from
 storage that isn't going to be used.
 selection:  A filter declaring which rows to return, formatted as an
 SQL WHERE clause (excluding the WHERE itself). Passing null will
 return all rows for the given URI.
 selectionArgs:  You may include ?s in selection, which will be
 replaced by the values from selectionArgs, in the order that they
 appear in the selection. The values will be bound as Strings.
 sortOrder:  How to order the rows, formatted as an SQL ORDER BY clause
 (excluding the ORDER BY itself). Passing null will use the default
 sort order, which may be unordered.


 I hope this solves your simple query for 'experts'!

 On Jan 6, 9:31 am, ipeg.stud...@gmail.com wrote:
  Hi! am Suman. I have a code by which i can access all the sms from
  inbox. The code is written below.
 
  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.telephony.gsm.SmsMessage;
  import android.view.View;
  import android.widget.ListAdapter;
  import android.widget.ListView;
  import android.widget.SimpleCursorAdapter;
 
  public class niceandroid8 extends ListActivity {
 
   private ListAdapter mAdapter;
 
/** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle icicle) {
  super.onCreate(icicle);
  Uri uri = Uri.parse(content://sms/inbox);
  Cursor c = getContentResolver().query(uri, null, null,
  null,null);
 // Cursor c = getContentResolver().query(Carriers.CONTENT_URI,
  null, null, null, null);
  startManagingCursor(c);
 
  String[] columns = new String[]{body}; // Comment
  int[] names = new int[]{R.id.row_entry};
 
  mAdapter = new SimpleCursorAdapter(this, R.layout.con1, c,
  columns, names);
 
  this.setListAdapter(mAdapter);
  }
 
  }
 
  xml coding is..
 
  ?xml version=1.0 encoding=utf-8?
 
  LinearLayout xmlns:android=http://schemas.android.com/apk/res/
  android
  android:orientation=horizontal
  android:layout_width=fill_parent
  android:layout_height=wrap_content
  
  TextView
  android:layout_width=wrap_content
  android:layout_height=wrap_content
  android:text=Sms: 
  /
  TextView
  android:id=@+id/row_entry
  android:layout_width=wrap_content
  android:layout_height=wrap_content
  /
  /LinearLayout
 
 
 ///
 /
  Now my problem is i want to access those sms which have a specific
  string . As a example 
  if any sms contains Hello. So i want to search the string. i have
  tried a lot. But i cant do this beacause i cant convert the
  Listadapter to String. Please help me and give me the correct code.
 
 ///
 /
 


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



[android-developers] Re: Unique problem only for the EXPERTS.

2009-01-05 Thread freepine
So you need some support like parsing strings for regular expressions
matching?
Take a look at java.util.regex.Matcher
http://code.google.com/intl/zh-CN/android/reference/java/util/regex/Matcher.html

Maybe it's helpful to you.

On Tue, Jan 6, 2009 at 3:33 PM, IPEG Student ipeg.stud...@gmail.com wrote:

 Hi,

 Thanks a lot for the problem, but I'm still unfortunately at square one.

 
 Here is what I need:

 Read an SMS into a string variable, then do some string operations.

 For example, how can I find the first character of an SMS?

 Thanks in advance for helping me out.

 ###


 On 1/6/09, Ninad mnina...@gmail.com wrote:


 Hi..

 All you need is simple SQL..

 Modify the Cursor as:

Cursor c= getContentResolver().query(uri, null, body like
 '%hello%', null,null);

 Since the query takes the following argument:

 public final Cursor query(Uri uri, String[] projection, String
 selection, String[] selectionArgs, String sortOrder)
 .
 Arguments:

 uri:  The URI, using the content:// scheme, for the content to
 retrieve.
 projection:  A list of which columns to return. Passing null will
 return all columns, which is discouraged to prevent reading data from
 storage that isn't going to be used.
 selection:  A filter declaring which rows to return, formatted as an
 SQL WHERE clause (excluding the WHERE itself). Passing null will
 return all rows for the given URI.
 selectionArgs:  You may include ?s in selection, which will be
 replaced by the values from selectionArgs, in the order that they
 appear in the selection. The values will be bound as Strings.
 sortOrder:  How to order the rows, formatted as an SQL ORDER BY clause
 (excluding the ORDER BY itself). Passing null will use the default
 sort order, which may be unordered.


 I hope this solves your simple query for 'experts'!

 On Jan 6, 9:31 am, ipeg.stud...@gmail.com wrote:
  Hi! am Suman. I have a code by which i can access all the sms from
  inbox. The code is written below.
 
  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.telephony.gsm.SmsMessage;
  import android.view.View;
  import android.widget.ListAdapter;
  import android.widget.ListView;
  import android.widget.SimpleCursorAdapter;
 
  public class niceandroid8 extends ListActivity {
 
   private ListAdapter mAdapter;
 
/** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle icicle) {
  super.onCreate(icicle);
  Uri uri = Uri.parse(content://sms/inbox);
  Cursor c = getContentResolver().query(uri, null, null,
  null,null);
 // Cursor c = getContentResolver().query(Carriers.CONTENT_URI,
  null, null, null, null);
  startManagingCursor(c);
 
  String[] columns = new String[]{body}; // Comment
  int[] names = new int[]{R.id.row_entry};
 
  mAdapter = new SimpleCursorAdapter(this, R.layout.con1, c,
  columns, names);
 
  this.setListAdapter(mAdapter);
  }
 
  }
 
  xml coding is..
 
  ?xml version=1.0 encoding=utf-8?
 
  LinearLayout xmlns:android=http://schemas.android.com/apk/res/
  android
  android:orientation=horizontal
  android:layout_width=fill_parent
  android:layout_height=wrap_content
  
  TextView
  android:layout_width=wrap_content
  android:layout_height=wrap_content
  android:text=Sms: 
  /
  TextView
  android:id=@+id/row_entry
  android:layout_width=wrap_content
  android:layout_height=wrap_content
  /
  /LinearLayout
 
 
 ///
 /
  Now my problem is i want to access those sms which have a specific
  string . As a example 
  if any sms contains Hello. So i want to search the string. i have
  tried a lot. But i cant do this beacause i cant convert the
  Listadapter to String. Please help me and give me the correct code.
 
 ///
 /

 


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