use of android.app.AlertDialog.Builder in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ShortcutPickHelper method processShortcut.
private void processShortcut(final Intent intent, int requestCodeApplication, int requestCodeShortcut) {
// Handle case where user selected "Applications"
String applicationName = mParent.getString(R.string.profile_applist_title);
String application2name = mParent.getString(R.string.picker_activities);
String shortcutName = intent.getStringExtra(Intent.EXTRA_SHORTCUT_NAME);
if (applicationName != null && applicationName.equals(shortcutName)) {
Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
Intent pickIntent = new Intent(Intent.ACTION_PICK_ACTIVITY);
pickIntent.putExtra(Intent.EXTRA_INTENT, mainIntent);
startFragmentOrActivity(pickIntent, requestCodeApplication);
} else if (application2name != null && application2name.equals(shortcutName)) {
final List<PackageInfo> pInfos = mPackageManager.getInstalledPackages(PackageManager.GET_ACTIVITIES);
ExpandableListView appListView = new ExpandableListView(mParent);
AppExpandableAdapter appAdapter = new AppExpandableAdapter(pInfos, mParent);
appListView.setAdapter(appAdapter);
appListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
@Override
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
Intent shortIntent = new Intent(Intent.ACTION_MAIN);
String pkgName = ((GroupInfo) parent.getExpandableListAdapter().getGroup(groupPosition)).info.packageName;
String actName = ((GroupInfo) parent.getExpandableListAdapter().getGroup(groupPosition)).info.activities[childPosition].name;
shortIntent.setClassName(pkgName, actName);
completeSetCustomApp(shortIntent);
mAlertDialog.dismiss();
return true;
}
});
Builder builder = new Builder(mParent);
builder.setView(appListView);
mAlertDialog = builder.create();
mAlertDialog.setTitle(mParent.getString(R.string.select_custom_activity_title));
mAlertDialog.show();
mAlertDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
mListener.shortcutPicked(null, null, false);
}
});
} else {
startFragmentOrActivity(intent, requestCodeShortcut);
}
}
use of android.app.AlertDialog.Builder in project android-app-common-tasks by multidots.
the class Util method showAlert.
/**
* Display a simple alert dialog with the given text and title.
*
* @param context Android context in which the dialog should be displayed
* @param title Alert dialog title
* @param text Alert dialog message
*/
public static void showAlert(Context context, String title, String text) {
Builder alertBuilder = new Builder(context);
alertBuilder.setTitle(title);
alertBuilder.setMessage(text);
alertBuilder.create().show();
}
use of android.app.AlertDialog.Builder in project ABPlayer by winkstu.
the class MainActivity method show_existDialog.
private void show_existDialog() {
// 弹出退出对话框
Builder dialog = new AlertDialog.Builder(MainActivity.this).setMessage("您确定要退出吗?").setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface arg0, int arg1) {
// 退出程序
finish();
}
}).setNegativeButton("支持我", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface arg0, int arg1) {
SpotManager.getInstance(MainActivity.this).showSpotAds(MainActivity.this, new SpotDialogListener() {
@Override
public void onShowSuccess() {
Log.i("YoumiAdDemo", "展示成功");
}
@Override
public void onShowFailed() {
Log.i("YoumiAdDemo", "展示失败");
}
@Override
public void onSpotClosed() {
Log.i("YoumiAdDemo", "展示关闭");
}
});
}
});
dialog.show();
}
use of android.app.AlertDialog.Builder in project generic-oauth2-login-for-android by wareninja.
the class Utils method showAlert.
/**
* Parse a server response into a JSON Object. This is a basic
* implementation using org.json.JSONObject representation. More
* sophisticated applications may wish to do their own parsing.
*
* The parsed JSON is checked for a variety of error fields and
* a FacebookException is thrown if an error condition is set,
* populated with the error message and error type or code if
* available.
*
* @param response - string representation of the response
* @return the response as a JSON Object
* @throws JSONException - if the response is not valid JSON
* @throws FacebookError - if an error condition is set
*/
/*public static JSONObject parseJson(String response)
throws JSONException, FacebookError {
// Edge case: when sending a POST request to /[post_id]/likes
// the return value is 'true' or 'false'. Unfortunately
// these values cause the JSONObject constructor to throw
// an exception.
if (response.equals("false")) {
throw new FacebookError("request failed");
}
if (response.equals("true")) {
response = "{value : true}";
}
JSONObject json = new JSONObject(response);
// errors set by the server are not consistent
// they depend on the method and endpoint
if (json.has("error")) {
JSONObject error = json.getJSONObject("error");
throw new FacebookError(
error.getString("message"), error.getString("type"), 0);
}
if (json.has("error_code") && json.has("error_msg")) {
throw new FacebookError(json.getString("error_msg"), "",
Integer.parseInt(json.getString("error_code")));
}
if (json.has("error_code")) {
throw new FacebookError("request failed", "",
Integer.parseInt(json.getString("error_code")));
}
if (json.has("error_msg")) {
throw new FacebookError(json.getString("error_msg"));
}
if (json.has("error_reason")) {
throw new FacebookError(json.getString("error_reason"));
}
return json;
}*/
/**
* Display a simple alert dialog with the given text and title.
*
* @param context
* Android context in which the dialog should be displayed
* @param title
* Alert dialog title
* @param text
* Alert dialog message
*/
public static void showAlert(Context context, String title, String text) {
Builder alertBuilder = new Builder(context);
alertBuilder.setTitle(title);
alertBuilder.setMessage(text);
alertBuilder.create().show();
}
use of android.app.AlertDialog.Builder in project WordPress-Android by wordpress-mobile.
the class MediaGridFragment method handleMultiSelectDelete.
private void handleMultiSelectDelete() {
if (!isAdded()) {
return;
}
Builder builder = new AlertDialog.Builder(getActivity()).setMessage(R.string.confirm_delete_multi_media).setCancelable(true).setPositiveButton(R.string.delete, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (getActivity() instanceof MediaBrowserActivity) {
((MediaBrowserActivity) getActivity()).deleteMedia(mGridAdapter.getSelectedItems());
}
// update upload state
for (int itemId : mGridAdapter.getSelectedItems()) {
MediaModel media = mMediaStore.getMediaWithLocalId(itemId);
media.setUploadState(MediaUploadState.DELETE.name());
mDispatcher.dispatch(MediaActionBuilder.newUpdateMediaAction(media));
}
mGridAdapter.clearSelection();
if (mActionMode != null) {
mActionMode.finish();
}
refreshMediaFromDB();
refreshSpinnerAdapter();
}
}).setNegativeButton(R.string.cancel, null);
AlertDialog dialog = builder.create();
dialog.show();
}
Aggregations