Open conversation based on clicked number then intent the image












2















I know this is a common question that has been asked. But my problem is different now. So I create a share button which if I click it will open list of phone number like below :



List of phone number



So when I click one of them, it will immediately open conversation in whats app base on the phone number I click. I use this code



 val url = "https://api.whatsapp.com/send?phone=62"+tempDatas!![position].custHpWa
val intent = Intent(Intent.ACTION_VIEW);
intent.putExtra(Intent.EXTRA_TEXT,intent.getStringExtra("DESCRIPTION") );
intent.data = Uri.parse(url)
startActivity(intent);


Then I add this code for intent image into the conversation



 rvListWa!!.addOnItemTouchListener(RecyclerItemClickListener(this@ShareFileActivity,
RecyclerItemClickListener.OnItemClickListener { view, position ->

Glide
.with(this@ShareFileActivity)
.load(baseURLPicasso+intent.getStringExtra("PICTURE"))
.asBitmap()
.into(object : SimpleTarget<Bitmap>() {
override fun onResourceReady(resource: Bitmap?, glideAnimation: GlideAnimation<in Bitmap>?) {

val url = "https://api.whatsapp.com/send?phone=62"+tempDatas!![position].custHpWa
val intent = Intent(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_TEXT,intent.getStringExtra("DESCRIPTION") );
val path = MediaStore.Images.Media.insertImage(getContentResolver(), resource, "", null);
val image = Uri.parse(path);

intent.data = Uri.parse(url)
intent.putExtra(Intent.EXTRA_STREAM, image);
intent.setType("image/*");
startActivity(intent);


}

})
}))


Instead of open conversation base on number and send image. It turns out open whats app and choose to who we want to send it.



Is there any solution. Because I already try to make the Intent.ACTION_VIEW it will open gallery.



My image url is from database










share|improve this question

























  • Possible duplicate of Send text to specific contact programmatically (whatsapp)

    – Sushil Kumar
    Nov 21 '18 at 4:36
















2















I know this is a common question that has been asked. But my problem is different now. So I create a share button which if I click it will open list of phone number like below :



List of phone number



So when I click one of them, it will immediately open conversation in whats app base on the phone number I click. I use this code



 val url = "https://api.whatsapp.com/send?phone=62"+tempDatas!![position].custHpWa
val intent = Intent(Intent.ACTION_VIEW);
intent.putExtra(Intent.EXTRA_TEXT,intent.getStringExtra("DESCRIPTION") );
intent.data = Uri.parse(url)
startActivity(intent);


Then I add this code for intent image into the conversation



 rvListWa!!.addOnItemTouchListener(RecyclerItemClickListener(this@ShareFileActivity,
RecyclerItemClickListener.OnItemClickListener { view, position ->

Glide
.with(this@ShareFileActivity)
.load(baseURLPicasso+intent.getStringExtra("PICTURE"))
.asBitmap()
.into(object : SimpleTarget<Bitmap>() {
override fun onResourceReady(resource: Bitmap?, glideAnimation: GlideAnimation<in Bitmap>?) {

val url = "https://api.whatsapp.com/send?phone=62"+tempDatas!![position].custHpWa
val intent = Intent(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_TEXT,intent.getStringExtra("DESCRIPTION") );
val path = MediaStore.Images.Media.insertImage(getContentResolver(), resource, "", null);
val image = Uri.parse(path);

intent.data = Uri.parse(url)
intent.putExtra(Intent.EXTRA_STREAM, image);
intent.setType("image/*");
startActivity(intent);


}

})
}))


Instead of open conversation base on number and send image. It turns out open whats app and choose to who we want to send it.



Is there any solution. Because I already try to make the Intent.ACTION_VIEW it will open gallery.



My image url is from database










share|improve this question

























  • Possible duplicate of Send text to specific contact programmatically (whatsapp)

    – Sushil Kumar
    Nov 21 '18 at 4:36














2












2








2








I know this is a common question that has been asked. But my problem is different now. So I create a share button which if I click it will open list of phone number like below :



List of phone number



So when I click one of them, it will immediately open conversation in whats app base on the phone number I click. I use this code



 val url = "https://api.whatsapp.com/send?phone=62"+tempDatas!![position].custHpWa
val intent = Intent(Intent.ACTION_VIEW);
intent.putExtra(Intent.EXTRA_TEXT,intent.getStringExtra("DESCRIPTION") );
intent.data = Uri.parse(url)
startActivity(intent);


