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();
  }
}       
Darragh O'Flaherty
  • 995
  • 3
  • 13
  • 30

2 Answers2

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);

 }
Lukos
  • 712
  • 4
  • 5
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();
}
} 
Galax
  • 367
  • 1
  • 13