0

I have this dialog fragment, but i'm trying to get it so that when a user clicks on the "My Other Apps" Button they get redirected to a web address. Is there any way of doing this. Any help is appreciated Thanks

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // TODO Auto-generated method stub

    AlertDialog.Builder theDialog = new AlertDialog.Builder(getActivity());
    theDialog.setTitle("About");
    String d1 = "Thanks For Downloading! ";
    String d2 = "Made by ME";
    theDialog.setMessage(d1 +"\n"+ d2 ); 
    theDialog.setPositiveButton("My Other Apps", new DialogInterface.OnClickListener(){


        @Override
        public void onClick(DialogInterface dialog, int which) {
            Toast.makeText(getActivity(), "Clicked My Other Apps",
                    Toast.LENGTH_SHORT).show();

        }

    });

    theDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener(){

        @Override
        public void onClick(DialogInterface dialog, int which) {
            Toast.makeText(getActivity(), "Clicked Cancel",
                    Toast.LENGTH_SHORT).show();

        }

    });     
    return theDialog.create();
  }
}       
1
  • a little research before posting please Commented Nov 12, 2014 at 21:03

2 Answers 2

0
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
// TODO Auto-generated method stub

AlertDialog.Builder theDialog = new AlertDialog.Builder(getActivity());
theDialog.setTitle("About");
String d1 = "Thanks For Downloading! ";
String d2 = "Made by ME";
theDialog.setMessage(d1 +"\n"+ d2 ); 
theDialog.setPositiveButton("My Other Apps", new DialogInterface.OnClickListener(){


@Override
public void onClick(DialogInterface dialog, int which) {
    String url = "http://www.example.com";
    Intent i = new Intent(Intent.ACTION_VIEW);
    i.setData(Uri.parse(url));
    startActivity(i);

}

});

theDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener(){

@Override
public void onClick(DialogInterface dialog, int which) {
    Toast.makeText(getActivity(), "Clicked Cancel",
    Toast.LENGTH_SHORT).show();

}

});     
return theDialog.create();
}
} 
Sign up to request clarification or add additional context in comments.

Comments

0

Do this on your button click:

 @Override
 public void onClick(DialogInterface dialog, int which) {
     String url = "http://www.example.com";
     Intent i = new Intent(Intent.ACTION_VIEW);
     i.setData(Uri.parse(url));
     startActivity(i);

 }

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.