Rob Red envelopes, first look at the effect chart ~
To achieve automatic red envelopes, solve the problem has two points:
One: How to monitor the occurrence of red envelopes in real time
Second: How to automatically enter the page when the red envelope arrives and automatically click on the red envelope
How to obtain the event of the arrival of red envelopes
In order to get the red envelope arrival status bar changes, we need to use a class: accessibility
Many
Android provides a class named Wakelock in Android.os.PowerManager.WakeLock, from the name of Wakelock is the meaning of wake-up lock, it can control the screen backlight switch, so in the power management class.
The Wakelock instantiation method is simpler because it is the remote service of the system, constructed by the following code
Copy Code code as follows:
PowerManager pm = (
Android development skills-similar to the new version of QQ screen lock pop-up window, android development skills
The new version of qq can display qq messages in the pop-up window under the screen lock. This function is also required for projects currently in progress. After a variety of experiments and data searches, the process is finally achieved, but there are some points to note.
The following is the
Android Android-build an android development environment, android-android
Android official website address: http://developer.android.com/, download and install AndroidSDK following the steps below:
Download ADT and SDK: http://dev
listing the configured network and currently active WiFi network.
Android. OpenGL: contains a utility class for operations on OpenGL ES. The main OpenGL ES class is implemented in a set of different packages from JSR 239. These packages are javax. microedition. khronos. opengles, javax. microedition. khronos. EGL, and javax. microedition. khronos. NiO. These packages are based on the khronos Implementation of OpenGL ES and are written in C and C ++.
setWakMode () signature:SetWakeMode (Context context, int mode)
The first parameter is the current context, and the second parameter is the state to be locked. It is set to a constant of the int type and is defined in the final class PowerManager. PowerManager is designed to manage the locking status of Android power consumption. It is related to locking the CUP
screen status broadcast receiver */private void startScreenBroadcastReceiver () {IntentFilter filter = new IntentFilter (); filter. addAction (Intent. ACTION_SCREEN_ON); filter. addAction (Intent. ACTION_SCREEN_OFF); filter. addAction (Intent. ACTION_USER_PRESENT); mContext. registerReceiver (mScreenReceiver, filter );}
Because the user can set whether the screen is locked after it is disabled, we cannot track the unlock event to determine its status. A function that can obtain the status from
Start searching from the Internet and use the action method, but it has never been successful.Intent intent = new Intent ();Intent. setAction (Intent. ACTION_SHUTDOWN );SendBroadcast (intent );Add Permissions
If a successful employee wishes to send a message, thank you.
Here I will introduce my methods.
1. The power service enables shutdown.Framework/base/services/java/com/android/server/power/PowerManagerService. java/*** Shuts down the device.** @ P
system will not enter sleep phenomenonRefer to the following method to have the dialog box appear above the lock screenThe OnCreate method is usedRequestwindowfeature (Window.feature_no_title); Hide TitleWindow win = GetWindow ();Windowmanager.layoutparams winparams = Win.getattributes ();Winparams.flags |= (WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD| WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED| WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON| WindowManager.LayoutParams.FL
There are a total of two types of methods:First, the code directly determineIi. Reception of broadcastsNow let's start with the first class of methods (the code directly determines):1, through the PowerManager Isscreenon method, the code is as follows:PowerManager pm = (powermanager) context.getsystemservice (Context.power_service); Boolean isscreenon = Pm.isScreenOn () ;//If true, the screen is "lit", othe
Android SDK Android NDK android Studio officialIf the download speed is too slow, please use thunder, Baidu cloud offline and other methods to download.For Linux systems, if you cannot upgrade online, see belowsudo vi/etc/hostsAdd to74.125.206.93 dl-ssl.google.comHere are the various.
2014.7ADT BundleHttp://dl.google.com/
release the lock at the right time, otherwise it will be very power-hungry.In Figure 1 I used a check box (Qcheckbox) to control whether the screen is always lit, the corresponding slot is onscreenonchecked, the code is as follows:void widget::onscreenonchecked (bool checked) {Qandroidjnienvironment env; Qandroidjniobject activity = androidactivity (); if (m_lastchecked) {if (M_wakelock.isvalid ()) {m_wakelock.callmethodOne thing to note here is that WakeLock is the inner class of
mobile phone has a large number of social apps installed. Even if your mobile phone is in the standby status, these apps will often wake up to check and synchronize new data information.
Android will keep disabling hardware to prolong the phone's standby time. First, the screen will gradually become dark until it is disabled, and then the CPU enters sleep. All these operations are aimed at saving valuable power resources. But even in this sleep state
This example describes the uses-permission of the Android permissions operation. Share to everyone for your reference, specific as follows:
When we install the Android software, the system prompts the software for the permissions it needs, and Android has a lot of permissions relative to other systems. We are in the development of software, also need to declare
(Switch) Android system comes with Activity style (@ android: style/), android @ android
Configure in the activity of the AndroidManifest. xml file
1. android: theme = "@ android: style/Theme"
The default status is theme.
2.
" /> "Android.permission.DEVICE_POWER" /> 2. All locks must be used in pairs , and if the application is not released in a timely manner will cause a system failure . If you apply for partial wakelock and do not release it in time , the system will never get into sleep mode . Note: For more information on PowerManager, please refer to "PowerManager"Android F
First, understand the Android operating system
Android was first founded by Andy Robin (Andy Rubin) and was acquired by Google in 2007, and Google has achieved great success with its Android operating system on smartphones.
1, the characteristics of the Android operating system
The
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.