You are on page 1of 23

14/07/2015

Read SMS Message from Inbox / Sent / Draft in Android | Pulse7

Android, Python, Django, Odoo and Open Source tutorials

ANDROID

ODOO (OPENERP)

DJANGO

TRICKS

MEET TEAM

Start Free Download


Start Tracking your Package w/ Link Get Package Tracer for Free - Now!

ADD A M E NU

Right Sidebar - First


Menu

ADD A M E NU

Right Sidebar - Second


Menu

ARCH IVE S

June 2014
January 2014
December 2013
November 2013
October 2013
September 2013
http://pulse7.net/android/read-sms-message-inbox-sent-draft-android/

Read
SMS
Mess
age
from
Inbo
x/
Sent
/
Draft
in

CONNECT
WITH
ME

TWITTEFACE
R
B OOK

GOOGLLEINKE D

P L U S IN

SUBSCRIBE
TO
BLOG
VIA
EM AIL

1/23

14/07/2015

in
Andr
oid

Read SMS Message from Inbox / Sent / Draft in Android | Pulse7

Email Address

SUBSCRIBE

POPU L AR
POSTS

OCT 24, 2013

b y V IM AL
OPENERP

RUGHANI

in ANDROID

http://pulse7.net/android/read-sms-message-inbox-sent-draft-android/

In

previous
tutorial we
learn How to
send SMS
Message from
Android
Application.
Now its time to
learn How to
read SMS
Message from
Inbox / Sent /
Draft in android
application. To
complete this
task we will use
built-in SMS
Content
Provider of
Android. We
will create

Run
Odoo
from
port
80
instead
of
8069

RECENT
POSTS

OPENERP

Run
Odoo
from
port
80
instead
of
8069
DJANGO

Install
Django
on
Windows
8
2/23

14/07/2015

Read SMS Message from Inbox / Sent / Draft in Android | Pulse7

will create
simple Android
application,
which will have
3 buttons
(Inbox , Sent
and Draft) when
user click on
button it will
display SMS
Message of
respective
message box.

ANDROID

Read
NFC
Tag
with
Android
Application
OPENERP

Install
Odoo
on
Ubuntu
14.04
from
Github
OPENERP

Code to
read
SMS
Messag
e from
Inbox

http://pulse7.net/android/read-sms-message-inbox-sent-draft-android/

Lets first see


how to read
SMS Message
from you
mobile inbox.
We will use
built-in SMS
content
provider for
reading
message.

Install
Odoo
(Open
ERP
v8)
on
Ubuntu
12.04
from
launchpad

3/23

14/07/2015

Read SMS Message from Inbox / Sent / Draft in Android | Pulse7

message.
01
02
03
04
05
06
07
08
09
10
11

// Create Inbox box URI


