标签: share-intent

通过Whatsapp或Facebook分享图像和文字

我在我的应用程序中有一个共享按钮,我想同时共享图像和文本.Gmail中工作正常,但在WhatsApp的,只有图像被发送和Facebook的应用程序崩溃.

我使用共享代码是这样的:

Intent shareIntent = new Intent(Intent.ACTION_SEND);  
shareIntent.setType("image/*");
shareIntent.putExtra(Intent.EXTRA_TEXT, "Message");         

Uri uri = Uri.parse("android.resource://" + getPackageName() + "/drawable/ford_focus_2014");
     try {
        InputStream stream = getContentResolver().openInputStream(uri);
    } catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
Run Code Online (Sandbox Code Playgroud)

如果我使用"shareIntent.setType("*/*")"Facebook和WhatsApp崩溃.

有办法做到这一点吗?也许同时发送两条消息(WhatsApp).

提前致谢.

android facebook whatsapp share-intent

24
推荐指数
3
解决办法
6万
查看次数

如何以编程方式将图像或视频发送到android中的whatsapp状态?

如何在 Android 中将图像或视频发送到 WhatsApp 状态(或故事)。

我们可以使用以下方式将图像发送给联系人:

Intent sendIntent = new Intent("android.intent.action.MAIN");
sendIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
sendIntent.putExtra(Intent.EXTRA_STREAM, imageURI);
sendIntent.putExtra("jid", "91"+mobile + "@s.whatsapp.net");
sendIntent.putExtra(Intent.EXTRA_TEXT, "whatsapp image caption");
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.setPackage("com.whatsapp");
sendIntent.setType("image/*");
Run Code Online (Sandbox Code Playgroud)

但如何将其发送到我的 Whatsapp 状态呢?

android whatsapp share-intent

7
推荐指数
1
解决办法
4520
查看次数

如何显示我们的应用程序(如 facebook)的多个图像共享选项?

我正在创建一个社交媒体应用程序,用户可以在其中共享图像、视频、音频等。通过在清单文件中添加以下代码,我成功地接收了从第三方应用程序共享的媒体。

<activity
        android:name=".activity.SendToActivity"
        android:screenOrientation="portrait"
        android:theme="@style/Theme.AppCompat.NoActionBar">
        <intent-filter>
            <action android:name="android.intent.action.SEND" />

            <category android:name="android.intent.category.DEFAULT" />

            <data android:mimeType="*/*" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.SEND_MULTIPLE" />

            <category android:name="android.intent.category.DEFAULT" />

            <data android:mimeType="*/*" />
        </intent-filter>
    </activity>
Run Code Online (Sandbox Code Playgroud)

现在,当用户尝试从他们的图库(如 facebook)(设置为个人资料图片)共享图片以直接上传个人资料图片时,我想显示我的应用程序的多个图标。请看截图

像facebook一样显示多个图标

当用户尝试从他们的图库中共享图像时,请有人帮助我显示我的应用程序的多个图标。

android image android-manifest share-intent

6
推荐指数
1
解决办法
136
查看次数

Android:共享意图不适用于视频文件路径

我有一个视频文件路径,想在社交媒体上共享视频,但是无法共享视频。我正在尝试遵循Android Studio 2.2中的代码,但是无法正常工作。

程式码片段:

public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Button shareBtn = (Button) findViewById(R.id.sharebutton);

    shareBtn .setOnClickListener(
            new Button.OnClickListener() {
                public void onClick(View v) {

                    File f = new File("/sdcard/VID_20161201123613.mp4");
                    Uri uriPath = Uri.parse(f.getPath());

                    Intent shareIntent = new Intent();
                    shareIntent.setAction(Intent.ACTION_SEND);
                    shareIntent.putExtra(Intent.EXTRA_TEXT, "Text");                  
                    shareIntent.putExtra(Intent.EXTRA_STREAM, uriPath);
                    shareIntent.setType("video/*");
                    shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
                    startActivity(Intent.createChooser(shareIntent, "send"));

                }
            }
    );
}
Run Code Online (Sandbox Code Playgroud)

video android android-intent share-intent

5
推荐指数
1
解决办法
7776
查看次数