Then I add this code for intent image into the conversation



 rvListWa!!.addOnItemTouchListener(RecyclerItemClickListener(this@ShareFileActivity,
RecyclerItemClickListener.OnItemClickListener { view, position ->

Glide
.with(this@ShareFileActivity)
.load(baseURLPicasso+intent.getStringExtra("PICTURE"))
.asBitmap()
.into(object : SimpleTarget<Bitmap>() {
override fun onResourceReady(resource: Bitmap?, glideAnimation: GlideAnimation<in Bitmap>?) {

val url = "https://api.whatsapp.com/send?phone=62"+tempDatas!![position].custHpWa
val intent = Intent(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_TEXT,intent.getStringExtra("DESCRIPTION") );
val path = MediaStore.Images.Media.insertImage(getContentResolver(), resource, "", null);
val image = Uri.parse(path);

intent.data = Uri.parse(url)
intent.putExtra(Intent.EXTRA_STREAM, image);
intent.setType("image/*");
startActivity(intent);


}

})
}))


Instead of open conversation base on number and send image. It turns out open whats app and choose to who we want to send it.



Is there any solution. Because I already try to make the Intent.ACTION_VIEW it will open gallery.



My image url is from database










share|improve this question
















I know this is a common question that has been asked. But my problem is different now. So I create a share button which if I click it will open list of phone number like below :



List of phone number



So when I click one of them, it will immediately open conversation in whats app base on the phone number I click. I use this code



 val url = "https://api.whatsapp.com/send?phone=62"+tempDatas!![position].custHpWa
val intent = Intent(Intent.ACTION_VIEW);
intent.putExtra(Intent.EXTRA_TEXT,intent.getStringExtra("DESCRIPTION") );
intent.data = Uri.parse(url)
startActivity(intent);


Then I add this code for intent image into the conversation



 rvListWa!!.addOnItemTouchListener(RecyclerItemClickListener(this@ShareFileActivity,
RecyclerItemClickListener.OnItemClickListener { view, position ->

Glide
.with(this@ShareFileActivity)
.load(baseURLPicasso+intent.getStringExtra("PICTURE"))
.asBitmap()
.into(object : SimpleTarget<Bitmap>() {
override fun onResourceReady(resource: Bitmap?, glideAnimation: GlideAnimation<in Bitmap>?) {

val url = "https://api.whatsapp.com/send?phone=62"+tempDatas!![position].custHpWa
val intent = Intent(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_TEXT,intent.getStringExtra("DESCRIPTION") );
val path = MediaStore.Images.Media.insertImage(getContentResolver(), resource, "", null);
val image = Uri.parse(path);

intent.data = Uri.parse(url)
intent.putExtra(Intent.EXTRA_STREAM, image);
intent.setType("image/*");
startActivity(intent);


}

})
}))


Instead of open conversation base on number and send image. It turns out open whats app and choose to who we want to send it.



Is there any solution. Because I already try to make the Intent.ACTION_VIEW it will open gallery.



My image url is from database







android image android-intent kotlin whatsapp






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 21 '18 at 9:10







Ratri

















asked Nov 21 '18 at 4:30









RatriRatri

5711




5711













  • Possible duplicate of Send text to specific contact programmatically (whatsapp)

    – Sushil Kumar
    Nov 21 '18 at 4:36



















  • Possible duplicate of Send text to specific contact programmatically (whatsapp)

    – Sushil Kumar
    Nov 21 '18 at 4:36

















Possible duplicate of Send text to specific contact programmatically (whatsapp)

– Sushil Kumar
Nov 21 '18 at 4:36





Possible duplicate of Send text to specific contact programmatically (whatsapp)

– Sushil Kumar
Nov 21 '18 at 4:36












1 Answer
1






active

oldest

votes


















1














Hope this works. Just pass the path the file location of the file variable and make sure you pass the correct phone number.



    val sendIntent = Intent("android.intent.action.SEND")
val f = File("path to the file")
val uri = Uri.fromFile(f)
sendIntent.component = ComponentName("com.whatsapp", "com.whatsapp.ContactPicker")
sendIntent.type = "image"
sendIntent.putExtra(Intent.EXTRA_STREAM, uri)
sendIntent.putExtra("jid", PhoneNumberUtils.stripSeparators("91**********") + "@s.whatsapp.net")
sendIntent.putExtra(Intent.EXTRA_TEXT, "sample text you want to send along with the image")
startActivity(sendIntent)





