Teach you how to make a personal app

We all know that developing an app depends to a large extent on the server: the server provides interface data, and then we display it; in addition, to develop an app, we also need the assistance of an artist to cut the map. Without the interface and without the art, the app seems to be only a stand-alone version or a tool app. Is this really the case? Let's show my personal app first, there is no server, no art, in other words, I did everyone's work:

This app is called "Weiyan". It means a lot to me. At first, Weiyan was just a project for me to practice. I just started working and my technology is limited. Weiyan is just a sqlite notepad app that can only be operated locally. Later, it gradually evolved into the present. It’s an almost perfect app. I learned a lot from it. I am familiar with the whole process from project approval to launch. The latest technology has been put into practice, and I have changed from a programmer’s thinking to a product thinking, such as simple Photoshop. Of course, long-term accumulation will naturally bring economic benefits. Here I show my app advertising revenue, the sum of all my apps: at most more than 4,000 a month, what concept is more than 4,000, which is higher than my salary at that time, these " Achievement" has the capital I can brag here, hahaha!

Next, I will analyze one by one and take you to complete such a complete app.

no server

are p

I overheard my Daniel colleague talking about parsing html, and I was more interested in searching for what it was. I learned about a powerful thing, jsoup, which can parse html, that is, a website, so my Weiyan got out of the stand-alone version. For users, they don't care where the data comes from, no matter whether you fetch it from the interface or parse the html, they care about the improvement of the app experience and functions. I just lied about it and took the data from the web page. Too many people in the group asked me what server I used, and after replying too many times to parse the html, I was unwilling to reply.

One of the biggest advantages of choosing this method is that the data does not need to be maintained by myself, which cleverly avoids the fact that I do not know how to develop on the server side, let alone make an interface; parsing html also has the biggest drawback. Once the node of the other party's website changes, Maybe your app hangs and must be updated in time.

Instructions

Step 1 : First, network request, Retrofit used here, see: Android MVP+Retrofit+RxJava practice summary . By parsing my blog http://wuxiaolong.me/ example, you can get data similar to the following: In Google Chrome, right-click on my blog page - view the source code of the webpage (V), and also see the above data.

Step 2 : 1. app/build.gradle

compile 'org.jsoup:jsoup:1.10.1'

