Hello to everybody, I'm new to the group and of course I need your help :-)

I'm developing an application for ICS levelApi 15. I have a single Activity
and some Fragment.
The problem is about the Menu attached to the ListView item and in
particular to the "Share" action.

This is my code:

public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenu.ContextMenuInfo menuInfo) {
        super.onCreateContextMenu(menu, v, menuInfo);

        MenuInflater mInflater = new
MenuInflater(getActivity().getApplicationContext());
        mInflater.inflate(R.menu.tweet_item_menu, menu);

        final AdapterView.AdapterContextMenuInfo adapterMenuInfo =
(AdapterView.AdapterContextMenuInfo) menuInfo;
        final Status status = (Status)
getListView().getAdapter().getItem(adapterMenuInfo.position);

        ...

        ShareActionProvider shareActionProvider = (ShareActionProvider)
menu.findItem(R.id.ic_action_item_share).getActionProvider();

shareActionProvider.setShareHistoryFileName("tweet_item_share_history.xml");
        shareActionProvider.setShareIntent(createShareIntent(status));

        ...
}

private Intent createShareIntent(Status status) {
        Intent sharingIntent = new Intent(Intent.ACTION_SEND);
        sharingIntent.setType("text/html");
        sharingIntent.putExtra(Intent.EXTRA_SUBJECT, "Sharing via
TwinyWorld");
        sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT,
status.getText());
        return sharingIntent;
}

Executing the app I see that after clicking on the item, the menu appears
and the code above is executed with no exception, but suddenly after
clicking on the service I want to share with (for example Gmail) the app is
terminated but I can't see any error on Android LogCat.
After I attached the sources to the android-4.0.3.jar I started to debug
the app and in I put a breakpoint on the "onMenuItemClick" method: after I
stop there I see that the code is executed until the line
mContext.startActivity(launchIntent) and after this the app crashes.
Evaluating all the expressions in this snippet I can't find anything
strange.
The menuItem is correct, the launchIntent is the GmailComposer (or
something like this) but something goes bad... with no apparent error.
At this point I'm stuck !

    private class ShareMenuItemOnMenuItemClickListener implements
OnMenuItemClickListener {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            ActivityChooserModel dataModel =
ActivityChooserModel.get(mContext,
                    mShareHistoryFileName);
            final int itemId = item.getItemId();
            Intent launchIntent = dataModel.chooseActivity(itemId);
            if (launchIntent != null) {
                mContext.startActivity(launchIntent);
            }
            return true;
        }
    }

Even if I want to use this way, I tried also another one: for example if I
set a listener to the item and start the share intent through
Intent.createChooser everything goes fine, the chooser is shown and the
intent is launched. For this example I used:

startActivity(Intent.createChooser(Intent.ACTION_SEND, "Share"))

But both the solutions do not show me "social apps" that I have installed
on the phone, only Gmail, Email and some other app is shown.
What can I do for this ?

Thanks in advance,
Alex.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to