2

i am using below code to share content from my android app which shows webview page to whatsapp.

it works just fine except one issues. it shares complete link including whatsapp://send?text= i want only content to be shared.

  Uri uri = Uri.parse(url);
 Intent sendIntent = new Intent();
  sendIntent.setAction(Intent.ACTION_SEND);
 sendIntent.putExtra(Intent.EXTRA_TEXT, ""  + uri);
 sendIntent.setType("text/plain");
 sendIntent.setPackage("com.whatsapp");
 startActivity(sendIntent);

i tried using replace for replacing the whatsapp://send?text but it gives error that replace(string,string) is undefined.

is there any better way to achieve this

anamika
  • 75
  • 5

1 Answers1

0

Ok, so, you need to go one char by char until you get to the char "?".Create a loop and go character by character. When you get to the "?" leave the loop, and select the rest of the string as a new string. What is the easiest/best/most correct way to iterate through the characters of a string in Java?

After that, your strin is from charAt(where the "?" is + 1) to the end.

Community
  • 1
  • 1
Vulovic Vukasin
  • 1,540
  • 2
  • 21
  • 30