如何使用选择器中的Intent作为PendingIntent

我想使用CustomTabs库,我需要添加一个共享菜单项.该库只接受PendingIntent实例作为菜单项的Action.我想使用以下代码确保在没有Just Once和Always按钮的情况下始终向用户建议列表:

Intent shareIntent = Intent.createChooser(intent, "Choose the application to share.");
Run Code Online (Sandbox Code Playgroud)

但问题是,如果我使用此选择器Intent创建PendingIntent,则CustomTabs for Chrome不会为用户激活选择器:

PendingIntent pendingIntent = PendingIntent.getActivity(context,
            requestCode,
            shareIntent,
            PendingIntent.FLAG_UPDATE_CURRENT);
Run Code Online (Sandbox Code Playgroud)

有没有办法使用Chooser的Intent作为PendingIntent?

我不能使用以下行来启动Intent,因为库是这样做的,它只接受PendingIntents:

startActivity(Intent.createChooser(i, getString()));
Run Code Online (Sandbox Code Playgroud)

android android-pendingintent chrome-custom-tabs share-intent

4
推荐指数
1
解决办法
837
查看次数

使用kotlin在android studio中共享意图文本

我想使用kotlin使用共享Intent 在我的CardView中共享文本但是kotlin代码中的最后一行有问题代码

 val shareIntent = Intent()
            shareIntent.action = Intent.ACTION_SEND
            shareIntent.putExtra(Intent.EXTRA_STREAM, "ali")
            shareIntent.type = "text/plain"
            startActivity(Intent.createChooser(shareIntent, getResources().getText(R.string.send_to)))
Run Code Online (Sandbox Code Playgroud)

这是代码中的问题

startActivity(Intent.createChooser(shareIntent, getResources().getText(R.string.send_to)))
Run Code Online (Sandbox Code Playgroud)

请帮我

看图像了解我

图片

https://ibb.co/jQwYXw

https://ibb.co/id0tXw

https://ibb.co/fbCU5G

适配器完整代码

class MyAdapter(context: Context, listItem: ArrayList<com.EliteTeam.comedytaste.Model.Movie>) : RecyclerView.Adapter<MyAdapter.MyViewHolder>() {

var Context = context
var movieList = listItem;
var layoutInflator = LayoutInflater.from(context)

override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int): MyViewHolder {

    var inflateView = layoutInflator.inflate(R.layout.single_item, parent, false)

    return MyViewHolder(inflateView)
}

override fun onBindViewHolder(holder: MyViewHolder?, position: Int) {

    holder?.moviewTitle?.text = movieList[position].name
    holder?.movieDescription!!.text=   movieList[position].description
    //holder!!.cardImageView!!.background= …
Run Code Online (Sandbox Code Playgroud)

android android-intent kotlin android-studio share-intent

4
推荐指数
1
解决办法
4744
查看次数

Intent.ACTION_SEND无法使用Oreo

我正在开发一个自定义相机应用程序,它捕获图片并将其存储在图库中.当我使用Intent.ACTION_SEND共享该图像时,除了具有API 26的设备(即OREO)之外,它在所有设备上都能正常工作.

我分享图片的代码是:

Intent shareIntent = new Intent();
            shareIntent.setAction(Intent.ACTION_SEND);
            shareIntent.setType("image/jpeg");
            Uri uriShare = Uri.fromFile(outFile);
            //outfile is the path of the image stored in the gallery
            shareIntent.putExtra(Intent.EXTRA_STREAM, uriShare);
            startActivity(Intent.createChooser(shareIntent, ""));
Run Code Online (Sandbox Code Playgroud)

任何人都可以帮我解决这个问题吗?

java android share-intent android-8.0-oreo

4
推荐指数
1
解决办法
1万
查看次数

分享时将标题文字加粗

在这里,下面的代码将分享 onclick 的内容。通过其他应用分享内容时,有两种内容:一种是标题,另一种是描述。我想在分享时将标题加粗。那可能吗?

expListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {

    @Override
    public boolean onChildClick(ExpandableListView parent, View v,
                                int groupPosition, int childPosition, long id) {
        // TODO Auto-generated method stub

        TextView de = (TextView) v.findViewById(R.id.lblListItem);
        TextView ti = (TextView) v.findViewById(R.id.lblListHeader);


        String selected = ti.getText().toString() + de.getText().toString();
        Intent intent = new Intent(Intent.ACTION_SEND);
        intent.setType("text/plain");
        intent.putExtra(Intent.EXTRA_TEXT, selected);
        startActivity(Intent.createChooser(intent, "Share via"));

        return false;
    }
});
Run Code Online (Sandbox Code Playgroud)

