Alibabacloud.com offers a wide variety of articles about android getapplicationcontext, easily find your android getapplicationcontext information here online.
// Returns the context of the application, the life cycle is the entire application, the application destroys it before it destroys The context of the Activity.this // returns to the current activity, belongs to the activity, the activity destroys him destroys Getbasecontext () // returns the context specified by the constructor or Setbasecontext () settingReference:Http://blog.sina.com.cn/s/blog_5da93c8f0100t77t.htmlAndorid Development (22)--Get Context G
Android development implementation calculator example, android calculator example
Example
The Code is as follows:Android: id = "@ + id/warpcontent"Android: layout_width = "fill_parent"Android: layout_height = "fill_parent"Android: orientation = "vertical">
Toast is a mechanism used by Android to display information. Unlike dialog, Toast has no focus and the display time of toast is limited, after a certain period of time, it will automatically disappear. Next we will use an instance to see how to use toast.
1. Default Effect
Code
Toast. maketext (getapplicationcontext (), "Default toast style ",Toast. length_short). Show ();
2. Custom display
The example in this article describes the solution for using toast in the Android service to display problems correctly. Share to everyone for your reference, specific as follows:
In the service of simple practice, oncreate, OnStart, OnDestroy three methods are called Toast.maketext in the same way as in the activity, and the OnStart and OnDestroy methods of the service are invoked through two buttons in Acitivy:
The Demoservice code is as follows:
callback mechanism.3. Java design mode-callback function and observer ModeCardView1. Introduction and use of the new Android5.0 control CardView2. Android CardView Example3. Android CardView Widget-Add Cards to a List using RecyclerViewConfiguration Change1. Problems Caused by Android Configuration change and Solutions2. Handling Runtime ChangesContext1.
Figure Description: Moving, backup after the launch of Android virtual machine appears
Solution to the problem of panic:could not open D:\java2\android\android-sdk-windows\.android\avd\test.ini
A few days ago, I am sorting some files, the previously installed on the Android
)
2. Data Storage instance of files in Android (save data to the SD card of the mobile phone)
To save data to the SD card, you must first set the relevant permissions in the list file,
For example:
Then we need to add a method for FileService. java in the above instance,
Used to save files to mobile sdcard
Public void saveToSDCard (String filename, String filecontent) throws Exception {
File file = new File (Environment. getExternalStorageDirecto
System services provided by Android-Vibrator and android-vibrator
Vibrator, a system service provided by Android)
-- Reprinted with the source: coder-pig
Vibrator introduction and related methods:
Simple demo -- set frequencyDifferent Vibrator
The most widely used app for Vibrator is the so-called mobile phone massager app, which is searched and piled up
. In this case, some readers are not very clear. At the end of the article, an example is provided to illustrate the problem.[Java]Public View inflate (int resource, ViewGroup root, boolean attachToRoot)
Public View inflate (int resource, ViewGroup root, boolean attachToRoot)
The third parameter indicates that if the second parameter is not null, true is placed in the Viewgroup referenced by the second parameter, if it is false, it is not placed in the Viewgroup of the second parameter.
The foll
Android Address Book Management 3 short message acquisition and Sending Short Messages
The first two blogs respectively talked about how to obtain contacts and call records. This topic describes how to get short messages. Short Messages are a difficult point in communication management, because SMS involves two parts: Short Message session and text message details, and the text message data volume is large, you can use AsyncQueryHandler framework to q
This example describes the Android toast notification usage. Share to everyone for your reference, specific as follows:
Toast displays a message to the user on the phone screen, and the information disappears automatically after a period of time.
1. Default usage
Copy Code code as follows:
Toast.maketext (Getapplicationcontext (), "Default Toast style", Toast.length_short). Show ();
The
, and the log will return the result to us.
03-24 14:02:17. 591 28576-28576 /? E/MainActivity: File is/data/user/0/com. tnnowu. android. iobutterknife/files/test.txt 03-24 14:02:17. 591 28576-28576 /? E/MainActivity: Fos is java. io. FileOutputStream @ 6eaf805
FileInputStream (String name)
① Read byte data from a local file
The framework provided by the system is as follows:
public FileInputStream(String name) throws FileNotFoundException { this(n
Android cainiao Study Notes 30 ---- use Baidu map API for Android (I) preparations and display maps in applications, and android Baidu map api
1. Preparations:
Baidu map API is open for free, but you need to apply for API Key:
1) register a Baidu developer account first
2) Enter Baidu open service platform http://developer.baidu.com/
3) enter the LBS cloud
4) C
mVersion; // The application version public static final int PARSE_XML_ERROR = 10; public static final int PARSE_XML_SUCCESS = 11; public static final int SERVER_ERROR = 12; public static final int URL_ERROR = 13; public static final int NETWORK_ERROR = 14; private static final int DOWNLOAD_SUCCESS = 15; private static final int DOWNLOAD_ERROR = 16; protected static final String TAG = "SplashActivity"; pr Ivate static final int COPYDATA_ERROR = 17; private UpdateInfo updateInfo; private Progres
radio button}/*** The onClick method specified by the button control in the layout* @ Param v*/Public void save (View v ){String name = nameText. getText (). toString ();String age = ageText. getText (). toString ();Integer sex = radioGroup. getCheckedRadioButtonId ();Service. save (name, Integer. valueOf (age), sex );Toast. makeText (getApplicationContext (), R. string. success, 1). show ();}}
Package com. wwj. setting;
Import java. util. Map;
Impor
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.