java如何在定制Android应用程序中实现“whatsapp共享”功能?
我在这个网站上读了几篇已经回复的文章,并使用了这个 Sending message through WhatsApp
我可以从chrome上分享,但不能从app上分享
我的密码是
public void onClickWhatsApp(View view) {
PackageManager pm=getPackageManager();
try {
Intent waIntent = new Intent(Intent.ACTION_SEND);
waIntent.setType("text/plain");
String text = "YOUR TEXT HERE";
PackageInfo info=pm.getPackageInfo("com.whatsapp", PackageManager.GET_META_DATA);
//Check if package exists or not. If not then code
//in catch block will be called
waIntent.setPackage("com.whatsapp");
waIntent.putExtra(Intent.EXTRA_TEXT, text);
startActivity(Intent.createChooser(waIntent, "Share with"));
} catch (NameNotFoundException e) {
Toast.makeText(MainActivity.this, "WhatsApp not Installed", Toast.LENGTH_SHORT).show();
}
}
当我点击我的安卓应用whatsapp图标中的共享按钮时,它会显示错误页面not found,但当从chrome上共享相同的内容时,它就可以正常工作了
我的网址是http://way2enjoy.com/app/jokes.php
如果有人能告诉我错误在哪里,我将心存感激
共 (0) 个答案