Android course Summary (1): android Course

Source: Internet
Author: User

Android course Summary (1): android Course

For Android beginners, you may not understand it in some places. If you have any friends, please correct me. Thank you very much.


1. make good use of the api demo, the requirements of beginners can basically be met in it, Eclipse import API Demo project error may be caused by the SDK version is too low, set the target attribute to high, then prject -- clean

2. Fragment belongs to the APP, not the VIEW, which is also reflected in the API Demo, because Fragment is not only used to display the VIEW, but can also process corresponding events in each Fragment.

3. The addToBackStack (args) method in the FragmentTransaction class means that when you press the return key, the system will return all the operations in the current transaction instead of saving the transaction.

4. the life cycle of each component is very important, and the current understanding is not very deep. We will make a special supplement later.

5. getActivity () or getActivity () can be used when a Context parameter is required (). getApplicationContext (). Because both Activity and Application inherit from Context, Activity refers to an Activity form. You can obtain Appliction through Activity.

6. In Fragment, if you want to obtain the Context, you need to override it in onActivityCreated () or the function after the lifecycle. Otherwise, the nullpointer exception will occur because the Activity has not been generated.

7. connectivityManager is used to operate the mobile data network. on the Internet, you can set correct parameters to enable the network and set incorrect parameters to disable the network, this method is not good or overbearing because when you set an incorrect parameter, the user cannot open the network if he wants to open it. Therefore, I personally support reflection, I will refer to my blog post on the Internet.

8. getTypeName () in NetworkInfo returns a lower-case value. If there is a network, and NetworkInfo is null if there is no network, remember to handle it to avoid nullpointer exceptions, to avoid errors when matching network conditions, use equalsIgnoreCase to ignore case sensitivity. Here, the return value in the API document is in upper case and the test result is in lower case. I do not know why

9. String implements the CharSequence interface, so you can directly use String when you need a CharSequence type variable.

10. Operations written in onResume () may be repeatedly called, which involves the lifecycle issue.


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

1. no child DialogFragment can be nested in DialogFragment. Because the Fragment in the v4 compatibility package is not used, the getChildFragmentManager is not available. The setDialogShow () method is invalid in this case, currently, AlertDialog is used. builder to create a dialog box, because the id in DialogFragment is not actually loaded by the system when I call it, so there will be an error of no view found, imagine that if we load the required resources in advance, we can solve the problem and will write a blog post on this aspect.

2. OnClickListener () in AlertDialog. Builder must use

3. BroadcastReceiver is used to process intent-specific operations, while Service is mostly used to process data and interact with users in the background.

4. The package = "" attribute in AndroidManifest specifies the location where the R file is generated, which is also the unique identifier of the program.

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

1. it is better for the broadcast receiver to use static registration. First, some actions can only use static registration, second, code registration is used only when the program is started, so that we can process some things and then close the program at the end of the program or at a specific time in the program lifecycle, one thing to note about static registration is that some friends may ask static registration of this broadcast receiver, which is why I did not come up with it in the process of my own project, it is not always running in the background, and it has been processing things, so I don't want it to do anything. In fact, we can control it by using parameters, such as placing a parameter in SharedPreferences, then, when the broadcast receiver is activated, obtain the parameter value and perform corresponding operations based on the parameter value.

2. The Mode of SharedPreferences was incorrectly understood to be used to control whether to rewrite or not to append data. In fact, it is used to control the permissions of the XML configuration file.

3. SVN version control, mainly developed in the trunk directory; branchs is used for bug adjustment based on released versions; tags is used to save released versions, which are read-only

4. The data directory in the real machine cannot be seen in DDMS, because the real machine does not grant the DDMS permission, you can view it through the adb shell.

5. The flags parameter in PendingIntent specifies the behavior of PendingIntent, for example, enabling only once.

6. AlarmManagerService is a process where the service runs in systmen_server.
7. Exported receiver does not require permission indicates that the specified receiver does not have the permission set, or android: exported = "false" indicates that the receiver cannot be used across processes.

8. AlarmManager uses PendingIntent's requestcode to differentiate different alarms. Based on this, AlarmManager can be used to cancel the specified alarm task.

9. calendar. getInstance (Locale. for example, the first day of a week is Monday, but after I use localization, the number of weeks obtained by get still starts from Sunday, then I found the information and added it.

10. Make sure to optimize the use of ListView (a blog post will be written after the holder optimization)

11. Refresh the page and use the broadcast receiver in the Activity to register the Activity when it is created, and cancel the Activity when it is destroyed. However, this is not implemented, and a blog summary is provided.

12. int month = c. get (Calendar. MONTH) + 1; because the calculated month is a few months different from the first MONTH, then January is 0.

13. focus: AlarmManager. triggerAtTime of the set method if the type is in absolute value mode, the total number of milliseconds of the target time is used instead of the target time minus the number of milliseconds of the current time. Otherwise, intent is directly sent, because the number of milliseconds after the subtraction represents the intention to be sent early, early, and early.

_______________________________________________________________________________________________________________________________

1. In the layout configuration file, when the weight is vertical, the layout_height of each part must be 0dp; when the weight is normal, the layout_width of each part must be 0dp

2. When using the SVN commit project, directories such as bin and gen do not need to be submitted. They are the file directories generated by compilation.

3. private Class Name () {} privatize the constructor to avoid user new

4. You can obtain the tables in sqlite from the SQL _master table to determine whether to recreate the required tables.

5. Use the OnKeyDown () function to process events such as backend by parameters.

6. Fragment in the fragment type parameter of the remove () method of FragmentTransaction can be obtained from the Fragment stack through the tag set during add

7. When you use the current view to findViewById, you can only obtain resources in the current view. You can use getActivity () to find other view resources.



What are the development prospects of Android? If there is no java Foundation, how long does it take to learn? Have anyone ever learned this?

Android accounts for 73% of the Chinese market, Apple accounts for 16%, and others account for 11%. the development prospects of Android are higher than those of other mobile phone operating systems. Furthermore, Apple's IOS is non-open-source, while Android's biggest one is open-source. If you study hard, you only need one month to get started.

In the process of android development and learning, a small problem occurs.

You add a View or a group of views to each Item. You can set the background for them and set the desired background image, set the background in the listview to the background of the entire listview instead of an item. For example, if you add a textView to each item, you only need to set textvie. setBackground.

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.