Reputation: 1332
I am using DialogPreference in my program, now i want to Redirect to webpage while click on OK Button using DialogPreference.
Preferences.xml:-
<com.chr.tatu.sample.friendslist.contacts.TimePickerPreferences
android:defaultValue=""
android:key="about"
android:summary="Summary"
android:title="Title"
android:negativeButtonText="@null" />
TimePickerPreferences.java:-
public class TimePickerPreferences extends DialogPreference
{
public TimePickerPreferences(Context context, AttributeSet attrs) {
super(context, attrs);
}
public TimePickerPreferences(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
}
Upvotes: 1
Views: 257
Reputation: 957
Try this code:
@Override
public void onClick(DialogInterface dialog,
int button) {
if (button == Dialog.BUTTON_POSITIVE)
{Intent myWebLink = new Intent(android.content.Intent.ACTION_VIEW);
myWebLink.setData(Uri.parse("http://www.google.com"));
startActivity(myWebLink);
}
}
Upvotes: 1