android - Detecting sharer app when using share action provider -


When using a shared AdWords provider, I know which sharer app is selected, so that I can send different messages Different apps? I am using the following method for the share action provider;

  mShareActionProvider = (ShareActionProvider) menu.findItem (R.id.menu_item_share) .getActionProvider (); MShareActionProvider.setShareIntent (getDefaultShareIntent ());   

More intent,

  public intent getDefaultShareIntent () {string message = Fname + Mobileno + Homeno + Workmail + + Homemail + + + + + + Skype + address + Company + title + website; Intuit shareIntent = new intent (Intent.ACTION_SEND); ShareIntent.putExtra (Intent.EXTRA_TEXT, Message); Return share}    

update:

The simplest solution is:

  @Override Public Boolean onShareTargetSelected (ShareActionProvider source, intended intent) {string shareTarget = intent.getComponent (). GetPackageName (); ...}   

There is no need to copy files or anything.


If you use some files then from Android source or actionbirdroll, copy:

  • ActivityChooserModel.java
  • ActivityChooserView .java
  • ShareActionProvider.java

    Make sure that you refer to these files, not the original ones from your app.

    In ActivityChooserModel.java , modify it:

      if (mActivityChoserModelPolicy! = Null) {ResolveInfo info = getActivity (index); ChoiceIntent.putExtra ("user_selected_activity", (info.activityInfo! = Null)? Info.activityInfo.packageName: info.serviceInfo.packageName); Last Boolean handled = mActivityChoserModelPolicy.onChooseActivity (this, choiceIntent); If (handled) return tap; }   

    and it will store the package name of the selected activity in the intent, then you can read it in your handler:

      @ Override public boolean onShareTargetSelected ( ShareActionProvider source, intent to intent) {string sharetag = intestine .getStringExtra ("user_selected_activity"); ...}   

    and decide how to handle differently depending on the activity selected.

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -