Dark Horse programmer --- mobile guard day4 custom toast, dark horse day4

Source: Internet
Author: User

Dark Horse programmer --- mobile guard day4 custom toast, dark horse day4

Custom toast

First, obtain a window manager.

WindowManager wm = (WindowManager) getSystemService (WINDOW_SERVICE );

Wm isFull ScreenOnly the view is displayed in the window.

Bind a view and window parameter params in the window manager to generate a display of the view content.

Wm. addView (view, params );

Example:

<Span style = "white-space: pre"> </span> view = View. inflate (this, R. layout. address_show, null); TextView textview = (TextView) view. findViewById (R. id. TV _address); // "Translucent", "active orange", "Wei Shi blue", "metallic gray", "apple green" int [] ids = {R. drawable. call_locate_white, R. drawable. call_locate_orange, R. drawable. call_locate_blue, R. drawable. call_locate_gray, R. drawable. call_locate_green}; SharedPreferences sp = getSharedPreferences ("config", MODE_PRIVATE); view. setBackgroundResource (ids [sp. getInt ("which", 0)]); textview. setText (address );
// WindowManager is set for the form parameters. layoutParams params = new WindowManager. layoutParams (); params. height = WindowManager. layoutParams. WRAP_CONTENT; params. width = WindowManager. layoutParams. WRAP_CONTENT; params. flags = WindowManager. layoutParams. FLAG_NOT_FOCUSABLE | WindowManager. layoutParams. FLAG_NOT_TOUCHABLE | WindowManager. layoutParams. FLAG_KEEP_SCREEN_ON; params. format = PixelFormat. TRANSLUCENT; params. type = WindowManager. layoutParams. TYPE_TOAST; wm. <strong> addView </strong> (view, params );


Code registration Handler

<Span style = "white-space: pre"> </span> // use the code to register the broadcast receiver: new outcallemedier (); // intent filter <strong> IntentFilter </strong> filter = new IntentFilter (); // specify the behavior filter to be filtered. <strong> addAction </strong> ("android. intent. action. NEW_OUTGOING_CALL "); // (Register) bind the action to the aggreger <strong> registerReceiver </strong> (aggreger, filter );






Related Article

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.