Skip to content

Instantly share code, notes, and snippets.

@nagendrababu143
Created August 15, 2018 04:34
Show Gist options
  • Save nagendrababu143/290757194783092421657ecbd0672787 to your computer and use it in GitHub Desktop.
Save nagendrababu143/290757194783092421657ecbd0672787 to your computer and use it in GitHub Desktop.
package com.example.nagendra.intentexample;
import android.content.Intent;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
public class MainActivity extends AppCompatActivity {
EditText editText;
Button button;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
editText = (EditText)findViewById(R.id.edittext);
button = (Button)findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String url = editText.getText().toString().trim();
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(intent);
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment