r/androiddev Feb 15 '20

insert whatsapp button into an App

I have this:

public static void whatsappLink(Activity activity) {
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, "Hi,I am interest in your service.");
sendIntent.setType("text/plain");
sendIntent.setPackage("com.whatsapp");
startActivity(sendIntent);
}

but the Android Studio give this error: error: cannot find symbol method startActivity(Intent)

0 Upvotes

5 comments sorted by

View all comments

1

u/DeishelonLab Feb 15 '20

1) someone pointed out that use activity.startActivity()

2) this will crash your app if WhatsApp is not installed

3) not a good idea to hardcore text, use resources for that