java android share-intent

2
推荐指数
1
解决办法
1166
查看次数

如何在android中放置共享应用程序选项(尚未发布)

我想第一次发布应用程序.

我想在我的应用中添加一个分享按钮,当用户点击它时会打开所有的消息传递应用,并且可以与其他人分享链接,当其他人点击它时,它会在我的应用中进行google play商店.

我在这里看过,我认为这是我需要做的事情.

问题是如何获取我的应用程序的链接,该链接尚未在Google Play商店中发布.

我是否需要先发布我的应用程序,而不购股权,然后拿到市场链接,就像提到这里,我想到了链接有可能是这样的市场://细节ID =程序包,然后用SHARE发布的更新选项?

android google-play share-intent

1
推荐指数
1
解决办法
1364
查看次数

来自Content Provider with Content Provider的Android Intent.ACTION_SEND

我正在内部存储上保存文件.它只是一个.txt文件,其中包含有关对象的一些信息:

    FileOutputStream outputStream;
    String filename = "file.txt";

    File cacheDir = context.getCacheDir();
    File outFile = new File(cacheDir, filename);
    outputStream = new FileOutputStream(outFile.getAbsolutePath());
    outputStream.write(myString.getBytes());
    outputStream.flush();
    outputStream.close();
Run Code Online (Sandbox Code Playgroud)

然后我创建一个"shareIntent"来共享这个文件:

    Uri notificationUri = Uri.parse("content://com.package.example/file.txt");
    Intent shareIntent = new Intent(Intent.ACTION_SEND);
    shareIntent.putExtra(Intent.EXTRA_STREAM, notificationUri);
    shareIntent.setType("text/plain");
    context.startActivity(Intent.createChooser(shareIntent, context.getResources().getText(R.string.chooser)));
Run Code Online (Sandbox Code Playgroud)

所选应用程序现在需要访问私有文件,因此我创建了一个内容提供程序.我刚刚更改了openFile方法:

@Override
public ParcelFileDescriptor openFile(Uri uri, String mode) throws FileNotFoundException {
    File privateFile = new File(getContext().getCacheDir(), uri.getPath());
    return ParcelFileDescriptor.open(privateFile, ParcelFileDescriptor.MODE_READ_ONLY);
}
Run Code Online (Sandbox Code Playgroud)

清单:

<provider
        android:name=".ShareContentProvider"
        android:authorities="com.package.example"
        android:grantUriPermissions="true"
        android:exported="true">
    </provider>
Run Code Online (Sandbox Code Playgroud)

打开邮件应用程序以共享它所说的文件时,它无法附加文件,因为它只有0字节.通过蓝牙共享它也失败了.但是我可以privateFile在内容提供商中读出它,因此它存在且具有内容.问题是什么?

android android-contentprovider internal-storage share-intent android-internal-storage

1
推荐指数
1
解决办法
2670
查看次数

使用动作发送共享图像

所以我想用来Intent.ACTION_SEND从我的应用程序共享图像。

这是我正在使用的代码

Intent shareIntent = new Intent();
    shareIntent.setAction(Intent.ACTION_SEND);
    shareIntent.putExtra(Intent.EXTRA_STREAM, shareImgURI);
    shareIntent.setType("image/*");
    shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
    startActivity(Intent.createChooser(shareIntent, "Share images..."));
Run Code Online (Sandbox Code Playgroud)

并且shareImgURI是content://com.android.providers.media.documents/document/image%3A298

它会打开选​​择器,但是当我选择一个选项时没有任何反应。我错过了什么吗?

android android-intent share-intent

1
推荐指数
2
解决办法
1万
查看次数