How creating a blog native app is *almost* as easy as a web-blog
Before starting, let me present myself, my name is Anis Brachemi, a young passionate programmer who tried to play with each field (game, mobile, web, simulation). If you have read up to here, it means you really want to know how a "difficult" field such as native mobile apps can because as easy as using a blog builder ?
Well you might be disappointed if you did not read the almost in the title because this process, contrarily to web blogs, actually requires some programming but when you have done it once and you understand the concept, you will be able to create an infinity of them !
To create an online android app you will need to have :
- Your idea
- A computer
- Either your own server with a database and Php installed (~25$ a year) or firebase (which acts like a server and provides everything you need (database, notifications...).
- Some coding !
When you have everything listed above, you can create your project by opening Android studio and your server and setting up the files. As this is not really a tutorial, specific steps can be found on Youtube and with some practice. When you have practiced a bit, you understand that all you have to do in order to create your online working blog app is :
- Create a database on the server
- Gather the information from that database using Php and Json
- Get that info using post requests and specific keys to better protect your info from android
- With an adapter, you can create a new post layout (with a specific id and everything) for each post in the database with around 60 simple lines of code.
public class TopAdapter extends RecyclerView.Adapter<TopAdapter.MyViewHolder> {
private Context mContext;
private List<TopTwenty> messages;
private MessageAdapterListener listener;
private static int currentSelectedIndex = -1;
public class MyViewHolder extends RecyclerView.ViewHolder implements View.OnLongClickListener {
public TextView title, likes;
public ImageView image;
public PercentRelativeLayout messageContainer;
public MyViewHolder(View view) {
super(view);
title = (TextView) view.findViewById(R.id.mTitle);
image = view.findViewById(R.id.image_view);
likes = (TextView) view.findViewById(R.id.mlikes);
messageContainer = (PercentRelativeLayout) view.findViewById(R.id.message_container);
view.setOnLongClickListener(this);
}
@Override
public boolean onLongClick(View view) {
listener.onRowLongClicked(getAdapterPosition());
view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
return true;
}
}
public TopAdapter(Context mContext, List<TopTwenty> messages, MessageAdapterListener listener) {
this.mContext = mContext;
this.messages = messages;
this.listener = listener;
}
@Override
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View itemView = LayoutInflater.from(parent.getContext())
.inflate(R.layout.top_row, parent, false);
return new MyViewHolder(itemView);
}
@Override
public void onBindViewHolder(final MyViewHolder holder, final int position) {
final TopTwenty message = messages.get(position);
holder.title.setText(message.getName());
holder.likes.setText(message.getLikes() + " "+ mContext.getResources().getString(R.string.likes));
TextDrawable.builder().buildRound(message.getName(), color);
holder.itemView.setActivated(true);
applyClickEvents(holder, position);
}
private void applyClickEvents(final MyViewHolder holder, final int position) {
final TopTwenty message = messages.get(position);
final int likes = message.getLikes();
holder.messageContainer.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
listener.onMessageRowClicked(position, message.getName());
}
});
}
@Override
public long getItemId(int position) {
return messages.get(position).getId();
}
@Override
public int getItemCount() {
return messages.size();
}
public interface MessageAdapterListener {
void onMessageRowClicked(int position, String name);
void onRowLongClicked(int position);
}
}
-
Then, what you can do is customize your app layout by adding a bottom navigation bar, a page for when the user wants to "read more", settings, push notifications using firebase when you publish a new post, a contact me page and even ads.
-
The last part is if you don't want to go to the database and create new posts each time from there since the database looks like the image on the left therefore you would like to create a post manager using html, javascript and css.
So, this was the recipe to create your own app and reach more people because nowadays everybody's on their phone and imagine if they could read your new posts at the moment you post them. Want to reach iOS user ? It's almost the same thing but you would need a mac for that !