android - 如何获取设备上安装的所有共享应用程序?

标签 android

我想要共享文本和图像,我找到应用程序包明智的搜索,然后共享应用程序明智的共享功能。

请帮忙。

注意:我只想分享带有链接的文本。

谢谢

最佳答案

Intent intentIN = getPackageManager().getLaunchIntentForPackage("PACKAGE NAME");
         if (intentIN != null) {
             Intent shareIntentIN = new Intent();
             shareIntentIN.setAction(Intent.ACTION_SEND);
             shareIntentIN.setPackage("com.instagram.android");
             try {
              shareIntentIN.putExtra(Intent.EXTRA_STREAM, Uri.parse(MediaStore.Images.Media.insertImage(getContentResolver(), "", "I am Happy", "Share happy !")));
             } catch (FileNotFoundException e) {
                 e.printStackTrace();
             }
             shareIntentIN.setType("image/jpeg");

             startActivity(shareIntentIN);
         } else {
             // bring user to the market to download the app.
             // or let them choose an app?
          intentIN = new Intent(Intent.ACTION_VIEW);
          intentIN.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
          intentIN.setData(Uri.parse("https://play.google.com/store/apps/details?id=com.instagram.android&hl=en"));
             startActivity(intentIN);
         }

请尝试这个。根据您的需要更改包名称。

关于android - 如何获取设备上安装的所有共享应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24906527/

相关文章:

android - ioctl LOOP_SET_FD 失败

android - imageview 不会在触摸事件 android 上移动

android - 通过 Facebook 分享 - 在选择列表中缺失 - Android

android - 不能保护多功能即时应用程序?

java - 当前时间作为 32 位 UNIX 时间戳和时间偏移

Android OpenGL ES 纹理在某些三星设备的黑屏上显示

Android Sticky - 使用jetpack的页脚撰写: Align footer view to table,直到它达到屏幕尺寸然后固定在底部

java - 无法将上下文转换为 fragment 的 FragmentAdapter 中的 CustomCallBack 接口(interface)

java - Android - 以线性布局显示 WebView

Android - 为什么 SaxParser 可以处理本地 XML 文件,但不能处理 URL 上的 XML?