Uri inboxURI = Uri.parse(
// List required columns
String[] reqCols =

// Get Content Resolver object, w


ContentResolver cr = getContentRe

// Fetch Inbox SMS Message from B


Cursor c = cr.query(inboxURI, req

Code to
read
SMS
Messag
e form
Sent
box
Now lets see
how to read
SMS Message
from mobile
sentbox
01
02
03
04
05
06
07
http://pulse7.net/android/read-sms-message-inbox-sent-draft-android/

// Create Sent box URI


Uri sentURI = Uri.parse(
// List required columns
String[] reqCols =

// Get Content Resolver object, w


4/23

14/07/2015

07
08
09
10
11

// Get Content Resolver object, w


ContentResolver cr = getContentRe

Read SMS Message from Inbox / Sent / Draft in Android | Pulse7

// Fetch Sent SMS Message from Bu


Cursor c = cr.query(sentURI, reqC

Code to
read
SMS
Messag
e from
Draft
Lets read draft
messages from
mobile .
01
02
03
04
05
06
07
08
09
10
11

http://pulse7.net/android/read-sms-message-inbox-sent-draft-android/

// Create Draft box URI


Uri draftURI = Uri.parse(
// List required columns
String[] reqCols =

// Get Content Resolver object, w


ContentResolver cr = getContentRe

// Fetch Sent SMS Message from Bu


Cursor c = cr.query(draftURI, req

Permiss
ion
require
d to

5/23

14/07/2015

d to
Read
Messag
e from
Mobile

Read SMS Message from Inbox / Sent / Draft in Android | Pulse7

uses-permission

Databas
e
Column
s List of
Built-in
SMS
Content
Provide
r
Column ID -
Column Name

http://pulse7.net/android/read-sms-message-inbox-sent-draft-android/

0 :
_id
1 :
thread_id
2 :

6/23

14/07/2015

Read SMS Message from Inbox / Sent / Draft in Android | Pulse7

http://pulse7.net/android/read-sms-message-inbox-sent-draft-android/

2 :
address
3 :
person
4 :
date
5 :
protocol
6 :
read
7 :
status
8 :
type
9 :
reply_path_pre
sent
10 :
subject
11 :
body
12 :
service_center
13 :
locked

Lets put every


thing together
and build
android
application
which will read
SMS Message
from Inbox /
Sent / Draft
from mobile.

7/23

14/07/2015

Read SMS Message from Inbox / Sent / Draft in Android | Pulse7

from mobile.
Create New
Android
Project

1. Create a new
project and fill
the required
details File
New
Android
Project
2. Now open
main.xml
(res/layout)
and create
simple GUI
which have
three different
buttons, Inbox,
Sent and Draft.
and List view to
display list of
message.

http://pulse7.net/android/read-sms-message-inbox-sent-draft-android/

01
02
03
04
05
06
07
08
09
10
11
12
13

<?xml
<LinearLayout
android:layout_width
android:orientation
<LinearLayout

8/23

14/07/2015

Read SMS Message from Inbox / Sent / Draft in Android | Pulse7

13
14
15
16
17
18
19
20
21

</
<ListView

</LinearLayout

3. Now open
Activity Class
where we will
fetch Built-in
SMS content
provider and
display
Messages in
listview.

http://pulse7.net/android/read-sms-message-inbox-sent-draft-android/

001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
018
019
020
021
022
023
024

package
import
import
import
import
import
import
import
import
import
import
import
public

// GUI Widget
Button btnSent, btnInbox, bt
TextView lblMsg, lblNo;
ListView lvMsg;

// Cursor Adapter
SimpleCursorAdapter adapter;
9/23

14/07/2015

Read SMS Message from Inbox / Sent / Draft in Android | Pulse7

http://pulse7.net/android/read-sms-message-inbox-sent-draft-android/

024
025
026
027
028
029
030
031
032
033
034
035
036
037
038
039
040
041
042
043
044
045
046
047
048
049
050
051
052
053
054
055
056
057
058
059
060
061
062
063
064
065
066
067
068
069
070

/** Called when the activity


@Override
public

}
@Override
public

10/23

14/07/2015

Read SMS Message from Inbox / Sent / Draft in Android | Pulse7

http://pulse7.net/android/read-sms-message-inbox-sent-draft-android/

070
071
072
073
074
075
076
077
078
079
080
081
082
083
084
085
086
087
088
089
090
091
092
093
094
095
096
097
098
099
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116

}
11/23

14/07/2015

Read SMS Message from Inbox / Sent / Draft in Android | Pulse7

4. Dont forget
to put below
permission in
AndroidMenifes
t.xml file
1

<uses-permission

5. Now execute
application.

Read SMS from Inbox

Read Draft Message

http://pulse7.net/android/read-sms-message-inbox-sent-draft-android/

I hope you like


this article.
Share your
views to to

12/23

14/07/2015

Read SMS Message from Inbox / Sent / Draft in Android | Pulse7

views to to
improve
content. Happy
Coding !!!

Down
load
Sourc
e
Code

Sh
are
this
:

Facebook 46
Google
Twitter 6
LinkedIn 1
Reddit

Go
ogl
e+

vimal rughani
Follow

391

Related
Tutorials
:

http://pulse7.net/android/read-sms-message-inbox-sent-draft-android/

13/23

14/07/2015

Read SMS Message from Inbox / Sent / Draft in Android | Pulse7

Read NFC Tag


with Android
Application

How to send
SMS Message
in Android

Contacts
Content

SQLite
Database in

Tagged with:

Android, Draft, Inbox,


Message, Read, Sent,
SMS

http://pulse7.net/android/read-sms-message-inbox-sent-draft-android/

14/23

14/07/2015

Read SMS Message from Inbox / Sent / Draft in Android | Pulse7

ABOUT

THE

AUTHOR

Vimal

Rughani

Working
as
Creative
Product
Manager
at
Virtual
Reality
Systems,
Rajkot,
India

Comments
Community
1

Login

Recommend 6
Sort by Best
http://pulse7.net/android/read-sms-message-inbox-sent-draft-android/

15/23

14/07/2015

Read SMS Message from Inbox / Sent / Draft in Android | Pulse7

Join the dis


Robert
Greso
a
year
ago

Hi at first
thanks a lot
for your
tutorial! I
need it for
my app but
I need also
to get text
from sms
to editText
when I
click on
one of
those
shown
sms in list.
Could you
help me
with this
task or just
give a hint
? Thanks
for your
time
1
Reply
Share
Vimal
Rughani
Mod

>
Robert
Greso
a
year
ago

http://pulse7.net/android/read-sms-message-inbox-sent-draft-android/

Hi
Robert,
I
am
happy
that
you
liked

16/23

14/07/2015

Read SMS Message from Inbox / Sent / Draft in Android | Pulse7

liked
my
tutorial.
It
will
be
my
pleasure
to
help
you
in
your
task.
If
you
want
to
extend
this
example
to
full
fill
your
needs,
you
need
to
set
setOnItemClickListener

http://pulse7.net/android/read-sms-message-inbox-sent-draft-android/

for
your
message
listview
(lvMsg).
In
that
part
you
can
set
sms
content
into
your
desired
edittextbox.
Please

17/23

14/07/2015

Read SMS Message from Inbox / Sent / Draft in Android | Pulse7

Please
let
me
know
if
you
find
any
difficulty,
you
can
send
me
your
code
for
exact
answer.

Reply

Share

http://pulse7.net/android/read-sms-message-inbox-sent-draft-android/

18/23

14/07/2015

Read SMS Message from Inbox / Sent / Draft in Android | Pulse7

http://pulse7.net/android/read-sms-message-inbox-sent-draft-android/

19/23

14/07/2015

Read SMS Message from Inbox / Sent / Draft in Android | Pulse7

http://pulse7.net/android/read-sms-message-inbox-sent-draft-android/

20/23

14/07/2015

Read SMS Message from Inbox / Sent / Draft in Android | Pulse7

eshal
2
days
ago

hai sir!
will you
help me
please ..
your
tutorial is
best but i
am not
gettig how
to set the
listView
inside item
which you
have given
ids {
ibimsg nd
ibinumber}.
i am new
to android
and
working on
messages
field in
android
thanks
http://pulse7.net/android/read-sms-message-inbox-sent-draft-android/

21/23

14/07/2015

Read SMS Message from Inbox / Sent / Draft in Android | Pulse7


Reply
Share
Vimal
Rughani
Mod

>
eshal

a
day
ago

Hi
Eshal,
You
have
to
use
custom
row
for
your
listview.
You
can
download
full
source
code
from
download
link.
in
that
code
you
will
find
row.xml
file
which
is
used
for
custom
row.
You
can
put
any
details
http://pulse7.net/android/read-sms-message-inbox-sent-draft-android/

22/23

14/07/2015

Read SMS Message from Inbox / Sent / Draft in Android | Pulse7

which
you
want
to
put.
Let
me
know
if
you
have
any
query.

Reply

Share

hossein
shooshtari

PULSE7

VIR TUAL R EALITY S YS TEMS - OFFIC IAL BLOG C OPYR IGHT


2014 PULS E7. ALL R IGHTS R ES ER VED.

http://pulse7.net/android/read-sms-message-inbox-sent-draft-android/

23/23

You might also like