我想从asynctask中打开onpostexecute中的浏览器。但是在开始我的活动时我得到了一个nullpointerexception:
我的代码:
@Override
protected void onPostExecute(String file_url) {
AlertDialog alertDialog = new AlertDialog.Builder(context).create();
alertDialog.setTitle("Details");
ScrollView scrollview = new ScrollView(context);
LinearLayout lila1= new LinearLayout(context);
lila1.setOrientation(1); //1 is for vertical orientation;
lila1.setBackgroundColor(android.graphics.Color.BLACK);
scrollview.setBackgroundColor(android.graphics.Color.BLACK);
final Button adv1 = new Button(context);
adv1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Uri uriUrl = Uri.parse("http://androidbook.blogspot.com/");
Intent launchBrowser = new Intent(Intent.ACTION_VIEW, uriUrl);
startActivity(launchBrowser); //<- does not work
}
});
lila1.addView(adv1);