Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8880083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:05:49+00:00 2026-06-14T20:05:49+00:00

I am trying to implement this : Share Facebook In my application, I have

  • 0

I am trying to implement this : Share Facebook

In my application, I have a button, I want when user clicks on my button the AlertDialog appear but I figure it out that the adapter is not set to AlerDialog.

I use this code :

 shareb = (ImageView) findViewById(R.id.shareb);
 shareb.setOnClickListener(new View.OnClickListener() {

     public void onClick(View v) {

         sendIntent = new Intent();
         sendIntent.setAction(Intent.ACTION_SEND);
         activities = mContext.getPackageManager().queryIntentActivities(sendIntent, 0);
         builder = new AlertDialog.Builder(mContext);
         builder.setTitle("Share with...");
         final ShareIntentListAdapter adapter = new ShareIntentListAdapter((Activity) mContext, R.layout.basiclistview, activities.toArray());
         builder.setAdapter(adapter, new DialogInterface.OnClickListener() {

             public void onClick(DialogInterface dialog, int which) {
                 // TODO Auto-generated method stub
                 ResolveInfo info = (ResolveInfo) adapter.getItem(which);
                 if (info.activityInfo.packageName.contains("facebook")) {
                     postFacebookMessage();
                 } else {
                     Intent intent = new Intent(android.content.Intent.ACTION_SEND);
                     intent.setClassName(info.activityInfo.packageName, info.activityInfo.name);
                     intent.setType("*/*");
                     intent.putExtra(Intent.EXTRA_SUBJECT, "I just read " + knowTitle);
                     intent.putExtra(Intent.EXTRA_TEXT, knowTitle + "Read the full article via MomsApp by EnfaMama A+ at http://meadjohnsonasia.com.my/mobileapp");
                     ((Activity) mContext).startActivity(intent);
                 }

             }

         });

         builder.create().show();
     }
 });

and then i use this As Adapter :

public class ShareIntentListAdapter extends ArrayAdapter < Object > {
    Activity context;
    private final Object[] items;

    int layoutId;


    public ShareIntentListAdapter(Activity context, int layoutId, Object[] items) {
        super(context, layoutId, items);

        this.context = context;
        this.items = items;
        this.layoutId = layoutId;


    }

    public View getView(int pos, View convertView, ViewGroup parent) {
        LayoutInflater inflater = context.getLayoutInflater();
        View row = inflater.inflate(layoutId, null);
        TextView label = (TextView) row.findViewById(R.id.text1);
        label.setText(((ResolveInfo) items[pos]).activityInfo.applicationInfo.loadLabel(context.getPackageManager()).toString());
        ImageView image = (ImageView) row.findViewById(R.id.logo);
        image.setImageDrawable(((ResolveInfo) items[pos]).activityInfo.applicationInfo.loadIcon(context.getPackageManager()));
        System.out.println(layoutId);
        return (row);

    }


}

I found that getView function is not running! Because I set System.out.println(), and it didn’t print.

When I run this code, share with… it appears without any content!

How can I fix this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T20:05:50+00:00Added an answer on June 14, 2026 at 8:05 pm

    instantiate your sendIntend like below ,

    sendIntent = new Intent(Intent.ACTION_SEND, null);
    sendIntent.addCategory(Intent.CATEGORY_DEFAULT);
    sendIntent.setType("text/plain");
    

    then your list will be filled.

    i mean,

    public class MainActivity extends Activity {
    
        ImageView shareb;
        Intent sendIntent;
        AlertDialog.Builder builder;
        List<ResolveInfo> activities;
        Context mContext;
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            mContext= getApplicationContext();
    
            shareb = (ImageView) findViewById(R.id.imageView1);
            shareb.setOnClickListener(new View.OnClickListener() {
    
                public void onClick(View v) {               
                    sendIntent = new Intent(Intent.ACTION_SEND, null);
                    sendIntent.addCategory(Intent.CATEGORY_DEFAULT);
                    sendIntent.setType("text/plain");
    
                    activities =  mContext.getPackageManager().queryIntentActivities(sendIntent, 0);
    
                    builder = new AlertDialog.Builder(MainActivity.this);
                    builder.setTitle("Share with...");
                    final ShareIntentListAdapter adapter = new ShareIntentListAdapter(MainActivity.this, R.layout.basiclistview, activities.toArray());                
                    builder.setAdapter(adapter, new DialogInterface.OnClickListener() {
    
                        public void onClick(DialogInterface dialog, int which) {
                            // TODO Auto-generated method stub
                            ResolveInfo info = (ResolveInfo) adapter.getItem(which);
                            if (info.activityInfo.packageName.contains("facebook")) {
                                //postFacebookMessage();
                            } else {
                                Intent intent = new Intent(android.content.Intent.ACTION_SEND);
                                intent.setClassName(info.activityInfo.packageName, info.activityInfo.name);
                                intent.setType("*/*");
                                intent.putExtra(Intent.EXTRA_SUBJECT, "I just read ");
                                intent.putExtra(Intent.EXTRA_TEXT, "Read the full article via MomsApp by EnfaMama A+ at http://meadjohnsonasia.com.my/mobileapp");
                                ((Activity) mContext).startActivity(intent);
                            }
    
                        }
    
                    });
    
                    builder.create().show();
                }
            });
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to implement the shake tutorial on this page, but I think I'm
I'm trying to implement this pattern in my WinForms application (I don't like it,
I am trying to implement this demo on my local machine. http://bit.ly/4g4o1r I have
I'm trying to implement this scenario using Unity and i can't figure out how
I'm trying to implement the native facebook share for iOS 6 and need check
I am trying to make an application which integrates facebook and twitter. I have
Trying to implement the example from here. Facebook Share passes along the URL of
I am trying to implement multiple Facebook share buttons in one page to share
I am trying to implement share this method. I am using the code as
I'm trying to implement this algorithm description from a previous question I had here

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.