2. Tips for parsing html: observe more html nodes and tags. First observe the data we want to parse (take my blog http://wuxiaolong.me/ as an example). The home page has five elements: title, publication time, article classification, article comments, and article abstracts. This time, we only use Google Chrome. Need title, publication time, article abstract; you can see that my blog is paginated, the first page URL is http://wuxiaolong.me and the second page URL is http://wuxiaolong.me/page/2/ , After that, the difference is the page number, so if the app does pagination, it needs to judge the first page and other pages. The final result I made: we analyze one by one. Regarding the jsoup syntax, I will not talk about it here, see the jsoup official website .

(1) The title data structure is as follows:

<h1 class="post-title" itemprop="name headline">
<a class="post-title-link" href="/2016/10/31/AppShortcuts/" itemprop="url">Android App Shortcuts</a>
</h1>

The observation can be resolved according to getElementsByClass of class="post-title":

//responseBody是retrofit网络请求返回的,转成String,即我们需要解析的数据
Document document = Jsoup.parse(new String(responseBody.bytes(), "UTF-8"));
List<Element> titleElementList = new ArrayList<>();
Elements titleElements = document.getElementsByClass("post-title-link");
for (Element element : titleElements) {
    titleElementList.add(element);
    //text拿到文本,如这里的“Android App Shortcuts”
    LogUtil.d("text=" + element.text());
    //拿到href属性值,如这里“/2016/10/31/AppShortcuts/”,即博客链接,如果跳转详情需要加上“http://wuxiaolong.me”
    LogUtil.d("href=" + element.attr("href"));
}

(2) The data structure of publication time is as follows:

<span class="post-time">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time itemprop="dateCreated" datetime="2016-10-31T21:49:53+08:00" content="2016-10-31">2016-10-31</time>
</span>

Observation, also parsed with getElementsByClass:

List<Element> timeElementList = new ArrayList<>();
Elements timeElements = document.getElementsByClass("post-time");
for (Element element : timeElements) {
    //这里通过解析"time"标签,然后取文本,即“2016-10-31”
    LogUtil.d("time=" + element.getElementsByTag("time").text());
    timeElementList.add(element);
}

(3) The data structure of the article abstract is as follows:

<div class="post-body" itemprop="articleBody">
<h1 id="简介"><a href="#简介" class="headerlink" title="简介"></a>简介</h1>
<p>Android 7.1允许您定义应用程序中特定操作的快捷方式。这些快捷键可以显示桌面,例如Nexus和Pixel设备。快捷键可让您的用户在应用程序中快速启动常见或推荐的任务。<br>每个快捷键引用一个或多个意图,每个意图在用户选择快捷方式时在应用程序中启动特定操作。可以表达为快捷方式的操作示例包括:<br>
<div class="post-more-link text-center">
<a class="btn" href="/2016/10/31/AppShortcuts/" rel="contents">
阅读全文 &raquo;</a>
</div>
</p>
</div>

Well, it is also parsed with getElementsByClass:

List<Element> bodyElementList = new ArrayList<>();
Elements bodyElements = document.getElementsByClass("post-body");
for (Element element : bodyElements) {
	//这里用text()只是拿到文本,但我想要直接返回html标签,很好,jsoup有html()方法。
    LogUtil.d("body=" + element.html());
    bodyElementList.add(element);
}

3. Core code

private void loadMyBlog() {
    Call<ResponseBody> call;
    //分页处理
    if (page == 1) {
        call = apiStores.loadMyBlog();
    } else {
        call = apiStores.loadMyBlog(page);
    }
    call.enqueue(new RetrofitCallback<ResponseBody>() {
        @Override
        public void onSuccess(ResponseBody responseBody) {
            try {
                Document document = Jsoup.parse(new String(responseBody.bytes(), "UTF-8"));
                List<Element> titleElementList = new ArrayList<>();
                Elements titleElements = document.getElementsByClass("post-title-link");
                for (Element element : titleElements) {
                    titleElementList.add(element);
                    //LogUtil.d("text=" + element.text());
                    //LogUtil.d("href=" + element.attr("href"));
                }
                List<Element> timeElementList = new ArrayList<>();
                Elements timeElements = document.getElementsByClass("post-time");
                for (Element element : timeElements) {
                    //LogUtil.d("time=" + element.getElementsByTag("time").text());
                    timeElementList.add(element);
                }
                //Elements categoryElements = document.getElementsByClass("post-category");
                //for (Element element : categoryElements) {
                //    LogUtil.d("category=" + element.getElementsByTag("a").text());
                //}
                List<Element> bodyElementList = new ArrayList<>();
                Elements bodyElements = document.getElementsByClass("post-body");
                for (Element element : bodyElements) {
                    LogUtil.d("body=" + element.html());
                    bodyElementList.add(element);
                }
                if (page == 1) {
                    dataAdapter.clear();
                }
                dataAdapter.addAll(titleElementList, timeElementList, bodyElementList);
                if (titleElementList.size() < 8) {
                    //因为我的博客一页8条数据,当小于8时,说明没有下一页了
                    pullLoadMoreRecyclerView.setHasMore(false);
                } else {
                    pullLoadMoreRecyclerView.setHasMore(true);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        @Override
        public void onFailure(int code, String msg) {
            toastShow(msg);
        }
        @Override
        public void onThrowable(Throwable t) {
            toastShow(t.getMessage());
        }
        @Override
        public void onFinish() {
            pullLoadMoreRecyclerView.setPullLoadMoreCompleted();
        }
    });
    addCalls(call);
}

jsoup parsing source code

Parse my blog source code has been uploaded to my github, see: https://github.com/WuXiaolong/WeWin

Presumably by analyzing them one by one, you will definitely be able to parse HTML with jsoup. If you still can't, send me a big red envelope in private, and I will teach you hands-on, send a huge red envelope, I will be yours tonight, hehe.

off topic

Maybe you are worried that jsoup parses html, so the crawler is not infringing? Yes, I am also worried, so my app is only "promoted" in my group.

bmob

If you are careful, you must have discovered that jsoup can only crawl data for display functions, so there is no comment function in my WeChat! How is this done? When I first started making apps, personal apps could not do the POST function, but bmob appeared to solve the pain point of individual developers without a server. It is equivalent to a database and provides sdk. You can add, delete, modify, and search operations. We only need to focus on the client, and the backend doesn't matter. In this case, we still have a little bit of database knowledge so that we can make better use of bmob. In addition to bmob, there are also leancloud, apicloud, etc. that have similar services. I am very grateful to them for solving our rigid needs in a timely manner, and personal apps can still have a chance.

Regarding how to use bmob, leancloud, and apicloud, I know that you are already reading their official documents.

no art

Art Cut

In actual development, some effects can be easily achieved only by the artist making a picture. Without the cooperation of the artist, it seems that the development of the app is difficult to progress, right? In fact, I mentioned a sentence in the article " Android Design Support Library Use ": "At present, this sample has all the effects of Material design style, which is quite an empty shell. You only need to plug in real data in actual development to become a perfect app. "Yes, it's OK to use Google's Material design style. It provides a set of specifications and images, which are enough for our personal apps, and now there are vectors, which are extremely powerful. For example, the refresh button in the upper right corner of Weiyan-daily recommendation, as shown in the figure: the corresponding xml:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto">
    <item
        android:id="@+id/action_refresh"
        android:icon="@drawable/ic_loop_24dp"
        android:title="刷新"
        app:showAsAction="always" />
</menu>

Usually ic_loop_24dp is definitely a picture, but the vector I use, the code is as follows:

<vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:width="24dp"
        android:height="24dp"
        android:viewportWidth="24.0"
        android:viewportHeight="24.0">
    <path
        android:fillColor="?attr/colorControlNormal"
        android:pathData="M12,4L12,1L8,5l4,4L12,6c3.31,0 6,2.69 6,6 0,1.01 -0.25,1.97 -0.7,2.8l1.46,1.46C19.54,15.03 20,13.57 20,12c0,-4.42 -3.58,-8 -8,-8zM12,18c-3.31,0 -6,-2.69 -6,-6 0,-1.01 0.25,-1.97 0.7,-2.8L5.24,7.74C4.46,8.97 4,10.43 4,12c0,4.42 3.58,8 8,8v3l4,-4 -4,-4v3z"/>
</vector>

Isn't it amazing, how to create a vector: here is a random demonstration, a vector is created, for vector learning, you can refer to the doctor's article " The Tortuous Road to Compatibility with Android Vector ", which is written in great detail, so I won't say much here.

app icon

Of course, the app hopes to have a beautiful and meaningful icon, and it will use Photoshop. Of course I can't, it must be learned. Generally, the Android market requires icon sizes of 16 16 , 48 48, 512 512 , rounded corners, and Android development requires 48 48 , 72 72 , 96 96, 144 144 , 196 196, so when PS, you only need to make a maximum size of 512*512 , and then zoom out. PS steps for the icon: 1. Open the picture you want to modify with photoshop 2. Select the "Rounded Rectangle Tool" in the left toolbar (the default is the "Rectangle Tool", you just need to right-click the icon to find the "Rounded Rectangle Tool" "Corner Rectangle Tool"), as shown in Figure 3 above, enter the radius of the corner you want in the "Radius" box above. Generally, you can choose 25 for the picture. For obvious effect, I set it to 40, and there is a box showing the radius of 40 in the picture above. . 4. Draw a rounded rectangle on the opened picture to cover the picture. 5. Right-click on the image selection area that has been covered, and select "Create Selection". If a window pops up, click "OK" directly, and click "OK" in the pop-up options. 6. In the "Select" tab above Click, find "Reverse" in the drop-down box, or use the shortcut key ctrl+shilf+i. 7. Double-click the "Background" picture in the layer bar at the bottom right (you can see it in the lower right corner of the first picture above), if a window pops up, click "OK" to complete the unlocking. 8. Press the "DELETE" key on the keyboard to clear the four right angles. 9. Continue to right-click on "Shape 1" (which can be found in the layer at the bottom right of the screen), select "Delete Layer" in the pop-up options, and click "Yes" if a window pops up. 10. OK, you can see a picture with rounded corners. 11. Finally, click File--"Save as--" in the upper left corner to select the png format (other formats are also possible), and complete. Why is the icon of Weiyan a word "Yan", because I think it is so concise and generous, simple and clear, concise and comprehensive... Forget it, don't pretend, I don't know how to P!

Promotion skills

Don't you feel a sense of accomplishment after finishing a personal app? It's launched on the Android market, but there are not many downloads. Nima, it took a long time for labor and management. How come no one downloads such an awesome app? ! My mood hit rock bottom all of a sudden, so I have to let more people know about my app. Here's what I did:

1. Invite praise when you download an app, you may look at the reviews of the app. If there are a lot of praise, would you be more willing to download it? Yes, look at my WeChat comments: Hahaha , isn't it awesome, I have written a tool class to invite comments, please accept it with a smile:

public class InviteCommentUtil {
    private String mDateFormat = "yyyy-MM-dd";
    private String mInviteCommentTime;

    /**
     * 选择哪天弹邀请评论框
     */
    public void startComment(final Activity activity) {
        mInviteCommentTime = PreferenceUtils.getPreferenceString(activity, "inviteCommentTime", TimeUtil.getCurrentTime(mDateFormat));
        String saveCommentTime = PreferenceUtils.getPreferenceString(activity, "saveCommentTime", TimeUtil.getCurrentTime(mDateFormat));
          int compareDateValue = TimeUtil.compareDate(mInviteCommentTime, saveCommentTime, mDateFormat);
        if (compareDateValue == 1) {
            AlertDialog.Builder builder = new AlertDialog.Builder(
                    activity);
            int nowReadingTotal = ReadUtil.getReadedTotal();
            builder.setMessage(Html.fromHtml("您已经累计阅读<font color=#FF0000>" + nowReadingTotal + "</font>字,再接再厉哦!如果喜欢我,希望您能在应用市场给予<font color=#FF0000>五星</font>好评!"));
            builder.setTitle("求好评");
            builder.setPositiveButton("好评鼓励",
                    new android.content.DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            setComment(activity);
                            try {
                                Intent intent = new Intent(
                                        "android.intent.action.VIEW");
                                intent.setData(Uri
                                        .parse("market://details?id=com.android.xiaomolongstudio.weiyan"));
                                activity.startActivity(intent);
                                activity.overridePendingTransition(
                                        R.anim.enter_right_to_left, R.anim.exit);
                            } catch (Exception e) {
                                e.printStackTrace();
                            }

                            dialog.dismiss();
                        }
                    });
            builder.setNegativeButton("下次再说",
                    new android.content.DialogInterface.OnClickListener() {

                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            setComment(activity);
                            dialog.dismiss();
                        }
                    });
            builder.create().show();
        }
    }

    /**
     * 保存,直到下周再提示
     */
    private void setComment(Activity activity) {
        PreferenceUtils.setPreferenceString(activity, "saveCommentTime", mInviteCommentTime);
    }
}

Note: The time for inviting comments here is well controlled and not too frequent, otherwise users will be disgusted.

2. Focus on a market, I don’t know if you have found it, you can find your app in a market that you have not released, yes, some markets will catch your app, such as Wandoujia, Baidu, so the strategy is to focus on A market, this market is famous, are you afraid that other markets will not know? Of course, we are striving for each market to be released online, and one more download is one. Weiyan is in the front row under the category and has entered the boutique series many times

How to enter the front row or boutique, inviting praise is a key step.

3. New product recommendation New products are launched. Many markets have new product recommendations, such as Xiaomi, Meizhi, 360, and App Store. Generally, self-recommendation is required. Once recommended, the download volume is considerable, and Weiyan must have been recommended. Oh, and the updated version is also new.

4. Weibo This is what my good buddy taught me. He is really good, and his personal app is even better. Let me show you a link: http://weibo.com/p/1008082a702d2cb6146485e5dc3d624d31def6 , you will know how to use it on Weibo. It is promoted on the blog. Yes, it is a topic. Circle it with two # numbers and post it on Weibo. It is a topic. Others can discuss it under this topic, forming a promotion effect invisibly.

5. App sharing The app sharing function must be done. If the user thinks your app is great and wants to recommend it to a friend, but the sharing function is not available, why not stop the food? When sharing Weibo, you can add two # signs to circle it. Oh.

6. If you send the download link of the app directly in the QQ group, there will only be one result: T. Like our programmers, most of them are technical groups. My approach is to write articles to share the technology used in my app. The article will attach the app download address, and then people who are interested in this technology may ask, so that I can justifiably "promote" "Well, haha, I'm so bad!

The above is only what I know, and it may not be effective. After all, I am not a professional promoter.

how to make money

Everything is ready, and you only owe Dongfeng. When your user base is large enough, someone will come to you and invest in your app. In the early stage of this process, there is zero income, and the energy and time spent are not counted. You may have to burn money, which is not suitable for individuals. Developer, what I choose is to make a little money and add advertisements to the app. I chose a third-party advertising platform. I used Duomeng at the earliest, but I found that I had no income at all. I felt that Duomeng’s deduction was very serious. Points, I found that some markets do not allow points-based apps to be launched, and they gave up. There are also Baidu Mobile Advertising Alliance, Tencent’s Guangdiantong, and Google’s. The most stable revenue belongs to Baidu’s, which is not against it. As for advertising integration, it also provides sdk, go to their official website to find out.

Recommended reading

A complete set of Android common framework Android Design Support Library using AndroidMVPSample

Contact the author

My WeChat public account: Wu Xiaolong, welcome to pay attention to the exchange~

finally

I am very satisfied with several of my apps, and the functions are so perfect that I felt that there was nothing to update later, plus the advertising revenue was good for a period of time, and mobile advertisers sprang up, resulting in a high advertising unit price. Low, and the Android market has various restrictions on individual developers, such as not allowing video apps to be launched; a certain degree, a certain 60 must use its own reinforcement to launch the app, etc., there is no motivation to continue to maintain the app, and you still have to be motivated to do things. , otherwise what are you doing alive? However, I know that some people are still insisting on making personal apps. If they do well, they can earn hundreds or even thousands of them every day. The ultimate purpose of an app is to make money.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325431436&siteId=291194637