share|improve this answer
























  • it doesn't work sir @Nagendra.. when I click the whatsapp icon it do nothing

    – Ratri
    Nov 21 '18 at 5:06













  • Does the phone number in your code match with your whatsapp contact number?

    – Nagendra Hari Karthick
    Nov 21 '18 at 5:13











  • PhoneNumberUtils.stripSeparators(tempDatas!![position].custHpWa) , custHpWa is 081944877002, indonesian code

    – Ratri
    Nov 21 '18 at 5:31











  • can you post your full code?

    – Nagendra Hari Karthick
    Nov 21 '18 at 5:38











  • i change this com.whatsapp.ContactPicker into com.whatsapp.Conversation, it works but only for opening the convo , but my number becoming +081944877002 also the image not include

    – Ratri
    Nov 21 '18 at 5:39











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53405286%2fopen-conversation-based-on-clicked-number-then-intent-the-image%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














Hope this works. Just pass the path the file location of the file variable and make sure you pass the correct phone number.



    val sendIntent = Intent("android.intent.action.SEND")
val f = File("path to the file")
val uri = Uri.fromFile(f)
sendIntent.component = ComponentName("com.whatsapp", "com.whatsapp.ContactPicker")
sendIntent.type = "image"
sendIntent.putExtra(Intent.EXTRA_STREAM, uri)
sendIntent.putExtra("jid", PhoneNumberUtils.stripSeparators("91**********") + "@s.whatsapp.net")
sendIntent.putExtra(Intent.EXTRA_TEXT, "sample text you want to send along with the image")
startActivity(sendIntent)





share|improve this answer
























  • it doesn't work sir @Nagendra.. when I click the whatsapp icon it do nothing

    – Ratri
    Nov 21 '18 at 5:06













  • Does the phone number in your code match with your whatsapp contact number?

    – Nagendra Hari Karthick
    Nov 21 '18 at 5:13











  • PhoneNumberUtils.stripSeparators(tempDatas!![position].custHpWa) , custHpWa is 081944877002, indonesian code

    – Ratri
    Nov 21 '18 at 5:31











  • can you post your full code?

    – Nagendra Hari Karthick
    Nov 21 '18 at 5:38











  • i change this com.whatsapp.ContactPicker into com.whatsapp.Conversation, it works but only for opening the convo , but my number becoming +081944877002 also the image not include

    – Ratri
    Nov 21 '18 at 5:39
















1














Hope this works. Just pass the path the file location of the file variable and make sure you pass the correct phone number.



    val sendIntent = Intent("android.intent.action.SEND")
val f = File("path to the file")
val uri = Uri.fromFile(f)
sendIntent.component = ComponentName("com.whatsapp", "com.whatsapp.ContactPicker")
sendIntent.type = "image"
sendIntent.putExtra(Intent.EXTRA_STREAM, uri)
sendIntent.putExtra("jid", PhoneNumberUtils.stripSeparators("91**********") + "@s.whatsapp.net")
sendIntent.putExtra(Intent.EXTRA_TEXT, "sample text you want to send along with the image")
startActivity(sendIntent)





share|improve this answer
























  • it doesn't work sir @Nagendra.. when I click the whatsapp icon it do nothing

    – Ratri
    Nov 21 '18 at 5:06













  • Does the phone number in your code match with your whatsapp contact number?

    – Nagendra Hari Karthick
    Nov 21 '18 at 5:13











  • PhoneNumberUtils.stripSeparators(tempDatas!![position].custHpWa) , custHpWa is 081944877002, indonesian code

    – Ratri
    Nov 21 '18 at 5:31











  • can you post your full code?

    – Nagendra Hari Karthick
    Nov 21 '18 at 5:38











  • i change this com.whatsapp.ContactPicker into com.whatsapp.Conversation, it works but only for opening the convo , but my number becoming +081944877002 also the image not include

    – Ratri
    Nov 21 '18 at 5:39














1












1








1







Hope this works. Just pass the path the file location of the file variable and make sure you pass the correct phone number.



    val sendIntent = Intent("android.intent.action.SEND")
val f = File("path to the file")
val uri = Uri.fromFile(f)
sendIntent.component = ComponentName("com.whatsapp", "com.whatsapp.ContactPicker")
sendIntent.type = "image"
sendIntent.putExtra(Intent.EXTRA_STREAM, uri)
sendIntent.putExtra("jid", PhoneNumberUtils.stripSeparators("91**********") + "@s.whatsapp.net")
sendIntent.putExtra(Intent.EXTRA_TEXT, "sample text you want to send along with the image")
startActivity(sendIntent)





