Click here to Skip to main content
15,936,633 members
Articles / Mobile Apps / Android

CPDroid (CodeProject on Fly !!)

Rate me:
Please Sign up or sign in to vote.
4.94/5 (42 votes)
20 Mar 2014CPOL5 min read 66K   694   49   41
A lazy and attractive tool for CodeProject


Before starting my article, at the outset I would like to say that I am very addicted to reading articles on CodeProject. Also, I am a small contributor in this community and have given a couple of articles to it. I try to read almost all good articles in this community. Sometimes, I found that I have time but I don’t have my laptop to browse article (usually on long drive to my native place), so I surf CodeProject site in my mobile browser, which is not attractive. So in the process of solving my problem, I decided to make a native app for CodeProject and finally I developed an application which is known as “CPDroid” in the Android market. I would like to thank Luc Pattyn for his beautiful effort in CPVanity tool for CodeProject as I get most of the ideas from his article for CPDroid. You can install it from Android market here.

Anyway let’s start a little introduction for CPDroid. CPDroid is a native application for Android based mobile phone. I divided the application component in three parts.

  1. The first part consists of author search on the basis of their CodeProject member id. It will fetch author information and respective data in a neat and clean format.
  2. The second part gives latest feed of CodeProject articles and tips.
  3. The third part is just about me ? and license.

CPDroid Functionality

Functionality of CPDroid is very simple and straightforward. Let us summarize it as:

  • Search result of author is very handy and attractive. User will get author information with their respective points and other details like number of articles, messages, etc. along with list of articles and reputation graph.
  • User can read every article on click of listview and it will open article in best readable format of webview.
  • Get latest feed of CodeProject articles using Android SAX parser technique.

Main UI

Main user interface is navigator for different parts. This is Android activity which calls three different component buttons. Intent is used to fire associated activity for search author and latest feeds. Because Main UI consists of simple functionality, then I would not go too much in this section and it is better to give how I made rounded buttons in UI for navigation to section.

<?xml version="1.0" encoding="utf-8"?>
    <item android:state_pressed="true" >
     <bitmap android:src="@drawable/btnsearchall_pressed"
        android:gravity="center" />        
     <item android:state_enabled="true" >
     <bitmap android:src="@drawable/btnsearchall"
        android:gravity="center" />        

In Android, we can highlight the button through custom images. To indicate the different button states (focused, selected, etc.), you can define a different image for each state. E.g., a blue image by default, an orange one for when focused, and a yellow one for when pressed. An easy way to do this is with an XML drawable "selector." In this code, when button is pressed, it will call drawable source image button pressed and when it is not, it will call different drawable. UI is simply delegated by the Android operating system by mapping it elegantly. And this is the beauty of Android OS which attracts me to jump in Android.

Search Author

This is my favourite section and USP of CPDroid. User can perform search author with respective member Id. Though it is very tough to search author with id instead of name, I can’t put in more effort on custom URL and complex Regex operation to get required data of author. Actually life is easy if CodeProject would have any web service for this. Every data is coming from parsed HTML which I must say it is not good for a stable application. And this is the big fear of application for down as well. Anyway, I hope CodeProject will provide some web service in future to extend the community.

Anyway Search author result is separately handled by the model and parsing of HTML is handled by thread which delivers to view by Handler class. A Handler allows you to send and process Message and Runnable objects associated with a thread's MessageQueue. Each Handler instance is associated with a single thread and that thread's message queue. When you create a new Handler, it is bound to the thread / message queue of the thread that is creating it -- from that point on, it will deliver messages and runnables to that message queue and execute them as they come out of the message queue.

There are two main uses for a Handler:

  1. To schedule messages and runnables to be executed as some point in the future; and
  2. To enqueue an action to be performed on a different thread than your own.
