Touch
Event or phone guard face question finishing Answer (ii) custom control 1.
Touch
The delivery mechanism of events
Top View
View
View
-to-parent child, not handling reverse return
OnInterceptTouchEvent()
, the return value control Touch
is passed down. true
Interrupts the event, false
without interrupting the event.
onTouchEvent()
The return value determines whether the event is handled. True
consumes events and False
does not handle event-up passes.
2. How to implement the Carousel animation
ViewPage
And TextView
combine the effects of pictures and titles
ViewPage
Set setOnPageChangeListener
Listen for transformed images and corresponding text content.
Handler
Send handler.sendEmptyMessageDelayed(0, 200)
Delay message, the realization of automatic transformation of the picture.
ViewPage
set setOnTouchListener
, empty handler
Message
message queue, stop picture carousel
3. customizing
ViewPage
Principle of combined control implementation
Inheritance ViewGroup
The container class MyViewPage
dynamically adds controls to the container. can also be a layout combination control and so on
rewrite onMeasure()
To set the width height of the control, the child controls must be set manually
getChildAt(i).measure(widthMeasureSpec,heightMeasureSpec);
rewrite onLoayout()
sets the position of the control's drawing. Here, animate the child controls 一
to draw in a word shape,
getChildAt(i).layout(getWidth() * i, 0, getWidth() * (i + 1), getHeight());
definition GestureDetector
Set gesture Swipe callback listener
rewrite onTouchEvent(MotionEvent)
Delegate GestureDetector
Gesture recognizer to handle callbacks for sliding touch events onScroll(...)
. Sets View
scrollBy()
the distance in the horizontal direction of the slide. scrollTo(...)
set the specific position to slide to
define Scroller
and control the sliding slide effect.
rewritten computeScroll()
. View
constantly callback the method when sliding, control the Update Page
page page
definition OnPageChangeListener
interface, set page change callback listener onPageChange(...)
.
The realization idea of organizing mobile phone guard function point 1. Mobile phone anti-theft function setting principle
SharedPreferences
Save the settings password. Whether the Guride
page settings have been directed. SIM
Card string number.
ViewPage
+ Fragement
Implement sliding replacement page logic, getSystemService(Context.TELEPHONY_SERVICE);
get to System phone hair
Get to phone SIM card serial number, bind mobile phone number. Registration 广播
. Calling card changes send SMS to a designated security contact.
Sign up for SMS broadcasts. intent.getExtras().get("pdus");
get messages that are constantly being sent over. Interception of SMS content to implement the corresponding instruction function operation.
2. Phone Intercept function
ListView
Customize mData
The Adapter
changes you can make
AlartDialog
Add blacklist, set blocking mode
AsyncTask
Asynchronously loads the query blacklist. Page Search blacklist
Get to the phone number, hang up the phone, and destroy the call log by opening a service.
3. Software Steward
viewutils annotation events, annotation control issues,
By context.getPackageManager()
getting PackageManage
all the software managers installed on your phone. And customize the Adapter``ListViwe
display software list.
ListView
Set the setOnItemClickListener
listener popup PopupWindow
setting accordingly Intent
to implement the operation of the list item software
4. Process Management.
Gets the process information to which the system service has been run
// 通过AcitvityManager 取得想应的进程信息;
ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
// 获取到包管理器
PackageManager pm = context.getPackageManager();
// 获取系统运行的程序信息
List<RunningAppProcessInfo> runningAppProcesses = am.getRunningAppProcesses();
AsyncTask
Asynchronously loading, ListView
showing the list of processes. and distinguish between a system process or user process.
by ActivityManager
killBackgroundProcesses(...)
killing the user process.
To prevent the Service
background thread from being killed. Dynamically register registerReceiver
a broadcast, restart Kill Service
.
Touch event or phone guard face question finishing Answer (b)