Android adds the app to the market selection list to jump to the sharing list

Source: Internet
Author: User

Today, the boss has a requirement to add our applications to the sharing list. I can't do it on Android. Well, let's not say anything. Find information.

 

First, the following steps should be taken based on multiple experiences.

1. Search for logs. logcat is a good thing that can help you quickly locateProgramNot only can we find bugs, but some prompts can help you find some entry points to solve the problem. For example, the frontend camera of the 2.2 device was called last time.

2. Read the official document to describe this item and do not rush to find online cases. You know, our demands are changing, and online cases do not necessarily meet your needs, so don't try it out.

3. Find the corresponding method or search for specific statements on the Internet through the official description, and I believe it will soon be able to solve the problem.

The following describes how to solve the problem:

1. This is the log I pulled out in logcat. It's amazing.

// 15:53:08 from 07 to 27. 061: INFO/activitymanager (2460): starting activity: intent {act = android. intent. action. chooser CMP = Android/COM. android. internal. app. chooseractivity (has extras )}
// 07-27 15:53:08. 846: INFO/activitymanager (2460): displayed activity Android/COM. Android. Internal. App. chooseractivity: 771 MS (total 771 MS)
// 15:53:21 from 07 to 27. 592: INFO/activitymanager (2460): starting activity: intent {act = android. intent. action. send typ = image/JPEG flg = 0x3000000 CMP = com. sina. weibo /. editactivity (has extras )}

2. Search for this intent (Android. Intent. Action. chooser ).

Activity action: display an activity chooser, allowing the user to pick what they want to before proceeding. this can be used as an alternative to the standard activity picker that is displayed by the system when you try to start an activity with multiple possible matches, with these differences in behavior: you can specify the title that will appear in the activity chooser. the user does not have the option to make one of the matching activities a preferred activity, and all possible activities will always be shown even if one of them is currently marked as the preferred activity. this action shoshould be used when the user will naturally failed CT to select an activity in order to proceed. an example if when not to use it is when the user clicks on a "mailto:" link. they wocould naturally failed CT to go directly to their Mail app, so startactivity () shocould be called directly: it will either launch the current preferred app, or put up a dialog allowing the user to pick an app to use and optionally marking that as preferred. in contrast, if the user is selecting a menu item to send a picture they are viewing to someone else, There are too different things they may want to do at this point: send it through e-mail, upload it to a web service, etc. in this case the chooser action shocould be used, to always present to the user a list of the things they can do, with a nice title given by the caller such as "send this photo :". as a convenience, an intent of this form can be created with the createchooser (intent, charsequence) function.

3. Okay, search now. Keyword: Android sharing

Intent Intent = New Intent (intent. action_send); basically, this statement is available. You can find it several times.

PostCodeRight.

<Activity Android: Name = ". writer_blog "Android: Label =" share to Weibo "> <intent-filter> <action Android: Name =" android. intent. action. send "> </Action> <category Android: Name =" android. intent. category. default "> </Category> <data Android: mimetype = "image/*"> // The type of the message to be sent </data> </intent-filter> </activity>

This is my own Weibo application. Label is the text of the shared list to be popped up. <Action Android: Name = "android. Intent. Action. Send"> This is intent. action_send.

 

Intent it = getintent (); If (it! = NULL & it. getaction ()! = NULL & it. getaction (). equals (intent. action_send) {bundle extras = it. getextras (); If (extras. containskey ("android. intent. extra. stream ") {log. I (TAG, "URI ++ =" + Extras. get ("android. intent. extra. stream "); uri = (URI) extras. get ("android. intent. extra. stream "); set_image (URI); // loads the selected shared image.} // 07-27 17:39:44. 073: INFO/writer_blog (3289): Android. intent. extra. stream = content: // media/external/images/Media/1211}

The code found on the internet can get all manifest files with <action Android: Name = "android. Intent. Action. Send"> apps added

Public list <resolveinfo> getsharetargets () {list <resolveinfo> mapps = new arraylist <resolveinfo> (); intent = new intent (intent. action_send, null); intent. addcategory (intent. category_default); intent. settype ("text/plain"); packagemanager PM = This. getpackagemanager (); mapps = PM. queryintentactivities (intent, packagemanager. component_enabled_state_default); Return mapps ;}

 

There is also a code jump into the market

 

 
Intent intent = new intent (intent. action_view); 2 intent. setdata (URI. parse ("Market: // details? Id = "+ getpackagename (); 3 startactivity (intent );

Code for jump to market search

 
Intent intent = new intent (intent. action_view); 2 intent. setdata (URI. parse ("Market: // search? Q = Pub: Your publisher name "); 3 startactivity (intent );
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.