Torbjorn Zetterlund

Sun 24 2016

Customizing WordPress android app

by bernt & torsten

If you have bought the source code to the WordPress Android App, then you can read on – as these are the instructions on how to customize and make the source code your own.

If you have not bought the source code, you can do so by making a purchase here on my site, by selecting the button below.

You can get the code from Github.

There are a few articles that you might want to read before making a decision

How to effectively using the WP REST API V2 with Android App

Customizing Android App

The easy way to customize this app is by only inserting your own URLs to your WordPress site. To do this open the Const file located under app/java/ directory.

public static final String URL_BLOG_CATEGORIES = "https://<your-url>/wp-json/wp/v2/categories?per_page=60";

public static final String URL_RECENTLY_ADDED = "https://<your-url>/wp-json/wp/v2/posts/";
public static final String URL_AUTHOR = "https://<your-url>/wp-json/wp/v2/users/";//    

public static final String URL_RECENTLY_ADDED = "https://<your-url>/api/get_recent_posts/";
public static final String URL_CATEGORY_POST = "https://<your-url>/wp-json/wp/v2/posts?categories=_CAT_ID_";

public static final String URL_STORY_PAGE = "https://<your-url>/wp-json/wp/v2/posts/_STORY_ID_/";
public static final String URL_SEARCH_RESULT = "https://<your-url>/wp-json/wp/v2/posts?search=_SEARCH_KEYWORD_";
public static final String URL_COMMENTS_LIST_PAGE = "https://<your-url>/wp-json/wp/v2/comments?post=_STORY_ID_";

Change all the above URLs in this code with your own WordPress URL and save the file.

Customizing App color and strings

You can also change the app default colours and the name of this app. Colours used in this app are all in hexadecimal value (e.g.: #CECECE). Now just find hex values you want to change in all XML files located in drawable, layout, and values directories of resources. Many colours used in this app are placed in the color.xml file. Which you can find app/res/values

And, just find the strings.xml file in the values directory of the resources and open it to change the name of this app or other word used in this app. Look for  app_name to change the application’s name.

Customizing Application logo and icons

To make this app represent your WordPress site you need to change the application icon, and logo with your own. To change them you need to create and replace images from a drawable directory.

Note: Make 4 different sized icons and place them in the (drawable-ldpi, drawable-mdpi, drawable-hdpi, and drawable-xhdpi). Sizes are as following

  • drawable-ldpi: 36×36 pixels
  • drawable-mdpi: 48×48 pixels
  • drawable-hdpi: 72×72 pixels
  • drawable-xhdpi: 96×96 pixels

Also, Make it sure that all images you create have the same file name with the file name and type of images that they have.

Configure AdMob

Please visit Google AdMob to get the AdMob Unit and Publisher ID. Please do the following settings, once you get the AdMob Unit ID.

  • Open Const file located underapp/java/ directory.
  • Change the ADMOBService_ACTIVE variable to true from false.
  • Now open strings.xml file form values resources directory.
  • Paste your AdMob Unit and Publisher ID in the unit_id string.

Note: Make sure your AdMob Unit ID that you are going to Paste is in ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx format. If you want to disable the AdMob Support then set the ADMOBService_ACTIVE to false.

Configure Google Firebase Cloud Messaging (FCM)

We are using Google Firebase Cloud Messaging (FCM) for notifications, please look at these details on how to set up your FCM. On the server side, you require the WP Thor FCM plugin, you can get that from me as well.

Google Analytics Tracking Code

This Android App has the ability to track detailed statistics about the app usage using Google Analytics Service. It’s the most widely used website statistics service. The basic service is free of charge and a premium version is available for a fee.

  • Open global_tracker.xml, app_tracker.xml, ecommerce_tracker.xml files one by one. These files are located under app/res/xml directory.
  • Change the ga_trackingId string to your own Analytics Tracking ID.
  • You can toggle Analytics_ACTIVE variable to true or false to enable or disable.

Note: Make sure you’ve changed the tracking id to get your own statistics.

Change Colors of the App

You can also change the colours of the action bar, post title, heading, etc from the app style files.

  • Open style.xml and color.xml files located under app/res/values/ directory.
  • You will see two style.xml files. One for Pre-Lollipop devices and other for Lollipop devices.
  • Change the colors and style and Enjoy 🙂

Localization / Translation

WordPress Android now has RTL support. You can add your own language.

In your projects file navigator, expand the values directory, right-click the strings.xml file to open the Translation Editor.

In the Translation Editor, click the globe icon to add a new language file. You may need to close and re-open the Translation Editor tab after adding a new language if it does not show up immediately. Please share any translations.

Forcing your app to follow RTL Layout

This Android App has the ability to force the app to follow RTL Layout. If you need to change the layout to RTL.

  • Open Const file located underapp/java/ directory.
  • Change the forceRTL variable from false to true.
  • Change the forceRTLLang variable to your desired language. e.g. ar for Arabic

Note: Make sure you’ve created a language translation file in the package under the values directory.

Configure the Social Media Pages

In the app, you can add links to your Facebook, Twitter, and Google+. To configure these pages, do follow these steps

  • Open Const file located under app/java/  directory.
  • Change the Facebook_URL variable to configure the Facebook Page.
  • Change the Twitter_URL variable to configure the Twitter Page.
  • Change the GooglePlus_URL variable to configure the Google Plus Page.

Testing Android App

To test this android app, on Android Studio IDE, press Shift + F10 key and select Run As > Android Application.

Publishing Android App

Android Studio has provided App-signing capability so you don’t have to open up your keytool or do any complicated task.

  1. Go to Build -> Generate Signed APK…
  2. Click Create new…
  3. To make a new keystore, just put a non-exist keystore in “Key store path:” (The folder MUST exist, while the file MUST NOT exist).
  4. It will automatically complete our last dialog in keystore. Just click “Next
  5. And “Finish


Upload the WP REST API plugin. Follow these steps, if you’re a newbie!

  • Login to your WordPress
  • Do a search for WP REST API
  • Select WP REST API and install it.
  • Activate the Plugin

Install the WP Rest API JSON Filter which I have made available on Github or you can read the article How to effectively using the WP REST API V2 with Android App – which explains how I extend the WP Rest API JSON response with additional fields to save URL request from the Android app.