Structure Query Language, C programming, Java, Servlet, Jsp, Unix

Thursday, 18 October 2012

Read messages from the mobile and display it on the screen.

Pro13Activity.java
package ps.pro13;

import android.app.Activity;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.widget.TextView;

public class Pro13Activity extends Activity {
    /**
     *  www.master-gtu.blogspot.com
     *  pankaj sharma(8460479175),
     *  chavda vijay(8460420769) 
     */
 TextView txtmsg;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        txtmsg=(TextView) findViewById(R.id.TextViewmsgs);
        
        Uri u=Uri.parse("content://sms/inbox");
        Cursor cur=managedQuery(u, null, null, null, null);
        
        String msg="";
        while(cur.moveToNext())
        {
         msg+=cur.getString(2)+":\n\t"+cur.getString(11)+"\n\n";
        }
        txtmsg.setText(msg);
       
    }
}

1 comment: