我使用下面的代码来分享来自我的android应用程序的内容,该应用程序向whatsapp显示网页视图页面。
它工作得很好,除了一个问题。它共享完整的链接,包括whatsapp://send?text=我只想共享内容。
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);我尝试使用replace来替换whatsapp://send?文本,但是它给出了一个错误,replace(string,string) is undefined。
有没有更好的方法来实现这一点?
发布于 2015-08-24 05:38:23
好的,所以,你需要一个字符接一个字符,直到你到达字符“?”,.Create一个循环,一个字符接一个字符。当你到了"?“离开循环,并选择字符串的其余部分作为新字符串。What is the easiest/best/most correct way to iterate through the characters of a string in Java?
在此之后,您的字符串来自charAt( "?“是+ 1)到最后。
https://stackoverflow.com/questions/32171737
复制相似问题