Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/188.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 安卓分享多个笑话的意图_Android_Android Intent - Fatal编程技术网

Android 安卓分享多个笑话的意图

Android 安卓分享多个笑话的意图,android,android-intent,Android,Android Intent,我正在为笑话创建一个android应用程序。我有很多笑话想和whatsapp用户分享 我是否需要为每个笑话分别编写共享意图 例如: public void share(View view) { Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_TEXT,

我正在为笑话创建一个android应用程序。我有很多笑话想和whatsapp用户分享

我是否需要为每个笑话分别编写共享意图

例如:

public void share(View view) 
    {
        Intent sendIntent = new Intent();
           sendIntent.setAction(Intent.ACTION_SEND);
           sendIntent.putExtra(Intent.EXTRA_TEXT,
               "Q: What did the butcher say when he backed into the meat-grinder?
A: Looks like I'm getting a little behind in my work!");
           sendIntent.setType("text/plain");
           startActivity(sendIntent);
    }

请提供帮助。

为了让您更容易理解,只需将意图看作是一个信使,它可以帮助您将数据从Activity1传递到Activity2

在这种情况下,您可以尝试一种简单的方法:将您的笑话放入字符串中:

字符串笑话=Q:屠夫回到绞肉机时说了什么?\n 看来我的工作有点落后了

sendIntent.putExtraIntent.EXTRA_文本,笑话


喜欢尝试其他方法,当你改进Java时,

可能会对你有所帮助…嗨..我是Android开发的初学者。请你举一个例子,因为我无法理解这个链接中的任何内容。非常感谢你,杰基。现在这个概念很清楚了。但是我必须为每个笑话分别写意图吗?不,相反,你可以用每个字符串来开始写每个笑话。示例:字符串joke1=。。。。;字符串2=;并将这些变量添加到意图中。笑话一,笑话二。。。是“包”,在“卡车”的意图,正在交付。正如你所知,我是android开发的新手。。请给我一个完整代码的例子。再次感谢你的帮助。非常感谢!看看这个示例:如果您愿意看到真实的代码,并且我假设您知道如何从其他代码重建,我将向您发送整个代码Hi jacky…我在片段中使用。。。请看一下这段代码……它给了我GetInstant的错误&我改成了这段也是Intent sendIntent=new IntentgetActivity,JokeActivity.class;因为它给了我错误。还请告诉我,我的xml文件将看起来像main.xml&jokes.xml。对不起打扰你了。再次感谢。