So I'm making a app that views certain surveys on the device, but the thing is that the device doesn't want to load the webview. How would I go about changing the button to instead open the survey link in google?
Asked
Active
Viewed 178 times
-6
-
`in google` Google Chrome you mean? – Vladyslav Matviienko Nov 20 '18 at 09:44
-
Yeah- the default web browser for android – Joseph Siccita Nov 20 '18 at 09:45
-
So basically you want to open a specific website when button is clicked? – Nero Nov 20 '18 at 09:45
-
Yes- but externally to the app – Joseph Siccita Nov 20 '18 at 09:45
-
always remember that you have to use search before asking a question. – Vladyslav Matviienko Nov 20 '18 at 09:46
2 Answers
0
Button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.addCategory(Intent.CATEGORY_BROWSABLE);
intent.setData(Uri.parse("http://www.yourURL.com"));
startActivity(intent);
}
});

V-rund Puro-hit
- 5,518
- 9
- 31
- 50

Manish Ahire
- 550
- 4
- 19
0
On Button click (onClick) set this event:
Uri link = Uri.parse("http://www.yourwebsite.xx");
Intent intent = new Intent(Intent.ACTION_VIEW, link);
startActivity(intent);
This will open you URL.

arst3k
- 976
- 2
- 8
- 18