share|improve this answer













Hope this works. Just pass the path the file location of the file variable and make sure you pass the correct phone number.



    val sendIntent = Intent("android.intent.action.SEND")
val f = File("path to the file")
val uri = Uri.fromFile(f)
sendIntent.component = ComponentName("com.whatsapp", "com.whatsapp.ContactPicker")
sendIntent.type = "image"
sendIntent.putExtra(Intent.EXTRA_STREAM, uri)
sendIntent.putExtra("jid", PhoneNumberUtils.stripSeparators("91**********") + "@s.whatsapp.net")
sendIntent.putExtra(Intent.EXTRA_TEXT, "sample text you want to send along with the image")
startActivity(sendIntent)






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 21 '18 at 4:52









Nagendra Hari KarthickNagendra Hari Karthick

220212




220212













  • it doesn't work sir @Nagendra.. when I click the whatsapp icon it do nothing

    – Ratri
    Nov 21 '18 at 5:06













  • Does the phone number in your code match with your whatsapp contact number?

    – Nagendra Hari Karthick
    Nov 21 '18 at 5:13











  • PhoneNumberUtils.stripSeparators(tempDatas!![position].custHpWa) , custHpWa is 081944877002, indonesian code

    – Ratri
    Nov 21 '18 at 5:31











  • can you post your full code?

    – Nagendra Hari Karthick
    Nov 21 '18 at 5:38











  • i change this com.whatsapp.ContactPicker into com.whatsapp.Conversation, it works but only for opening the convo , but my number becoming +081944877002 also the image not include

    – Ratri
    Nov 21 '18 at 5:39



















  • it doesn't work sir @Nagendra.. when I click the whatsapp icon it do nothing

    – Ratri
    Nov 21 '18 at 5:06













  • Does the phone number in your code match with your whatsapp contact number?

    – Nagendra Hari Karthick
    Nov 21 '18 at 5:13











  • PhoneNumberUtils.stripSeparators(tempDatas!![position].custHpWa) , custHpWa is 081944877002, indonesian code

    – Ratri
    Nov 21 '18 at 5:31











  • can you post your full code?

    – Nagendra Hari Karthick
    Nov 21 '18 at 5:38











  • i change this com.whatsapp.ContactPicker into com.whatsapp.Conversation, it works but only for opening the convo , but my number becoming +081944877002 also the image not include

    – Ratri
    Nov 21 '18 at 5:39

















it doesn't work sir @Nagendra.. when I click the whatsapp icon it do nothing

– Ratri
Nov 21 '18 at 5:06







it doesn't work sir @Nagendra.. when I click the whatsapp icon it do nothing

– Ratri
Nov 21 '18 at 5:06















Does the phone number in your code match with your whatsapp contact number?

– Nagendra Hari Karthick
Nov 21 '18 at 5:13





Does the phone number in your code match with your whatsapp contact number?

– Nagendra Hari Karthick
Nov 21 '18 at 5:13













PhoneNumberUtils.stripSeparators(tempDatas!![position].custHpWa) , custHpWa is 081944877002, indonesian code

– Ratri
Nov 21 '18 at 5:31





PhoneNumberUtils.stripSeparators(tempDatas!![position].custHpWa) , custHpWa is 081944877002, indonesian code

– Ratri
Nov 21 '18 at 5:31













can you post your full code?

– Nagendra Hari Karthick
Nov 21 '18 at 5:38





can you post your full code?

– Nagendra Hari Karthick
Nov 21 '18 at 5:38













i change this com.whatsapp.ContactPicker into com.whatsapp.Conversation, it works but only for opening the convo , but my number becoming +081944877002 also the image not include

– Ratri
Nov 21 '18 at 5:39





i change this com.whatsapp.ContactPicker into com.whatsapp.Conversation, it works but only for opening the convo , but my number becoming +081944877002 also the image not include

– Ratri
Nov 21 '18 at 5:39


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53405286%2fopen-conversation-based-on-clicked-number-then-intent-the-image%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

If I really need a card on my start hand, how many mulligans make sense? [duplicate]

Alcedinidae

Can an atomic nucleus contain both particles and antiparticles? [duplicate]