Source Code


Manage Your Android App Directly From WordPress Dashboard. Also, Send Push Notifications to users. Add Categories, Post, Slider, Comments, No Internet Activity, Notification Activity, Feed Activity, Post Details, and Much More. Also, Make Revenue From Admob.

We made the project as simple as possible for easy understanding. It contains few JAVA and XML files
to customize. If you are new in Android Studio follow the instructions below to open project:

● Android Studio 3.5 or higher.
● Android SDK v29 installed.
● Build Tool 29.0.2 installed.

Change Splash Image:
Open app/src/main/res/drawable/ic_launcher icon. Replace the ic_launcher.png by your icon.

Change App Template:
We have 5 different templates in our project to serve the different jobs. You can choose one of them. Open
app\src\main\java\com\bestweby\enewz\activity\SplashActivity.class then set your desired template
class from below classes as marked below.
NewsTemplateActivity.class, BlogTemplateActivity.class, ArticleTemplateActivity.class,
StoryTemplateActivity.class, FeedTemplateActivity.class

Change Navigation Drawer:
You can Change the navigation drawer item from app\src\main\res\menu\nav_drawer_layout.XML File.
Add/remove items will also need to change the
java source file. To do this open
app\src\main\java\com\bestweby\enewz\app\BaseActivity.class file and modify
onNavigationItemSelected()override method as you required.
Change Social Media Link:
Open app/src/main/res/values/strings.xml. Modify the value of Facebook, Youtube, Twitter,
Instagram, Pinterest URL with your social URL.

Modify App Language:
We have added 10 different languages (English, Arabic, French, German, Spanish, Indonesian, Italian,
Hindi, Turkish, Russian) as default. You may need to set your own language, follow the instructions to
set your language in the app:

Setup Deeplinking:
Open app/src/main/res/values/strings.xml. Modify the value of the website_domain URL with your social

Log into your website hosting and find header.php inside Wp-Content\Themes\Your_theme directory. Then copy. Paste below codes by changing with your website and app info within

<head> Meta Property Code </head>.
<meta property="al:android:url" content="">
<meta property="al:android:package" content="com.bestweby.enewz">
<meta property="al:android:app_name" content="ENEWZ">

Website Configuration (WordPress Site)
This project built on WordPress. If you don’t have any WordPress installed, then kindly request
hosting provider to prepare one for you or you can install a WordPress
site by yourself.
Install WordPress REST API:
Go to WordPress Dashboard > Plugins > Add New > Search for ‘WordPress REST API (Version 2)’

Install Now > Activate.

Customize Website:
Customize your site url in to app. Open java classapp/src/main/java/com/bestweby/enewz/network/

WordPress Configuration:
To get ‘post id’, Go to WordPress Dashboard > Settings > Permalinks> Custom Structure >Select
‘/%post_id%/’> Save Changes (can be found at the bottom of the page). Now post id will be shown
with each post in the url.

Enable Post Commenting:
To enable the post comment facility from the app we have configured the
‘WordPress REST API’ plugin like below.
Go to WordPress Dashboard > Plugins > Editor > Select plugin to edit (Select WP REST API) >
Select. Then, in this window, select ‘extras.php’ > put the filter code as shown in the screenshot and
then click the Update File.

add_filter( 'rest_allow_anonymous_comments', '__return_true' );

Go to WordPress Dashboard > Settings > Discussion > Deselect Previously Approved Comment >
Save Changes (can be found at the bottom of the page)

Push Notification
App Level Configuration:
1) Open and login via your gmail account in to
2) Click on Add Project option, provide project name and region and create project.
3) Click on Add Firebase to your Android App, Provide Package Name, App Name and Release
SHA1 of your release keystore.
4) Click on Register App and Download google-service.json and Continue and Finish.
5) Paste google-service.json to /app directory (replace previous one).
6) Do a sync And rebuild your android project.
Server Level configuration:
We provided a Push notification console script using php. You need an Apache server hosting to run it.
If you don’t have a server you can still configure by installing Apache server in your PC.

Copy Legacy server key from firebase for your android project.

  1. Open config.php from push_enewz/ and modify value of $apiKey by the Legacy server key.

Modify $pushTopic as your project name and set to android project as well. Open
app/src/main/res/values/strings.xml change push notification topic as server $pushTopic

Host push notification console files to your server.

Collect Server key and Sender ID from Firebase Console, to setup OneSignal.

Install OneSignal – Web Push Notification WordPress Plugin from your website dashboard.

Collect App ID and REST API KEY from OneSignal Dashboard and configure in to your website.

Open Project Module level Gradle and Paste OneSignal App ID like below.

To get well formatted auto push notification and open specific post in app configure ‘WordPress REST
API’ plugin like below. Go to WordPress Dashboard > Plugins > Editor > Select plugin to edit (Select
WP REST API) > Select. Then, in this window, select ‘extras.php’ > put OneSignal Config Code.txt
codes as shown in the screenshot and then click the Update File, you get it main product folder.

Special Notes:
● Set Featured image to all posts from WordPress dashboard To show a picture on the top of
each post-in-app,
● By enabling some posts ‘sticky’ you can see the ‘Featured Posts’ as a slider on the
● Use the Youtube video link in the post to see the video in post detail.
● If a post under is set for multiple categories will be shown in the post list of both categories.
So, set a post under a single category.
● To show Home Slider autoplay go to your desired (News/Blog/Article/Story/Feed)Activity class
and uncomment lines between 330 and 355 in the showSlider() method.
● Make sure posts accept comment before publishing unless users will not able to comment on
post using the app.
● Configure OneSignal as above explained format, unless app will only receive a
notification, will
not save to local memory and will fail to open specific post details information.

Download Source Code

Leave a Comment