I am trying to open a web browser with a supplied url, however, after the last line of the following code, I get a null pointer exception. According to the call stack, Actvity.startActvitity(Intent) is where the exception occurs. This code is in a custom controller class for a sub view of the main activity. Any ideas on how to properly start the web browser via code, ideally from outside the main activity since I would to reuse as much as possible. or at least point me in the right direction.
private void showWebSite() {
String _url = (String) this.urlview.getText();
Activity webactivity = new Activity();
Intent webIntent = new Intent( Intent.ACTION_VIEW );
webIntent.setData( Uri.parse(_url) );
webactivity.startActivity( webIntent );
}
If you want it to be reusable create a static method like this