This article describes the implementation of Android programming to monitor battery status. Share to everyone for your reference, specific as follows:
Recently in the development of a GPS-related project, because it involves the use of GPs, it is well known that GPS is quite power consumption, so think how to know the current electricity, and when the electricity reaches a lower limit, timely reminder to t
The android:configchanges= "Orientation|keyboardhidden" attribute is first added to the activity element of the Mainifest.xmlAdding this property means that the application will handle changes in screen orientation and keyboard state (rolled or closed) information. However, changes to other device configuration information are handled by the Android system (destroying the current
This article describes the Android programming approach to not destroy the current activity and lock the screen when the switch is in the horizontal screen. Share to everyone for your reference, specific as follows:
First, add the android:configchanges= "Orientation|keyboardhidden" attribute to the Mainifest.xml activity element
The implication of
First put the Activity_main.xml file code out. TextView Full Screen?
12345678910111213141516171819202122232425
LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"android:layout_height="match_parent"android:paddingBottom="@dimen/activity_vertical_margin"android:paddingLeft="@dimen/activity_horizontal_margin"android:paddingRight="@dimen
The preferencescreen in the setting can be displayed on the setting interface and the activity can be started. The following describes how to start the activity.1. Start activity in preferencescreen
For example, wireless_setting.xml contains the following fragments:
Com. Android. settings is the package name o
the logic can quickly find the answer, we all know that the production of an event must be user interaction, that is, It is only when the user touches the screen or presses a button that the system can respond to an event, and each of these actions can be used as the "source" of the event, so who should capture the most primitive interactive information? Will it be view? Will it be activity? Will it be viewrootimpl and WMS? The components in these fr
of the principles of design, one of the characteristics of anonymous internal class is to have high cohesion.
But there are also deficiencies:
1 when the same method is needed elsewhere, write an anonymous inner class again in that place, making the code highly redundant.
2) inconvenient Late maintenance
A, add a button
B, back to the mainactivity implementation
public class Mainactivity extends activity{
private Butto
Background:In many app development processes need to listen to the Android device in the activity of the soft keyboard bounce and close, but Android does not seem to provide the relevant listening API to call us, this article provides a practical way to listen to the soft keyboard bounce and close.Pre-Knowledge:The Android:windowsoftinputmode property of the
This example describes how Android listens to the home key. Share to everyone for your reference, specific as follows:
Will go to Android in the home button listening, many people first reaction to rewrite the corresponding activity of the onkeydown () method, monitoring when the key pressed KeyCode for Keycode_home, carry out their own corresponding processing.
) access_coarse_location or access_fine_location.
public int getdataactivity () returns the status of the current data connection activity.
public int getdatastate () returns the condition of the current data connection state.
Public String Getdeviceid ()
Returns the device ID of the cell phone. For example, for GSM mobile phone is IMEI code, for CDMA mobile phone Meid code or ESN code. If the read fails, NULL is returned.
How to
When developing an Android program, sometimes you need to monitor your finger to slide the screen, and when your finger slides up and down in different directions to make a different response, how do you achieve that?Using the gesture monitor provided by Android can be easily implemented, directly on the code (tested p
Test function points
Click on the main interface MainActivity button Button to jump to another interfaceOtherActivity
Test method
Use Instrumentation , perform a Click button action, determine whether the activity of the interface after the jump is expected activity
Use ActivityMonitor , this class is used to monitor a single
Android Back Home key monitorBack key monitoringThe back key is easier to listen to, and can be intercepted in multiple systems, such as the following events in the activity: @Override public void onbackpressed () {//super.onbackpressed ();//comment out this line, the back key does not exit activity LOG.I (log_t AG, "onbackpressed"); } @Override public bool
());} Cursor.close (); Super.onchange (Selfchange);}}2.3 Register ListenerGetcontentresolver (). Registercontentobserver (Uri.parse ("Content://sms"), True, new Smsobserver (New Handler ()));3. Set permissions to receive some action, you need to add the appropriate permissions to the Androidmanifest.xml.4. References[1] broadcastreceiver Introduction http://www.cnblogs.com/alwaysyouare/archive/2011/11/17/2252397.html[2] Android phone, SMS
system comes with the format, directly take to call it). A third parameter is ListView the content. Second, monitor the ListView object:There are three commonly used to monitor a ListView object:1.OnItemClickListener: Listener triggers when clicking on a child of this item2.OnTouchListener: Listener triggers when touching the ListView3.OnScrollListener: Listener triggers when the ListView Scrolls(1), On
The first is usually defined directly in the OnCreate event of the activity component and is directly acting. This approach is defined once for each control and is usually inconvenient.Button btn = (button) Findviewbyid (R.id.mybutton);Btn. Setonclicklistener (New View.onclicklistener () {public void OnClick (View v) {Do something}});The second is usually to implement its interface in the activity component
Two, listen to whether the current test item is a accelerometer measurement test itemIn the first way, we can get the currently active activity similar to listening to the CTS test current test item. But because it is listening to all the activity in the Android system, it greatly reduces the performance of the system, so there is a more efficient way to pinpoint
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.