"Original Android Game" Ninone V2.3.1--Loading mode learning, interface re-design

Source: Internet
Author: User

After the last update and found some bugs, and is a very obvious bug, one after another corrected.

Guess the function of the digital game has been basically implemented, but I think an application to do a game a little bit less fun, slightly monotonous, so I intend to write an n-in-1 game integration application, an application integration of a variety of games, so that can be played by an application to play what game game, Although may only realize some simple game, but anyway is writes oneself to play well, has the interest to have the motive, hehe.

---------------------------------------------------------------------------------------------------------

This update:

1. Fixed the issue of two icons for application installation 2. Fixed activity loading mode 3. Design of the final main screen of the game
4. Game renaming

---------------------------------------------------------------------------------------------------------

1. Fixed an issue where the application installation generated two icons.

, two app icons appear after installing the application.

Since the two activity in Androidmanifest.xml contains the <action android:name= "Android.intent.action.MAIN"/>, there are two main processes, So there will be two application icons, the rankactivity of this statement deleted, successfully solved the problem.

2. Fixed the activity loading mode

Another bug in the software is that if you constantly switch between two activity, after many times, press mainactivity in the exit is not immediately quit the program, but continue to retreat to mainactivity, and then many times later will quit the program, This is an issue with the activity loading mode.

First of all, let's look at four loading modes for Android activity:

1.stantard: Standard mode.

The default load mode, each time the target activity is launched through this mode, a new instance is created and added to the task stack (the task stack is used to manage the activity).

At first I used the default stantard mode, resulting in each press of the ranking key, will create a rankactivity instance, and put on the top of the task stack, transfer to rankactivity do not destroy mainacitvity, and then press the Back button in the leaderboard , and re-create an instance of Mainactivity, put on top of the stack, rankactivity each time will be destroyed, so many times in the activity between the activity, actually more and more in the stack, and are mainactivity, This explains why you can press exit or mainactivity in mainactivity because it is stacked on a layer-by-level basis.

2.singletop:task Top Single case mode

As with standard mode, the only difference is that when the target activity that is going to start is already at the top of the stack, no more instances of the activity are created, and the activity is taken directly from the top of the stack. That is, "the top elements of the stack can only have one", that is singletop meaning. ‘

3.singletask:task in single-case mode

That is, there can be only one instance within the same task, that is, there is only one task and only one instance within the task.

If the target activity that will be started:

(1) does not exist, then creates an instance and puts it on top of the task stack

(2) already at the top of the task stack, then handle the same singletop

(3) already exists, but not at the top of the stack, then delete the instance above it and let it be the top of the stack.

4.singleInstance: Global Singleton mode

With this mode, the system guarantees that the target activity will be started, regardless of which task it was created from, and a new task will be built to store the instance.

That is, each time the target activity does not exist, create a task, place it at the top of the task stack, and then, if present, put the task in the foreground. There is only one instance of each task in this way.

--------------------------------------------

After three kinds of experiments:

1. Add finish () directly to the mainactivity, and each jump ends itself.

2. Use Singletask mode.

3. Use singleinstance mode.

The first kind of words, can not save the scene, resulting in each guess number halfway to see the line will clear out the situation, that is unable to save the scene. The third, although able to protect the scene, but the jump time interval is too long, does not meet this small application, I do not want this small application in any place delay too much time. So, I decided to use the Singletask mode to process and load two activity and not write the data when I reversed it. In this case, you can continue playing when you jump back.

---------------------------------------------------------------------------------------------------------

3. Design of the final main screen of the game

Looking for a map on the Internet, their P buttons have been used for a long time, although the button design is a bit ugly, but now it is so.

Then is adjust mainactivity, add ImageButton, realize the switch between activity, etc., step by step completed.

First look at the main interface (for light injection):

Then is the login interface, originally wanted to make a dialog box form, but there are some problems, resulting in failed to achieve, the next estimate can be achieved.

Click on the "Guess number game" to go to the main interface to guess the number game, at present, this is the core function of the application.

Click on "About" to get software information, including author, version and so on.

4. Game renaming

The game changed its name to Ninone, taking N-1 meaning.

---------------------------------------------------------------------------------------------------------------

OK, this time the code will not be posted, the next step should be a good study of git use, the code to GitHub to manage a bit, can not be affixed every time one by one.

Originally this time to implement the application of the database, but in view of the application changes, and so on May implement a game of the global database, so the database first shelved.

Next, the first good git, and then should think about the overall architecture design, a guess the number of games to say, is no brain write algorithm, and then put into an activity can, but to achieve a number of games, you should think about how to design the entire composition and logic, as well as the design of the database and so on , not just buried in the code, but also to look up the road, I do not want to write to the end to find the entire logic chaos, like writing a simulation, write write their own are written dizzy, and then Gg.

--------------------------------------------------------------------------------------------------------------- -------------------

Next:

git usage, upload code, and global architecture design.

--------------------------------------------------------------------------------------------------------------- -

APK: Click I download

2014.12.19

"Original Android Game" Ninone V2.3.1--Loading mode learning, interface re-design

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.