public void GetCpAuthorSummary(final ICPAuthorSummary cpAuthorNameCallback) {
    new Thread(new Runnable() {

        public void run() {

            try {
                 summaryList = cp.GetAuthorSummary();
                 authorName = cp.GetName();
        Runnable() {
                    public void run() {
                        (true, authorName, summaryList);
            } catch (Exception ex) {
                    authorName, summaryList);

Here, I used Interface ICPAuthorSummary for getting results from thread and further implement interface in Search author Activity. Boolean result of Interface ensures when to publish data in view.

Image Viewer

Once search is performed, it will gives Author CodeProject profile Image with other relative details. For image viewer, I used to download image from URL which extracts image from application context and HTML, then downloads to stream and generates Drawable Image source.

public Drawable ImageOperations(Context ctx, String url, String saveFilename) {
    try {
        InputStream is = (InputStream) this.fetch(url);
        Drawable d = Drawable.createFromStream(is, "src");
        return d;
    } catch (MalformedURLException e) {
        return null;
    } catch (IOException e) {
        return null;

public Object fetch(String address) throws MalformedURLException,IOException {
    URL url = new URL(address);
    Object content = url.getContent();
    return content;

Author Stats, Articles and Reputation

This section will have three tabs associated with it. First tab “Stats” gives listView of stats of articles. Here, I put in more effort to get regular expression for stats.

Articles will gives article for respective searched author. All articles will be published with their article details like View, Bookmark, votes, Popularity and Ratings. You can directly click on any article and read it in webview. Reputation is not very attractive, it just gives the reputation graph.

Latest Article Feed

For this section, thanks God!! CodeProject gives RSS feed for latest article. So I used Android SAX parser to get feed in view. I’m not going to give details on Android SAX parser because for this, it must be covered in a full phase article which I will surely give you in a separate effort of an article thread.


CPDroid is a simple, attractive and easy to use native application in Android. However, I did not implement a lot of functionality in the application because of absence of CodeProject Web service. It’s really hard to parse HTML content and get data using complex regular expression. But if this application becomes popular, I will defiantly release next version of CPDroid.

Future Component

The future idea of few components is running in mind to add more functionality in CPDroid. But I would like to release it in the next version if application will give good response from Android market. Some components are below:

  • Bookmark functionality to bookmark favorite author
  • Save article in PDF
  • Menu Control navigator
  • Show Famous Author Awards


  • Release Version: 1.0


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Written By
Technical Lead
United States United States
Rohit started Embedded Programing in his college days and now he is a Software Developer by Profession. Mainly he interested in cutting edge technology offer by Microsoft (i.e Azure,MVC). He Loves coding and his passion is always been towards Microsoft Technologies. Apart from coding his other hobbies include reading books and hang out with friends is his most favorite past time hobby.

1. 20 Apr 2014: Best Mobile Article of March 2014 - First Prize

Comments and Discussions

QuestionThats very good of you Pin
chidexj4-Feb-17 19:09
professionalchidexj4-Feb-17 19:09 
GeneralMy vote of 5 Pin
D V L26-Oct-15 1:49
professionalD V L26-Oct-15 1:49 
GeneralRe: My vote of 5 Pin
maq_rohit27-Oct-15 7:21
professionalmaq_rohit27-Oct-15 7:21 
GeneralMy vote of 5 Pin
swatiasthana8-Oct-15 23:00
swatiasthana8-Oct-15 23:00 
QuestionThanks for sharing Pin
Yildirim Kocdag8-Apr-14 4:49
Yildirim Kocdag8-Apr-14 4:49 
QuestionWill be waiting for details on Android SAX parser :D Pin
Rivalus2-Apr-14 16:31
Rivalus2-Apr-14 16:31 
GeneralNice codeproject app Pin
CrasherGeek31-Mar-14 8:20
CrasherGeek31-Mar-14 8:20 
Question5 from me Pin
MarvarickUSA25-Mar-14 10:08
MarvarickUSA25-Mar-14 10:08 
QuestionRegarding Android App Market Link Pin
Ranjan.D23-Mar-14 16:57
professionalRanjan.D23-Mar-14 16:57 
GeneralMy vote of 5 Pin
Prasad Khandekar21-Mar-14 3:51
professionalPrasad Khandekar21-Mar-14 3:51 
GeneralRe: My vote of 5 Pin
maq_rohit21-Mar-14 9:40
professionalmaq_rohit21-Mar-14 9:40 
QuestionCan I please send you some updated graphics? Pin
Chris Maunder21-Mar-14 3:36
cofounderChris Maunder21-Mar-14 3:36 
AnswerRe: Can I please send you some updated graphics? Pin
maq_rohit21-Mar-14 9:53
professionalmaq_rohit21-Mar-14 9:53 
GeneralMy vote of 5 Pin
Volynsky Alex21-Mar-14 1:45
professionalVolynsky Alex21-Mar-14 1:45 
GeneralRe: My vote of 5 Pin
maq_rohit21-Mar-14 9:40
professionalmaq_rohit21-Mar-14 9:40 
GeneralRe: My vote of 5 Pin
Volynsky Alex21-Mar-14 10:40
professionalVolynsky Alex21-Mar-14 10:40 
QuestionCan't open archive with source code Pin
Josip8420-Mar-14 23:37
Josip8420-Mar-14 23:37 
AnswerRe: Can't open archive with source code Pin
Ranjan.D21-Mar-14 1:00
professionalRanjan.D21-Mar-14 1:00 
GeneralNice Pin
Serge Desmedt20-Mar-14 9:55
professionalSerge Desmedt20-Mar-14 9:55 
GeneralRe: Nice Pin
maq_rohit20-Mar-14 11:14
professionalmaq_rohit20-Mar-14 11:14 
GeneralRe: Nice Pin
MacSpudster20-Mar-14 11:58
professionalMacSpudster20-Mar-14 11:58 
GeneralRe: Nice Pin
maq_rohit20-Mar-14 12:05
professionalmaq_rohit20-Mar-14 12:05 
GeneralRe: Nice Pin
Serge Desmedt21-Mar-14 7:58
professionalSerge Desmedt21-Mar-14 7:58 
GeneralMy vote of 5 Pin
virendra2411-Apr-11 0:38
virendra2411-Apr-11 0:38 
QuestionWont run ?? Pin
Bikeaccdnt5-Apr-11 10:34
Bikeaccdnt5-Apr-11 10:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.