<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-5626077093408809500</id><updated>2024-09-02T13:03:17.312+05:30</updated><category term="android"/><category term="inbox message"/><category term="incoming message"/><category term="message number"/><category term="message text"/><category term="message time"/><category term="message type"/><category term="ClickableSpan"/><category term="SMS content"/><category term="SMS content."/><category term="android call duration"/><category term="android call history"/><category term="android call type"/><category term="android phone number"/><category term="call date time"/><category term="change url text color"/><category term="custom ClickableSpan"/><category term="customization of link text"/><category term="delete contacts"/><category term="incoming call"/><category term="installed application"/><category term="link text"/><category term="missed call"/><category term="news"/><category term="open url"/><category term="outgoing call"/><category term="outgoing message"/><category term="package name"/><category term="spannable string"/><category term="version code"/><category term="version name"/><title type='text'>AndroidDev</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://android2011dev.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5626077093408809500/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://android2011dev.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>8</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5626077093408809500.post-1266391032285223553</id><published>2013-10-20T17:28:00.001+05:30</published><updated>2013-10-22T11:37:09.135+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="android"/><category scheme="http://www.blogger.com/atom/ns#" term="change url text color"/><category scheme="http://www.blogger.com/atom/ns#" term="ClickableSpan"/><category scheme="http://www.blogger.com/atom/ns#" term="custom ClickableSpan"/><category scheme="http://www.blogger.com/atom/ns#" term="customization of link text"/><category scheme="http://www.blogger.com/atom/ns#" term="link text"/><category scheme="http://www.blogger.com/atom/ns#" term="open url"/><category scheme="http://www.blogger.com/atom/ns#" term="spannable string"/><title type='text'>Open URL, Linkify text and Spannable string in Android</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
In this post I will be going to describe how to open URL in Android and how to link text in different ways using default methods and spannable string.&lt;br /&gt;
Below are the different methods to linking text with URL:&lt;br /&gt;
&lt;br /&gt;
1.Android&#39;s default method to link text with URL:&lt;br /&gt;
Here I added one text box :&lt;br /&gt;
&amp;lt;TextView android:id=&quot;@+id/text1&quot;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; android:layout_width=&quot;fill_parent&quot;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; android:layout_height=&quot;wrap_content&quot;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; android:text=&quot;@string/link&quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For this I am using below string :&lt;br /&gt;
&amp;nbsp;&amp;lt;string name=&quot;link&quot;&amp;gt;&amp;lt;a href=&quot;http://android2011dev.blogspot.com&quot;&amp;gt;Go to Android-Dev blog page.&amp;lt;/a&amp;gt; &amp;lt;/string&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and now will call this string on click of text view:&lt;br /&gt;
private void linkWithWeb()&lt;br /&gt;
{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;TextView text1 = (TextView)findViewById(R.id.text1);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;text1.setMovementMethod(LinkMovementMethod.getInstance());&lt;br /&gt;
}&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
It will look like this on device :&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhtIwfQK1bGZ7RywbBBK3RVpAmfXPxq1GiMCnG9B6eqWGGXegH0iwFMJ7tzlHOfJIuiqAXzgO3mcFmt0B-xcXKXr0DHvEMXn8IblcnewDvlDjRnDiUFZPf4v2ftdkyW51NVWorY7QR-jnw/s1600/Spannable.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhtIwfQK1bGZ7RywbBBK3RVpAmfXPxq1GiMCnG9B6eqWGGXegH0iwFMJ7tzlHOfJIuiqAXzgO3mcFmt0B-xcXKXr0DHvEMXn8IblcnewDvlDjRnDiUFZPf4v2ftdkyW51NVWorY7QR-jnw/s1600/Spannable.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Here complete text is linked with URL.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
2.In this second option I will link some part of string with URL and make the link text bold.&lt;br /&gt;
Add the text box:&lt;br /&gt;
&amp;lt;TextView android:id=&quot;@+id/text2&quot;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; android:layout_width=&quot;fill_parent&quot;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; android:layout_height=&quot;wrap_content&quot;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; android:text=&quot;@string/bold_link&quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is the bold_link string :&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;string name=&quot;bold_link&quot;&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Go to&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&amp;lt;a STYLE=&quot;text-decoration:none&quot; href=&quot;http://android2011dev.blogspot.com&quot;&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&amp;lt;b&amp;gt;Android Dev Blog&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&amp;lt;/a&amp;gt; page.&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;/string&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here we will be going to initialize text box and on click of text box app will launch above URL in web browser. Call below method on click of text box.&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private void linkWithBoldWeb() {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;TextView text2 = (TextView)findViewById(R.id.text2);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;text2.setMovementMethod(LinkMovementMethod.getInstance());&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
It will look like this on device :&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7-yfjeuXwcDzcyqvm2cUc40OZVMRneqRrBsYnXwAwixgMk2Zbih44O8f2aqn1TYlo8ZigaQvCtjykx1BHGDap2ZTt5w5SDbbakA9H-h1KTqucQhUTZ6zQ0LBrkLzsOhsxWbvf3h1MKrU/s1600/Spannable.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7-yfjeuXwcDzcyqvm2cUc40OZVMRneqRrBsYnXwAwixgMk2Zbih44O8f2aqn1TYlo8ZigaQvCtjykx1BHGDap2ZTt5w5SDbbakA9H-h1KTqucQhUTZ6zQ0LBrkLzsOhsxWbvf3h1MKrU/s1600/Spannable.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
3.&amp;nbsp;Change the text font and color of linking text&lt;/div&gt;
&lt;div&gt;
Text box:&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&amp;lt;TextView android:id=&quot;@+id/text3&quot;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; android:layout_width=&quot;fill_parent&quot;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; android:layout_height=&quot;wrap_content&quot;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; android:text=&quot;@string/link&quot;/&amp;gt; &amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
Here is the string:&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;string name=&quot;custom_link_pre&quot;&amp;gt;Go to &amp;lt;/string&amp;gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;string name=&quot;custom_link_end&quot;&amp;gt;Android Dev Blog &amp;lt;/string&amp;gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;string name=&quot;custom_link_end_text&quot;&amp;gt;page.&amp;lt;/string&amp;gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
Here I used three strings, text before link text, link text and finally text after link.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Here is the method to build third text box:&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
String linkBlog = &quot;http://android2011dev.blogspot.com&quot;;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
private void cutomizeLink(){&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;TextView text3 = (TextView)findViewById(R.id.text3);&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;text3.setMovementMethod(LinkMovementMethod.getInstance());&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;String strLeading = getXMLString(this, R.string.custom_link_pre);&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;String strTrailing = getXMLString(this, R.string.custom_link_end);&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;String strTrailingEnd = getXMLString(this, R.string.custom_link_end_text);&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;SpannableStringBuilder stringBuilder = new SpannableStringBuilder();&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;stringBuilder.append(strLeading);&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;stringBuilder.append(&quot; &quot; + strTrailing);&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;stringBuilder.append(&quot; &quot; + strTrailingEnd);&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;stringBuilder.setSpan(new NonUnderlinedClickableSpan() {&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;@Override&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;public void onClick(View widget) {&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;Intent browse = new Intent(Intent.ACTION_VIEW, Uri.parse(linkBlog));&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;startActivity(browse);&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;}&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}, strLeading.length(), strLeading.length() + strTrailing.length()+1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;text3.setText(stringBuilder);&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;text3.setMovementMethod(LinkMovementMethod.getInstance());&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
getXMLString method is used for int to string conversion.&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
public static String getXMLString(Context context, int stringID) {&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Resources res = context.getResources();&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;return res.getString(stringID);&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
NonUnderlinedClickableSpan class will be used to change the text color from default blue to megenta and removed underline from lined text.&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
public class NonUnderlinedClickableSpan extends ClickableSpan {&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;@Override&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;public void updateDrawState(TextPaint ds) {&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;ds.setColor(Color.MAGENTA);&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;ds.setUnderlineText(false);&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;ds.setTypeface(Typeface.DEFAULT_BOLD);&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;@Override&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;public void onClick(View v) {&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
It will look like this on device :&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOoRqsJPelDZPZtHhnGBEC8dJUbqx4NNh0aIWSpBzvjW4cuH9q5Pl_STUqGjy3ZJ7DD1P5_zMzijmRnIRgNejGDvy8tM60gGu2gw0FKhViN6hhBiZtyqRpDYCAsEsgDTf-sKqhPj0rv00/s1600/Spannable.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOoRqsJPelDZPZtHhnGBEC8dJUbqx4NNh0aIWSpBzvjW4cuH9q5Pl_STUqGjy3ZJ7DD1P5_zMzijmRnIRgNejGDvy8tM60gGu2gw0FKhViN6hhBiZtyqRpDYCAsEsgDTf-sKqhPj0rv00/s1600/Spannable.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
4. Here we will see how to multiple links in same string along with I will change the text font and color of linking text same as third option.&lt;/div&gt;
&lt;div&gt;
Add text box:&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&amp;lt;TextView android:id=&quot;@+id/text4&quot;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; android:layout_width=&quot;fill_parent&quot;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; android:layout_height=&quot;wrap_content&quot;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; android:textSize=&quot;20sp&quot;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; android:text=&quot;@string/custom_link_text&quot;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; android:padding=&quot;15dip&quot;/&amp;gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Then add string:&lt;/div&gt;
&lt;div&gt;
&amp;lt;string name=&quot;custom_link_text&quot;&amp;gt;Go to Google search page and Blog page.&amp;lt;/string&amp;gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
And now initialize and build the text box as per requirement:&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
String link = &quot;http://www.google.com&quot;;&lt;/div&gt;
&lt;div&gt;
String linkBlog = &quot;http://android2011dev.blogspot.com&quot;;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
private void customLink(){&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;TextView text4 = (TextView)findViewById(R.id.text4);&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;text4.setMovementMethod(LinkMovementMethod.getInstance());&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;String customStr = getXMLString(this, R.string.custom_link_text);&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;String strLeading = customStr.substring(0, customStr.indexOf(&quot;Google&quot;));&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;String strTrailing = customStr.substring(customStr.indexOf(&quot;Google&quot;), (customStr.indexOf(&quot;search&quot;) - 1));&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;String strTrailingEnd = customStr.substring(0, (customStr.indexOf(&quot;Blog&quot;)));&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;String strTrailingEnd1 = customStr.substring((customStr.lastIndexOf(&quot;page&quot;)));&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;SpannableStringBuilder stringBuilder = new SpannableStringBuilder();&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;stringBuilder.append(customStr);&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;stringBuilder.setSpan(new NonUnderlinedClickableSpan() {&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;@Override&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;public void onClick(View widget) {&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;Intent browse = new Intent(Intent.ACTION_VIEW, Uri.parse(link));&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;startActivity(browse);&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;}&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;},strLeading.length(),&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;strLeading.length() + strTrailing.length()+1,&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;stringBuilder.setSpan(new NonUnderlinedClickableSpan() {&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;@Override&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;public void onClick(View widget) {&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;Intent browse = new Intent(Intent.ACTION_VIEW, Uri.parse(linkBlog));&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;startActivity(browse);&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;}&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;},strTrailingEnd.length(),&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;strTrailingEnd.length() + strTrailingEnd1.length(),&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;text4.setText(stringBuilder);&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;text4.setMovementMethod(LinkMovementMethod.getInstance());&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
Here is the result :&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkuSENi5ts_yZbXvq2okUNWs0KzHCyBrW-sF8mE8hPDOJNfFwCjizKkaoHI0ZlKLJlx74Cd5gPDidO_gcj3QoC8qB7I7NpocxRABBz9cMUf5xTwtbORu-P2rsPzEIJZJHHhWoTBALqLc8/s1600/Spannable.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkuSENi5ts_yZbXvq2okUNWs0KzHCyBrW-sF8mE8hPDOJNfFwCjizKkaoHI0ZlKLJlx74Cd5gPDidO_gcj3QoC8qB7I7NpocxRABBz9cMUf5xTwtbORu-P2rsPzEIJZJHHhWoTBALqLc8/s1600/Spannable.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
On click of &amp;nbsp;&#39;Google&#39; app will navigate to &quot;http://www.google.com&quot; page and on click &#39;Blog&#39; navigate to &quot;http://android2011dev.blogspot.com&quot; page.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
That&#39;s it&lt;/div&gt;
&lt;div&gt;
.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
Here is the complete source code :&lt;/div&gt;
&lt;div&gt;
Activity file:&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
public class SpannableStringActivity extends Activity {&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;String link = &quot;http://www.google.com&quot;;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;String linkBlog = &quot;http://android2011dev.blogspot.com&quot;;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;@Override&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public void onCreate(Bundle savedInstanceState) {&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;super.onCreate(savedInstanceState);&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;setContentView(R.layout.main);&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;linkWithWeb();&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;linkWithBoldWeb();&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;cutomizeLink();&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;customLink();&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;/*&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * Used to linking with web&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; */&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private void linkWithWeb() {&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;TextView text1 = (TextView)findViewById(R.id.text1);&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;text1.setMovementMethod(LinkMovementMethod.getInstance());&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;/*&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * Link with bold font&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; */&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private void linkWithBoldWeb() {&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;TextView text2 = (TextView)findViewById(R.id.text2);&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;text2.setMovementMethod(LinkMovementMethod.getInstance());&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;/*&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * Change the text font and color of linking text&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; */&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private void cutomizeLink(){&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;TextView text3 = (TextView)findViewById(R.id.text3);&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;text3.setMovementMethod(LinkMovementMethod.getInstance());&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;String strLeading = getXMLString(this, R.string.custom_link_pre);&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;String strTrailing = getXMLString(this, R.string.custom_link_end);&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;String strTrailingEnd = getXMLString(this, R.string.custom_link_end_text);&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;SpannableStringBuilder stringBuilder = new SpannableStringBuilder();&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;stringBuilder.append(strLeading);&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;stringBuilder.append(&quot; &quot; + strTrailing);&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;stringBuilder.append(&quot; &quot; + strTrailingEnd);&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;stringBuilder.setSpan(new NonUnderlinedClickableSpan() {&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;@Override&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;public void onClick(View widget) {&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;Intent browse = new Intent(Intent.ACTION_VIEW, Uri.parse(linkBlog));&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;startActivity(browse);&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;}&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}, strLeading.length(), strLeading.length() + strTrailing.length()+1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;text3.setText(stringBuilder);&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;text3.setMovementMethod(LinkMovementMethod.getInstance());&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;/*&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; * &amp;nbsp;Change the text font and color of linking text. Add multiple links in to the single sentence.&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; */&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private void customLink(){&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;TextView text4 = (TextView)findViewById(R.id.text4);&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;text4.setMovementMethod(LinkMovementMethod.getInstance());&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;String customStr = getXMLString(this, R.string.custom_link_text);&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;String strLeading = customStr.substring(0, customStr.indexOf(&quot;Google&quot;));&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;String strTrailing = customStr.substring(customStr.indexOf(&quot;Google&quot;), (customStr.indexOf(&quot;search&quot;) - 1));&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;String strTrailingEnd = customStr.substring(0, (customStr.indexOf(&quot;Blog&quot;)));&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;String strTrailingEnd1 = customStr.substring((customStr.lastIndexOf(&quot;page&quot;)));&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;SpannableStringBuilder stringBuilder = new SpannableStringBuilder();&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;stringBuilder.append(customStr);&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;stringBuilder.setSpan(new NonUnderlinedClickableSpan() {&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;@Override&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;public void onClick(View widget) {&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;Intent browse = new Intent(Intent.ACTION_VIEW, Uri.parse(link));&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;startActivity(browse);&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;}&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;},strLeading.length(),&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;strLeading.length() + strTrailing.length()+1,&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;stringBuilder.setSpan(new NonUnderlinedClickableSpan() {&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;@Override&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;public void onClick(View widget) {&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;Intent browse = new Intent(Intent.ACTION_VIEW, Uri.parse(linkBlog));&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;startActivity(browse);&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;}&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;},strTrailingEnd.length(),&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;strTrailingEnd.length() + strTrailingEnd1.length(),&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;text4.setText(stringBuilder);&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;text4.setMovementMethod(LinkMovementMethod.getInstance());&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public class NonUnderlinedClickableSpan extends ClickableSpan {&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;@Override&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;public void updateDrawState(TextPaint ds) {&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;ds.setColor(Color.MAGENTA);&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;ds.setUnderlineText(false);&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;ds.setTypeface(Typeface.DEFAULT_BOLD);&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;@Override&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;public void onClick(View v) {&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public static String getXMLString(Context context, int stringID) {&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Resources res = context.getResources();&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;return res.getString(stringID);&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
main.xml file :&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; android:orientation=&quot;vertical&quot;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; android:layout_width=&quot;fill_parent&quot;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; android:layout_height=&quot;fill_parent&quot;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;TextView android:id=&quot;@+id/text1&quot;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; android:layout_width=&quot;fill_parent&quot;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; android:layout_height=&quot;wrap_content&quot;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; android:textSize=&quot;20sp&quot;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; android:text=&quot;@string/link&quot;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; android:padding=&quot;15dip&quot;/&amp;gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;TextView android:id=&quot;@+id/text2&quot;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; android:layout_width=&quot;fill_parent&quot;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; android:layout_height=&quot;wrap_content&quot;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; android:textSize=&quot;20sp&quot;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;android:text=&quot;@string/bold_link&quot;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; android:padding=&quot;15dip&quot;/&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;lt;TextView android:id=&quot;@+id/text3&quot;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; android:layout_width=&quot;fill_parent&quot;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; android:layout_height=&quot;wrap_content&quot;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; android:textSize=&quot;20sp&quot;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; android:text=&quot;@string/link&quot;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; android:padding=&quot;15dip&quot;/&amp;gt; &amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;lt;TextView android:id=&quot;@+id/text4&quot;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; android:layout_width=&quot;fill_parent&quot;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; android:layout_height=&quot;wrap_content&quot;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; android:textSize=&quot;20sp&quot;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; android:text=&quot;@string/custom_link_text&quot;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; android:padding=&quot;15dip&quot;/&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;lt;/LinearLayout&amp;gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
string.xml file:&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;resources&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;string name=&quot;hello&quot;&amp;gt;Hello World, SpannableStringActivity!&amp;lt;/string&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;string name=&quot;app_name&quot;&amp;gt;SpannableString&amp;lt;/string&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;string name=&quot;link&quot;&amp;gt;&amp;lt;a href=&quot;http://android2011dev.blogspot.com&quot;&amp;gt;Go to Android-Dev blog page.&amp;lt;/a&amp;gt; &amp;lt;/string&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;string name=&quot;bold_link&quot;&amp;gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Go to&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&amp;lt;a STYLE=&quot;text-decoration:none&quot; href=&quot;http://android2011dev.blogspot.com&quot;&amp;gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&amp;lt;b&amp;gt;Android Dev Blog&amp;lt;/b&amp;gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&amp;lt;/a&amp;gt; page.&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;/string&amp;gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;string name=&quot;custom_link_pre&quot;&amp;gt;Go to &amp;lt;/string&amp;gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;string name=&quot;custom_link_end&quot;&amp;gt;Android Dev Blog &amp;lt;/string&amp;gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;string name=&quot;custom_link_end_text&quot;&amp;gt;page.&amp;lt;/string&amp;gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;string name=&quot;custom_link_text&quot;&amp;gt;Go to Google search page and Blog page.&amp;lt;/string&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;/resources&amp;gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://android2011dev.blogspot.com/feeds/1266391032285223553/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5626077093408809500/1266391032285223553' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5626077093408809500/posts/default/1266391032285223553'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5626077093408809500/posts/default/1266391032285223553'/><link rel='alternate' type='text/html' href='http://android2011dev.blogspot.com/2013/10/open-url-linkify-text-and-spannable.html' title='Open URL, Linkify text and Spannable string in Android'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhtIwfQK1bGZ7RywbBBK3RVpAmfXPxq1GiMCnG9B6eqWGGXegH0iwFMJ7tzlHOfJIuiqAXzgO3mcFmt0B-xcXKXr0DHvEMXn8IblcnewDvlDjRnDiUFZPf4v2ftdkyW51NVWorY7QR-jnw/s72-c/Spannable.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5626077093408809500.post-6698336312859076535</id><published>2013-10-14T19:12:00.000+05:30</published><updated>2013-10-21T14:27:54.871+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="android"/><category scheme="http://www.blogger.com/atom/ns#" term="inbox message"/><category scheme="http://www.blogger.com/atom/ns#" term="incoming message"/><category scheme="http://www.blogger.com/atom/ns#" term="message number"/><category scheme="http://www.blogger.com/atom/ns#" term="message text"/><category scheme="http://www.blogger.com/atom/ns#" term="message time"/><category scheme="http://www.blogger.com/atom/ns#" term="message type"/><category scheme="http://www.blogger.com/atom/ns#" term="outgoing message"/><category scheme="http://www.blogger.com/atom/ns#" term="SMS content."/><title type='text'>Outgoing SMS details</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
In my previous post you can find how to &lt;a href=&quot;http://android2011dev.blogspot.in/2013/10/incoming-sms-details.html&quot;&gt;read incoming SMS&lt;/a&gt; content programmatically.&lt;br /&gt;
In this post I will give you information about how to read outgoing SMS content. It&#39;s same as incoming SMS data reading, just need use different URI to read outgoing SMS content.&lt;br /&gt;
To read outgoing SMS content first add user permission:&lt;br /&gt;
&amp;nbsp;&amp;lt;uses-permission android:name=&quot;android.permission.READ_SMS&quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then call below method :&lt;br /&gt;
&lt;br /&gt;
public StringBuffer getOutgoingSMSContent() {&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;ContentResolver contentResolver = getContentResolver();&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Uri uri = Uri.parse(&quot;content://sms/sent/&quot;);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;StringBuffer messagedata = new StringBuffer();&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;int count = 0;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Cursor cursor = contentResolver.query(uri, null, null, null, null);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;if (cursor.getCount() != 0) {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;if (cursor.moveToFirst()) {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;do {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;messagedata.append(&quot;Outgoing message count: &quot; + (count +1) + &quot;\n&quot;);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;for (int m = 0; m &amp;lt; cursor.getColumnCount(); m++) {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;      &lt;/span&gt;if (cursor.getColumnName(m).equalsIgnoreCase(&quot;address&quot;)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;        &lt;/span&gt;|| cursor.getColumnName(m).equalsIgnoreCase(&quot;date&quot;)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;        &lt;/span&gt;|| cursor.getColumnName(m).equalsIgnoreCase(&quot;body&quot;)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;        &lt;/span&gt;|| cursor.getColumnName(m).equalsIgnoreCase(&quot;type&quot;))&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;      &lt;/span&gt;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;messagedata.append(cursor.getColumnName(m) + &quot; &amp;nbsp;: &quot;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;         &lt;/span&gt;+ cursor.getString(m));&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;messagedata.append(&quot;\n&quot;);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;      &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;messagedata.append(&quot;\n&quot;);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;count++;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;} while (cursor.moveToNext());&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;cursor.close();&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;cursor = null;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;return messagedata;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;br /&gt;
This method will return list of all outgoing SMS content.&lt;br /&gt;
&lt;br /&gt;
Result will look something like this :&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhY8E86d5wCNQjpevbEBg3_2VJLawm1ucL29T5T4epV48wrtJ8lVRyBw7HUolCmTx0RZayCKcNeaMCaOvbh0zvfb5SnMUY2pWrJHCYDeROsgVmC3-fPPv_xdELTzmyPQQmxf7cCLIkcemY/s1600/OutgoingSMSData.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhY8E86d5wCNQjpevbEBg3_2VJLawm1ucL29T5T4epV48wrtJ8lVRyBw7HUolCmTx0RZayCKcNeaMCaOvbh0zvfb5SnMUY2pWrJHCYDeROsgVmC3-fPPv_xdELTzmyPQQmxf7cCLIkcemY/s320/OutgoingSMSData.png&quot; width=&quot;213&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Here &#39;address&#39; is mobile number of receiver.&lt;br /&gt;
&#39;date&#39; is message sent time in milliseconds.&lt;br /&gt;
&#39;type&#39; is message type incoming/outgoing. 2 is outgoing message type.&lt;br /&gt;
&#39;body&#39; is message text.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://android2011dev.blogspot.com/feeds/6698336312859076535/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5626077093408809500/6698336312859076535' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5626077093408809500/posts/default/6698336312859076535'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5626077093408809500/posts/default/6698336312859076535'/><link rel='alternate' type='text/html' href='http://android2011dev.blogspot.com/2013/10/outgoing-sms-details.html' title='Outgoing SMS details'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhY8E86d5wCNQjpevbEBg3_2VJLawm1ucL29T5T4epV48wrtJ8lVRyBw7HUolCmTx0RZayCKcNeaMCaOvbh0zvfb5SnMUY2pWrJHCYDeROsgVmC3-fPPv_xdELTzmyPQQmxf7cCLIkcemY/s72-c/OutgoingSMSData.png" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5626077093408809500.post-1606839626848763361</id><published>2013-10-14T17:36:00.001+05:30</published><updated>2013-10-14T17:41:20.095+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="android"/><category scheme="http://www.blogger.com/atom/ns#" term="inbox message"/><category scheme="http://www.blogger.com/atom/ns#" term="incoming message"/><category scheme="http://www.blogger.com/atom/ns#" term="message number"/><category scheme="http://www.blogger.com/atom/ns#" term="message text"/><category scheme="http://www.blogger.com/atom/ns#" term="message time"/><category scheme="http://www.blogger.com/atom/ns#" term="message type"/><category scheme="http://www.blogger.com/atom/ns#" term="SMS content"/><title type='text'>Incoming SMS details</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Using Android API&#39;s user can read incoming SMS message content programmatically.&lt;br /&gt;
&lt;div&gt;
To get SMS content first add below user permission in manifest file:&lt;/div&gt;
&lt;div&gt;
&amp;lt;uses-permission android:name=&quot;android.permission.READ_SMS&quot;&amp;gt;&amp;lt;/uses-permission&amp;gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Then call below method from activity class:&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
public StringBuffer getIncomingSMSContent() {&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;ContentResolver contentResolver = getContentResolver();&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Uri uri = Uri.parse(&quot;content://sms/inbox/&quot;);&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;StringBuffer messagedata = new StringBuffer();&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;int count = 0;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Cursor cursor = contentResolver.query(uri, null, null, null, null);&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;if (cursor.getCount() != 0) {&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;if (cursor.moveToFirst()) {&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;do {&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;messagedata.append(&quot;Incoming message count: &quot; + (count +1) + &quot;\n&quot;);&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;for (int m = 0; m &amp;lt; cursor.getColumnCount(); m++) {&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;      &lt;/span&gt;if (cursor.getColumnName(m).equalsIgnoreCase(&quot;address&quot;)&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;        &lt;/span&gt;|| cursor.getColumnName(m).equalsIgnoreCase(&quot;date&quot;)&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;        &lt;/span&gt;|| cursor.getColumnName(m).equalsIgnoreCase(&quot;body&quot;)&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;        &lt;/span&gt;|| cursor.getColumnName(m).equalsIgnoreCase(&quot;type&quot;))&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;      &lt;/span&gt;{&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;messagedata.append(cursor.getColumnName(m) + &quot; &amp;nbsp;: &quot;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;         &lt;/span&gt;+ cursor.getString(m));&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;messagedata.append(&quot;\n&quot;);&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;      &lt;/span&gt;}&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;}&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;messagedata.append(&quot;\n&quot;);&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;count++;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;} while (cursor.moveToNext());&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;}&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;cursor.close();&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;cursor = null;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;return messagedata;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
This method will return list of all incoming message content from inbox.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Here is the result :&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiqR9rFJ9EfnLh48kkHNUFjdM6yYkzHCd6lH0gr6Bfq8h_2QtmKXiC5iv7_o0qaFMoOhTYAgVE0matllbtkkNhBsQBJEqaYYB6ZVNu9UKl7HEwqw8lWDRX040cRMoJbCajL01ma6Pjp6iY/s1600/IncomingSMSData.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiqR9rFJ9EfnLh48kkHNUFjdM6yYkzHCd6lH0gr6Bfq8h_2QtmKXiC5iv7_o0qaFMoOhTYAgVE0matllbtkkNhBsQBJEqaYYB6ZVNu9UKl7HEwqw8lWDRX040cRMoJbCajL01ma6Pjp6iY/s320/IncomingSMSData.png&quot; width=&quot;213&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
In above result screen,&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
address : mobile number from which device received message&lt;/div&gt;
&lt;div&gt;
date : message received time in milliseconds&lt;/div&gt;
&lt;div&gt;
type : message type incoming/outgoing. Type 1 indicates as incoming message type&lt;/div&gt;
&lt;div&gt;
body : message text&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://android2011dev.blogspot.com/feeds/1606839626848763361/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5626077093408809500/1606839626848763361' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5626077093408809500/posts/default/1606839626848763361'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5626077093408809500/posts/default/1606839626848763361'/><link rel='alternate' type='text/html' href='http://android2011dev.blogspot.com/2013/10/incoming-sms-details.html' title='Incoming SMS details'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiqR9rFJ9EfnLh48kkHNUFjdM6yYkzHCd6lH0gr6Bfq8h_2QtmKXiC5iv7_o0qaFMoOhTYAgVE0matllbtkkNhBsQBJEqaYYB6ZVNu9UKl7HEwqw8lWDRX040cRMoJbCajL01ma6Pjp6iY/s72-c/IncomingSMSData.png" height="72" width="72"/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5626077093408809500.post-5856024103070746170</id><published>2011-08-20T14:05:00.000+05:30</published><updated>2011-08-20T14:05:33.279+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="android"/><category scheme="http://www.blogger.com/atom/ns#" term="android call duration"/><category scheme="http://www.blogger.com/atom/ns#" term="android call history"/><category scheme="http://www.blogger.com/atom/ns#" term="android call type"/><category scheme="http://www.blogger.com/atom/ns#" term="android phone number"/><category scheme="http://www.blogger.com/atom/ns#" term="call date time"/><category scheme="http://www.blogger.com/atom/ns#" term="incoming call"/><category scheme="http://www.blogger.com/atom/ns#" term="missed call"/><category scheme="http://www.blogger.com/atom/ns#" term="outgoing call"/><title type='text'>Get Android phone call history/log programmatically</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;To get call history programmatically first add read conact permission in Manifest file :&lt;br /&gt;
&amp;lt;uses-permission android:name=&quot;android.permission.READ_CONTACTS&quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create xml file. Add the below code in xml file :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;Linearlayout android:layout_height=&quot;fill_parent&quot;&lt;br /&gt;
&amp;nbsp;android:layout_width=&quot;fill_parent&quot;&lt;br /&gt;
android:orientation=&quot;vertical&quot;&amp;gt;&lt;br /&gt;
&amp;lt;Textview android:id=&quot;@+id/call&quot;&lt;br /&gt;
android:layout_height=&quot;fill_parent&quot;&lt;br /&gt;
android:layout_width=&quot;fill_parent&quot;&amp;gt;&lt;br /&gt;
&amp;lt;/Textview&amp;gt;&lt;br /&gt;
&amp;lt;/Linearlayout&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now call the getCallDetails() method in java class :&lt;br /&gt;
&lt;br /&gt;
private void getCallDetails() {&lt;br /&gt;
&lt;br /&gt;
StringBuffer sb = new StringBuffer();&lt;br /&gt;
Cursor managedCursor = managedQuery( CallLog.Calls.CONTENT_URI,null, null,null, null);&lt;br /&gt;
int number = managedCursor.getColumnIndex( CallLog.Calls.NUMBER ); &lt;br /&gt;
int type = managedCursor.getColumnIndex( CallLog.Calls.TYPE );&lt;br /&gt;
int date =  managedCursor.getColumnIndex( CallLog.Calls.DATE);&lt;br /&gt;
int duration =  managedCursor.getColumnIndex( CallLog.Calls.DURATION);&lt;br /&gt;
sb.append( &quot;Call Details :&quot;);&lt;br /&gt;
while ( managedCursor.moveToNext() ) {&lt;br /&gt;
String phNumber = managedCursor.getString( number );&lt;br /&gt;
String callType = managedCursor.getString( type );&lt;br /&gt;
String callDate = managedCursor.getString( date );&lt;br /&gt;
Date callDayTime = new Date(Long.valueOf(callDate));&lt;br /&gt;
String callDuration = managedCursor.getString( duration );&lt;br /&gt;
String dir = null;&lt;br /&gt;
int dircode = Integer.parseInt( callType );&lt;br /&gt;
switch( dircode ) {&lt;br /&gt;
case CallLog.Calls.OUTGOING_TYPE:&lt;br /&gt;
dir = &quot;OUTGOING&quot;;&lt;br /&gt;
break;&lt;br /&gt;
&lt;br /&gt;
case CallLog.Calls.INCOMING_TYPE:&lt;br /&gt;
dir = &quot;INCOMING&quot;;&lt;br /&gt;
break;&lt;br /&gt;
&lt;br /&gt;
case CallLog.Calls.MISSED_TYPE:&lt;br /&gt;
dir = &quot;MISSED&quot;;&lt;br /&gt;
break;&lt;br /&gt;
}&lt;br /&gt;
sb.append( &quot;\nPhone Number:--- &quot;+phNumber   +&quot; \nCall Type:--- &quot;+dir+&quot; \nCall Date:--- &quot;+callDayTime+&quot; \nCall duration in sec :--- &quot;+callDuration );&lt;br /&gt;
sb.append(&quot;\n----------------------------------&quot;);&lt;br /&gt;
}&lt;br /&gt;
managedCursor.close();&lt;br /&gt;
call.setText(sb);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Using this application user can access his call history. It show call number,call type i.e. incoming/outgoing/missed call, call date-time and call duration. &lt;br /&gt;
Here is the output where user can see all details :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhyXIJfm1_KBjqNgTLVQ9TMl2l1QCVlzUoLbn-5jrsFcZmNUt6IvU_RojSPsMHQyQt_8xVK_EluVbeZwuAP_CY-sAu6QchtQ-f75a_7j2KEohyL-lMuVAQUWi_u9hMixfaxlxtsbeTyI-s/s1600/call_history.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em; text-align: left;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhyXIJfm1_KBjqNgTLVQ9TMl2l1QCVlzUoLbn-5jrsFcZmNUt6IvU_RojSPsMHQyQt_8xVK_EluVbeZwuAP_CY-sAu6QchtQ-f75a_7j2KEohyL-lMuVAQUWi_u9hMixfaxlxtsbeTyI-s/s320/call_history.png&quot; width=&quot;214&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://android2011dev.blogspot.com/feeds/5856024103070746170/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5626077093408809500/5856024103070746170' title='72 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5626077093408809500/posts/default/5856024103070746170'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5626077093408809500/posts/default/5856024103070746170'/><link rel='alternate' type='text/html' href='http://android2011dev.blogspot.com/2011/08/get-android-phone-call-historylog.html' title='Get Android phone call history/log programmatically'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhyXIJfm1_KBjqNgTLVQ9TMl2l1QCVlzUoLbn-5jrsFcZmNUt6IvU_RojSPsMHQyQt_8xVK_EluVbeZwuAP_CY-sAu6QchtQ-f75a_7j2KEohyL-lMuVAQUWi_u9hMixfaxlxtsbeTyI-s/s72-c/call_history.png" height="72" width="72"/><thr:total>72</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5626077093408809500.post-1444684799697690351</id><published>2011-07-28T12:23:00.000+05:30</published><updated>2011-07-28T12:23:09.614+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="android"/><category scheme="http://www.blogger.com/atom/ns#" term="delete contacts"/><title type='text'>Delete contacts from Android device</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;We can delete the contacts from android device programmatically.&lt;br /&gt;
&lt;br /&gt;
Declare the permissions in manifest file:&lt;br /&gt;
&lt;uses-permission android:name=&quot;android.permission.READ_CONTACTS&quot;&gt;  &lt;br /&gt;
&lt;uses-permission android:name=&quot;android.permission.WRITE_CONTACTS&quot;&gt;&lt;br /&gt;
&lt;br /&gt;
Using Android 1.6 : &lt;br /&gt;
getContentResolver().delete(Contacts.People.CONTENT_URI,null,null);&lt;br /&gt;
&lt;br /&gt;
Using Android 2.0 and above:&lt;br /&gt;
getContentResolver().delete(ContactsContract.RawContacts.CONTENT_URI,null,&lt;br /&gt;
null);&lt;br /&gt;
&lt;br /&gt;
&lt;/uses-permission&gt;&lt;/uses-permission&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://android2011dev.blogspot.com/feeds/1444684799697690351/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5626077093408809500/1444684799697690351' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5626077093408809500/posts/default/1444684799697690351'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5626077093408809500/posts/default/1444684799697690351'/><link rel='alternate' type='text/html' href='http://android2011dev.blogspot.com/2011/06/delete-contacts-from-android-device.html' title='Delete contacts from Android device'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total><georss:featurename>Bengaluru, Karnataka, India</georss:featurename><georss:point>12.9715987 77.594562699999983</georss:point><georss:box>12.7518902 77.342821199999989 13.191307199999999 77.846304199999977</georss:box></entry><entry><id>tag:blogger.com,1999:blog-5626077093408809500.post-6445945221867003747</id><published>2011-06-22T14:39:00.000+05:30</published><updated>2011-06-22T14:39:13.815+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="android"/><category scheme="http://www.blogger.com/atom/ns#" term="installed application"/><category scheme="http://www.blogger.com/atom/ns#" term="package name"/><category scheme="http://www.blogger.com/atom/ns#" term="version code"/><category scheme="http://www.blogger.com/atom/ns#" term="version name"/><title type='text'>Installed application information in Android</title><content type='html'>Using PackageManager we can get the all installed application details in Android device like package name,version code,version info,class name etc.&lt;br /&gt;
&lt;br /&gt;
Code snippet:&lt;br /&gt;
&lt;br /&gt;
PackageManager pckMgr; &lt;br /&gt;
  pckMgr = getPackageManager(); &lt;br /&gt;
  List&lt;PackageInfo&gt; appInfo = pckMgr.getInstalledPackages(PackageManager.GET_ACTIVITIES); &lt;br /&gt;
  Log.i(&quot;Number of Applications are installed &quot; ,&quot;:&quot;+ appInfo.size()); &lt;br /&gt;
  for ( int cnt=0; cnt &lt; appInfo.size(); cnt++){&lt;br /&gt;
   &lt;br /&gt;
   Log.i(&quot;Package name  &quot;,&quot;:&quot;+appInfo.get(cnt).packageName);&lt;br /&gt;
   Log.i(&quot;Application name &quot;,&quot;:&quot;+appInfo.get(cnt).applicationInfo.loadLabel(getPackageManager()));&lt;br /&gt;
   Log.i(&quot;Version code  &quot;,&quot;:&quot;+appInfo.get(cnt).versionCode);&lt;br /&gt;
   Log.i(&quot;Version name  &quot;,&quot;:&quot;+appInfo.get(cnt).versionName);&lt;br /&gt;
  &lt;br /&gt;
  }</content><link rel='replies' type='application/atom+xml' href='http://android2011dev.blogspot.com/feeds/6445945221867003747/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5626077093408809500/6445945221867003747' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5626077093408809500/posts/default/6445945221867003747'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5626077093408809500/posts/default/6445945221867003747'/><link rel='alternate' type='text/html' href='http://android2011dev.blogspot.com/2011/06/installed-application-information-in.html' title='Installed application information in Android'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total><georss:featurename>Bengaluru, Karnataka, India</georss:featurename><georss:point>12.9715987 77.594562699999983</georss:point><georss:box>12.7518902 77.342821199999989 13.191307199999999 77.846304199999977</georss:box></entry><entry><id>tag:blogger.com,1999:blog-5626077093408809500.post-6162786639295412545</id><published>2010-02-02T11:02:00.000+05:30</published><updated>2010-02-02T11:04:06.781+05:30</updated><title type='text'>Android based Acer Liquid Launched in India</title><content type='html'>&lt;b&gt;Acer Liquid&lt;/b&gt; launcehed in India with &lt;b&gt;Android1.6&lt;/b&gt; high defination smartphone.&lt;br /&gt;
It is VGA smartphone with latest Android1.6 OS.&lt;br /&gt;
&lt;b&gt;Features &lt;/b&gt;: &lt;br /&gt;
multimidia&lt;br /&gt;
web browsing&lt;br /&gt;
video streaming&lt;br /&gt;
smart integration of Facebook, Twitter, Youtube, Picasa and Flickr in the address book&lt;br /&gt;
MP3 (MP3/WAV/WMA/eAAC+ player)&lt;br /&gt;
MP4 (MP4/WMV/H.264/H.263 player)&lt;br /&gt;
messaging (SMS (threaded view), MMS, Email, Instant Messaging)&lt;br /&gt;
browser (HTML) &lt;br /&gt;
memory of 256MB RAM&lt;br /&gt;
512MB ROM&lt;br /&gt;
microSD card slot of up to 32GB. &lt;br /&gt;
3.5mm audio jack&lt;br /&gt;
vibration&lt;br /&gt;
WAV ringtones&lt;br /&gt;
3G (HSDPA 7.2 Mbps, HSUPA 2.0 Mbps) enabled phone &lt;br /&gt;
weighs 135g with 115 x 62.5 x 12.5 mm dimensions&lt;br /&gt;
5-megapixel camera &lt;br /&gt;
GPS&lt;br /&gt;
HSDPA connectivity&lt;br /&gt;
RS.24,990 with 2GB micro-SD</content><link rel='replies' type='application/atom+xml' href='http://android2011dev.blogspot.com/feeds/6162786639295412545/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5626077093408809500/6162786639295412545' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5626077093408809500/posts/default/6162786639295412545'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5626077093408809500/posts/default/6162786639295412545'/><link rel='alternate' type='text/html' href='http://android2011dev.blogspot.com/2010/02/android-based-acer-liquid-launched-in.html' title='Android based Acer Liquid Launched in India'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5626077093408809500.post-9202373578227650162</id><published>2010-02-01T17:53:00.000+05:30</published><updated>2010-02-01T17:53:07.061+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="android"/><category scheme="http://www.blogger.com/atom/ns#" term="news"/><title type='text'>Android available with &#39;Deposit@Mobile&#39; App</title><content type='html'>Good news for Android users. According to MobileMag, Google Android Nexus One users, and other Android smartphone users will be able to use the ‘Deposit@Mobile’ app to deposit checks into their account without ever having to go to the bank again.&lt;br /&gt;
&lt;br /&gt;
Apparently, users are required to be pre-qualified by their branch and take a picture of the front and back of an endorsed check and then submit the image to their account info.&lt;br /&gt;
&lt;br /&gt;
Seemingly, the app comes equipped with a few extra features of an ATM Locator to find the closest ATM’s, a detailed accident checklist, a loan calculator which will estimate either car or mortgage payments, and a car rental locator for the nearest Avis, Budget, or Hertz.&lt;br /&gt;
&lt;br /&gt;
Reportedly, users must be running Android 1.6 or higher in order to use the app. The pricing details of the app are quite bleary for now.</content><link rel='replies' type='application/atom+xml' href='http://android2011dev.blogspot.com/feeds/9202373578227650162/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5626077093408809500/9202373578227650162' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5626077093408809500/posts/default/9202373578227650162'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5626077093408809500/posts/default/9202373578227650162'/><link rel='alternate' type='text/html' href='http://android2011dev.blogspot.com/2010/02/android-available-with-depositmobile.html' title='Android available with &#39;Deposit@Mobile&#39; App'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>