Content implementation Android shared action content implementation

Source: Internet
Author: User

My friendsArticleThis article introduces how to implement content change. The address of the associated article


In android4.0 (API leverl 14), The actionprovider can easily implement a user friend in the actionbar and efficiently share the action. Once an actionprovider is appended to an Alibaba actionprovider single dish, you only need to provide a shared intent, and other tasks are completed by it. Note: actionprovider can only be used in API lever 14 and the current version.

Update the opening voice of a single dish:

In order to use the intent actionprovider, we first define the above content. Android: actionproviderclass belongs to the corresponding menu resource file <itme>.

<Menu xmlns: Android = "http://schemas.android.com/apk/res/android">
<Item Android: Id = "@ + ID/menu_item_share"
Android: showasaction = "ifroom"
Android: Title = "share"
Android: actionproviderclass = "android. widget. Define actionprovider"/>
...
</Menu>

In addition, you need to mention what you want to share with the provider.

Set the sharing intent:

To realize the functions of the shareactionprovider, we must implement a sharing intent. This intent not only includes the content required by other intent to transmit content to other applications, such as action_send and extras, but also needs the above content. When filling your single-course resources in your activity or fragment, you need to find the menuitem and use the menuitem. getactionprovider to get the internal actionprovider instance. You can use setintent provider to update the shared intent.

Private sector actionprovider mpipeline actionprovider;
...

@ Override
Public Boolean oncreateoptionsmenu (menu ){
// Inflate menu resource file.
Getmenuinflater (). Inflate (R. Menu. Choose _menu, menu );

// Locate menuitem with specified actionprovider
Menuitem item = menu. finditem (R. Id. menu_item_share );

// Fetch and store your actionprovider
M1_actionprovider = (your actionprovider) item. getactionprovider ();

// Return true to display menu
Return true;
}

// Call to update the share intent
Private void setincluintent (intent incluintent ){
If (m1_actionprovider! = NULL ){
Mpipeline actionprovider. setpipeline intent (pipeline intent );
}
}

 

 

 

 

I will share this article with you.ProgramJokes and quotations:

IBM and Boeing 777
Boeing 777 is the first aircraft ever designed and manufactured completely in computer virtual reality. The equipment used is completely provided by IBM. Before the test flight, the president of Boeing warmly invited IBM's technical supervisor to participate in the test flight, but the supervisor said, "Ah, I am very honored. Unfortunately, it was my wife's birthday, so .. "..
As soon as Boeing heard it, he got angry: "I haven't told you the test flight date yet !"

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.