Last active
August 29, 2015 14:14
-
-
Save SelvinPL/26264c9468830fcbde4e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.app.Activity; | |
import android.content.Context; | |
import android.content.Intent; | |
import android.net.Uri; | |
import android.os.Bundle; | |
public class TestActivity extends Activity { | |
//well context is not valid yet, but we will use later so it is ok to use "this" | |
private Helper helper = new Helper(this); | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
//this method is using context ... but we are in onCreate so will work | |
helper.startBrowser(); | |
} | |
private static class Helper { | |
Context mContext; | |
public Helper(Context context) { | |
mContext = context; | |
} | |
public void startBrowser() { | |
final Intent intent = new Intent(Intent.ACTION_VIEW); | |
intent.setData(Uri.parse("http://google.com")); | |
mContext.startActivity(intent); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment