-1

I am using intent to get the list of all apps i can post text to. However, linkedin is not appearing in that list. Do i need to do anything extra for linkedin?

        Intent intent = new Intent();
        intent.setAction(Intent.ACTION_SEND);
        intent.setType("text/plain");
        intent.putExtra(Intent.EXTRA_TEXT, "dcsd");
        package= mContext.getPackageManager();
        List<ResolveInfo> appTargets= package.queryIntentActivities(shareIntent, 0);

I am able to get all other apps like Facebook, Twitter except LinkedIn? What could be the possible reason?

div
  • 1,475
  • 3
  • 22
  • 32
  • 1
    Perhaps, linkedin is not installed? Do not be blindly assuming that someone **will** have it installed. Handle it gracefully if it is not available. – t0mm13b May 20 '16 at 12:15
  • linkedin is installed. i'm not posting on linkedin with the above code. just searching the apps i can post to. – div May 20 '16 at 12:18
  • The other possibility, is the linkedin account is not set up and thus sharing is not yet available? – t0mm13b May 20 '16 at 12:21
  • it's set up properly in the device i'm testing. – div May 20 '16 at 12:21
  • it works on iphone without the sdk. are you sure i need the sdk for android cz it will increase the app size? – div May 20 '16 at 12:27
  • intent.setPackage("com.linkedin"); may be help you – Amit Basliyal May 20 '16 at 12:28
  • See this [question and answer](http://stackoverflow.com/questions/12599337/class-name-to-share-via-intent-to-linkedin-only) might help to search on the existing questions here on Stackoverflow instead of posting new questions! – t0mm13b May 20 '16 at 12:29
  • i repeat : i am not posting to linkedin using the above code. i am trying to get the list of apps i can post to. – div May 20 '16 at 12:32

2 Answers2

1

enter image description here

Code is

Intent intent = new Intent(Intent.ACTION_SEND);
            intent.setType("text/plain");
            String shareBody = "https://developers.facebook.com/docs/android/share";
            intent.putExtra(Intent.EXTRA_TITLE,"Share From Test App");
            intent.putExtra(Intent.EXTRA_TEXT,shareBody);
            intent.putExtra(Intent.EXTRA_SUBJECT, "hello");
            startActivity(Intent.createChooser(intent, "Share With"));
Amit Basliyal
  • 840
  • 1
  • 10
  • 28
1

Add this to the intent:

intent.putExtra(Intent.EXTRA_SUBJECT, "dsvs");
div
  • 1,475
  • 3
  • 22
  • 32