Hi Guys!
Today I am going to share the code for open web browser by action view in android.
In this article we will create an application which will open a user input website in a web browser. In order to open a web browser, we will create an intent object with ACTION_VIEW as action and data with �http� in the url. Since http request is invoked by the external browser, no explicit permission is needed for this application.
Today I am going to share the code for open web browser by action view in android.
In this article we will create an application which will open a user input website in a web browser. In order to open a web browser, we will create an intent object with ACTION_VIEW as action and data with �http� in the url. Since http request is invoked by the external browser, no explicit permission is needed for this application.
activity_main.xml
MainActivity.java
package com.sunil.browserview;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
public class MainActivity extends Activity implements OnClickListener{
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button btn = (Button) findViewById(R.id.btn_browse);
btn.setOnClickListener(this);
}
@Override
public void onClick(View v) {
EditText txt = (EditText) findViewById(R.id.te_url);
Intent intent = new Intent("android.intent.action.VIEW");
Uri data = Uri.parse("http://"+txt.getText().toString());
intent.setData(data);
startActivity(intent);
}
}
Update Contact :
No Wa/Telepon (puat) : 085267792168
No Wa/Telepon (fajar) : 085369237896
Email : Fajarudinsidik@gmail.com
No Wa/Telepon (puat) : 085267792168
No Wa/Telepon (fajar) : 085369237896
Email: Fajarudinsidik@gmail.com
atau Kirimkan Private messanger melalui email dengan klik tombol order dibawah ini :