The 5th Chapter understands Remoteviews

Source: Internet
Author: User

Used in the notification bar and desktop widgets. Cross-process display interface.The method of real Operation view in Remoteviews apply and reapply, the former will load the layout and update the interface, the latter only update the interface.
Notification Bar: If you use a custom notification, you need to use Remoteviews to load the layout file to change the notification style. RemoteView Update View: Because the remote process summary display cannot be Findviewbyid directly, a series of set methods are used to accomplish this.
 
   
  
  1. remoteViews.setTextViewText(R.id.msg,"chapter_5");
To add a click event to the control inside, use pendingintent and implement it by using the Setonclickpendingintent method.
Desktop Widgets: Class Appwidgetprovider for implementing desktop widgets, inherited from Broadcastreceiver. Configuration steps: Define the interface of Widgets Res/layout/widget.xml; res/xml new XML definition configuration information, Initiallayout is the initialization layout used by the gadget;                   The implementation class of the part, need to inherit the Appwidgetprovider, and the important method of replication, in the Manifest.xml declaration widget, essentially a broadcast component; Important callback: Onenable, the window is added to the desktop for the first time;                   OnUpdate, when a widget is added or an update is called; ondeleted, each time a part call is removed, ondisabled, the last one that is called when the desktop widget of that type is deleted; OnReceive, according to different action to invoke the above method;
Pendingintent:pendingintent is something that will happen at some point in the future intent,intent is happening immediately. Support: Activate activity, Service, broadcastreciver;
  
 
  1. getAvtivity(Context context,int requestCode,Intent intent,int flags);
  2. getService(Context context,int requestCode,Intent intent,int flags);
  3. getBroadcast(Context context,int requestCode,Intent intent,int flags);
Equivalent to Startactivty,startservice,sendbroadcast. Pendingintent matching rule: Internal intent same and Requestcode same; Intent matching rule: Two intent componentname and Intent-filter same;
Flag:flag_no_create, basically do not use; Flag_one_shot, whichever is the first, the following will be all the same as the first, any one is triggered, the others are cancel;flag_cancel_current, The same pendingintent in front will be cancel, only the latest is available; flag_udpate_current, the previous pendingintent will be updated (extras in their intent will be updated)




From for notes (Wiz)

The 5th Chapter understands Remoteviews

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.