sendWhatsapp.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String num = "+94****525";
String msg = "மருத்துவ ஆலோசனை தேவை";
boolean installed = isAppInstalled("com.whatsapp");
if(installed){
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("https://api.whatsapp.com/send?phone=" + num + "&text=" + msg));
startActivity(intent);
}else {
Toast.makeText(HomeActivity.this, "வட்சப் செயலியை நிறுவுக!", Toast.LENGTH_SHORT).show();
}
}
});
private boolean isAppInstalled(String s) {
PackageManager packageManager = getPackageManager();
boolean is_installed;
try {
packageManager.getPackageInfo(s, PackageManager.GET_ACTIVITIES);
is_installed = true;
} catch (PackageManager.NameNotFoundException e) {
is_installed = false;
e.printStackTrace();
}
return is_installed;
}
in Manifest file
<queries>
<package android:name="com.whatsapp" />
<package android:name="com.whatsapp.w4b" />
</queries>
0 Comments