Example usage for android.app AlertDialog setTitle

List of usage examples for android.app AlertDialog setTitle

Introduction

In this page you can find the example usage for android.app AlertDialog setTitle.

Prototype

@Override
    public void setTitle(CharSequence title) 

Source Link

Usage

From source file:org.wahtod.wififixer.ui.MainActivity.java

public void showServiceAlert() {
    final Context c;
    c = this;//from w  w  w. j  a va  2s . com
    AlertDialog alert = new AlertDialog.Builder(c).create();
    alert.setTitle(getString(R.string.note));
    alert.setIcon(R.drawable.icon);
    alert.setMessage(getString(R.string.servicealert_message));
    alert.setButton(AlertDialog.BUTTON_POSITIVE, getString(R.string.ok_button),
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    PrefUtil.writeBoolean(c, PrefConstants.SERVICEWARNED, true);
                }
            });
    alert.show();
}

From source file:com.ubundude.timesheet.MainActivity.java

/**
 * Checks for an updated version of the app
 *
 * If there is an updated version, an Alert dialog is displayed
 * to advise the user to download the latest version
 *
 * @throws NameNotFoundException/*from   ww w  .j  a  v  a  2 s .  com*/
 * @throws IOException
 * @throws InterruptedException
 * @throws ExecutionException
 */
@SuppressWarnings("deprecation")
private void updateCheck() throws NameNotFoundException, IOException, InterruptedException, ExecutionException {
    /** String to store the version from the url */
    String urlVersion;

    /** Get instance of UpdateCheck.java and get the version returned from it */
    UpdateCheck check = new UpdateCheck();
    urlVersion = check.execute().get();

    /** Get the currently running version of the app for comparision */
    PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
    String packageVersion = pInfo.versionName;

    Log.d("Package Version", packageVersion);

    /** Builds an alert dialog to let the user know that they need to upgrade */
    if (!urlVersion.equals(packageVersion)) {
        AlertDialog alert = new AlertDialog.Builder(this).create();
        alert.setTitle("Version Check");
        alert.setMessage("You're version is out of date. Please visit "
                + "www.ubundude.com/p/beta.html to update to the latest version.");

        alert.setButton("OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
            }
        });
        alert.show();
    }
}

From source file:com.technologx.firebirddesigns.MainInterface.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.bottom_interface);

    View main = findViewById(R.id.main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        if (main != null) {
            main.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
        }/*from  w  w w .j  a  va 2  s.com*/
    }

    AppCompatActivity activity = this;
    activity.setSupportActionBar(toolbar);
    activity.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    activity.getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_menu_toolbar);
    activity.getSupportActionBar().setTitle("Fire Bird Designs");
    activity.getSupportActionBar().setSubtitle("News, Content and More");

    UpdateChecker checker = new UpdateChecker(this);
    UpdateChecker.setStore(Store.GOOGLE_PLAY);
    UpdateChecker.setNoticeIcon(R.mipmap.ic_launcher);
    UpdateChecker.start();

    result = new DrawerBuilder(this).withToolbar(toolbar).withDisplayBelowStatusBar(false)
            .withTranslucentStatusBar(false).withActionBarDrawerToggleAnimated(true)
            .withDrawerLayout(R.layout.material_drawer_fits_not).withHeader(R.layout.settings_header)
            .addDrawerItems(new SectionDrawerItem().withName("Application"),
                    new PrimaryDrawerItem().withName("Notifications").withIdentifier(1),
                    new PrimaryDrawerItem().withName("Homepage").withIdentifier(2),
                    new ExpandableDrawerItem().withName("More").withSubItems(
                            new PrimaryDrawerItem().withName("Settings").withIdentifier(3),
                            new PrimaryDrawerItem().withName("License").withIdentifier(4),
                            new PrimaryDrawerItem().withName("Contact").withIdentifier(5)))
            .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
                @Override
                public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
                    long id = drawerItem.getIdentifier();
                    if (id == 1) {
                        Intent intent = new Intent(MainInterface.this, NewsfeedActivity.class);
                        startActivity(intent);
                    } else if (id == 2) {
                        Intent intent = new Intent(MainInterface.this, WebViewActivity.class);
                        startActivity(intent);
                    } else if (id == 3) {
                        Intent intent = new Intent(MainInterface.this, SettingsActivity.class);
                        startActivity(intent);
                    } else if (id == 4) {
                        new LicensesDialog.Builder(MainInterface.this).setNotices(R.raw.licenses).build()
                                .show();

                    } else if (id == 5) {
                        AlertDialog alertDialog = new AlertDialog.Builder(MainInterface.this).create();
                        alertDialog.setTitle(getResources().getString(R.string.feedback_title));
                        alertDialog.setMessage(getResources().getString(R.string.feedback_summary));
                        alertDialog.setButton(DialogInterface.BUTTON_POSITIVE,
                                getResources().getString(R.string.email),
                                new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dialog, int which) {
                                        sendEmail();
                                    }
                                });
                        alertDialog.setButton(DialogInterface.BUTTON_NEUTRAL,
                                getResources().getString(R.string.hangout),
                                new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dialog, int which) {
                                        startHangout();
                                    }
                                });
                        alertDialog.setButton(DialogInterface.BUTTON_NEGATIVE,
                                getResources().getString(android.R.string.cancel),
                                new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dialog, int which) {
                                    }
                                });
                        alertDialog.show();
                    }

                    return false;
                }
            }).withSavedInstance(savedInstanceState).build();

    // Setup the viewPager
    ViewPager viewPager = (ViewPager) findViewById(R.id.view_pager);
    MyPagerAdapter pagerAdapter = new MyPagerAdapter(getSupportFragmentManager());
    viewPager.setAdapter(pagerAdapter);
    viewPager.setCurrentItem(1);
    viewPager.setPageTransformer(false, new ViewPager.PageTransformer() {
        @Override
        public void transformPage(View page, float position) {
            final float normalizedposition = Math.abs(Math.abs(position) - 1);
            page.setAlpha(normalizedposition);
        }
    });

    mTabLayout = (TabLayout) findViewById(R.id.tab_layout);
    if (mTabLayout != null) {
        mTabLayout.setupWithViewPager(viewPager);

        for (int i = 0; i < mTabLayout.getTabCount(); i++) {
            TabLayout.Tab tab = mTabLayout.getTabAt(i);
            if (tab != null)
                tab.setCustomView(pagerAdapter.getTabView(i));
        }

        mTabLayout.getTabAt(0).getCustomView().setSelected(true);
    }
}

From source file:org.wahtod.wififixer.ui.MainActivity.java

private void phoneTutNag() {
    AlertDialog dialog = new AlertDialog.Builder(this).create();
    dialog.setTitle(getString(R.string.phone_ui_tutorial));
    dialog.setMessage(getString(R.string.phone_tutorial_q));
    dialog.setIcon(R.drawable.icon);//from ww  w .j av a 2s  .  com
    dialog.setButton(AlertDialog.BUTTON_POSITIVE, getString(R.string.ok_button),
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    runTutorial();
                }
            });

    dialog.setButton(AlertDialog.BUTTON_NEGATIVE, getString(R.string.later_button),
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    PrefUtil.writeBoolean(self.get(), PrefConstants.TUTORIAL, true);
                }
            });
    dialog.show();
}

From source file:com.bangalore.barcamp.activity.WebViewActivity.java

protected Dialog onCreateDialog(int id) {
    AlertDialog alertDialog = new AlertDialog.Builder(this).create();
    switch (id) {
    case SHOW_ERROR_DIALOG:
        alertDialog.setCancelable(false);
        alertDialog.setTitle(getString(R.string.error_title));
        alertDialog.setMessage(getString(R.string.connection_error_and_try_again));
        alertDialog.setButton(getString(R.string.ok), new DialogInterface.OnClickListener() {

            @Override/* www  .  j a  v a2 s.  c  o m*/
            public void onClick(DialogInterface dialog, int which) {
                dismissDialog(SHOW_ERROR_DIALOG);
                WebViewActivity.this.finish();
            }
        });
        break;
    }
    return alertDialog;
}

From source file:org.uclab.mm.sl.uiux.uiuxanalyticsdemo.MainActivity.java

public void userFeedback() {
    AlertDialog userfeedback = new AlertDialog.Builder(this).create();

    // Setting Dialog Title
    userfeedback.setTitle("Feedback");

    // Setting Icon to Dialog
    userfeedback.setIcon(R.drawable.ic_feedback_black_18dp);

    LayoutInflater inflater = this.getLayoutInflater();

    // Inflate and set the layout for the dialog
    // Pass null as the parent view because its going in the dialog layout
    userfeedback.setView(inflater.inflate(R.layout.feedback, null));

    // Setting OK Button
    userfeedback.setButton("Send", new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int which) {
            // Write your code here to execute after dialog
            // closed
            Toast.makeText(getApplicationContext(), "Your Feedback sent Successfully", Toast.LENGTH_SHORT)
                    .show();/*from  w  w w  .  ja  va2  s .c om*/
        }
    });

    // Showing Alert Message
    userfeedback.show();
}

From source file:com.janela.mobile.ui.repo.RepositoryListFragment.java

@Override
public boolean onListItemLongClick(ListView list, View v, int position, long itemId) {
    if (!isUsable())
        return false;

    final Repository repo = (Repository) list.getItemAtPosition(position);
    if (repo == null)
        return false;

    final AlertDialog dialog = LightAlertDialog.create(getActivity());
    dialog.setCanceledOnTouchOutside(true);

    dialog.setTitle(repo.generateId());

    View view = getActivity().getLayoutInflater().inflate(R.layout.repo_dialog, null);
    ViewFinder finder = new ViewFinder(view);

    final User owner = repo.getOwner();
    avatars.bind(finder.imageView(R.id.iv_owner_avatar), owner);
    finder.setText(R.id.tv_owner_name, getString(R.string.navigate_to_user, owner.getLogin()));
    finder.onClick(R.id.ll_owner_area, new OnClickListener() {

        public void onClick(View v) {
            dialog.dismiss();/*from   w  ww .ja v a2 s . c o  m*/

            viewUser(owner);
        }
    });

    if ((recentRepos != null) && (recentRepos.contains(repo))) {
        finder.find(R.id.divider).setVisibility(View.VISIBLE);
        finder.find(R.id.ll_recent_repo_area).setVisibility(View.VISIBLE);
        finder.onClick(R.id.ll_recent_repo_area, new OnClickListener() {

            public void onClick(View v) {
                dialog.dismiss();

                recentRepos.remove(repo);
                refresh();
            }
        });
    }

    dialog.setView(view);
    dialog.show();

    return true;
}

From source file:com.github.mobile.ui.repo.RepositoryListFragment.java

@Override
public boolean onListItemLongClick(ListView list, View v, int position, long itemId) {
    if (!isUsable())
        return false;

    final Repository repo = (Repository) list.getItemAtPosition(position);
    if (repo == null)
        return false;

    final AlertDialog dialog = LightAlertDialog.create(getActivity());
    dialog.setCanceledOnTouchOutside(true);

    dialog.setTitle(repo.generateId());

    View view = getActivity().getLayoutInflater().inflate(layout.repo_dialog, null);
    ViewFinder finder = new ViewFinder(view);

    final User owner = repo.getOwner();
    avatars.bind(finder.imageView(id.iv_owner_avatar), owner);
    finder.setText(id.tv_owner_name, getString(string.navigate_to_user, owner.getLogin()));
    finder.onClick(id.ll_owner_area, new OnClickListener() {

        public void onClick(View v) {
            dialog.dismiss();//  w ww .j a  va2 s .c  om

            viewUser(owner);
        }
    });

    if ((recentRepos != null) && (recentRepos.contains(repo))) {
        finder.find(id.divider).setVisibility(View.VISIBLE);
        finder.find(id.ll_recent_repo_area).setVisibility(View.VISIBLE);
        finder.onClick(id.ll_recent_repo_area, new OnClickListener() {

            public void onClick(View v) {
                dialog.dismiss();

                recentRepos.remove(repo);
                refresh();
            }
        });
    }

    dialog.setView(view);
    dialog.show();

    return true;
}

From source file:com.glanznig.beepme.view.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    BeeperApp app = (BeeperApp) getApplication();

    switch (item.getItemId()) {
    case R.id.action_toggle_beeper:
        if (app.isBeeperActive()) {
            app.cancelTimer(); //call before setBeeperActive
            app.setBeeperActive(BeeperApp.BEEPER_INACTIVE);
            item.setIcon(R.drawable.ic_menu_beeper_off);

            // hide generate beep menu entry
            if (this.actionMenu != null && app.getPreferences().isTestMode()) {
                MenuItem testBeep = actionMenu.findItem(R.id.action_test_beep);
                testBeep.setVisible(false);
            }/*from   ww w  . ja v a2s. c o  m*/
        } else {
            app.setBeeperActive(BeeperApp.BEEPER_ACTIVE);
            app.setTimer();
            item.setIcon(R.drawable.ic_menu_beeper_on);

            // show generate beep menu entry
            if (this.actionMenu != null && app.getPreferences().isTestMode()) {
                MenuItem testBeep = actionMenu.findItem(R.id.action_test_beep);
                testBeep.setVisible(true);
            }
        }

        return true;

    case R.id.action_test_beep:
        app.beep();
        return true;

    case R.id.action_export:
        Intent iExport = new Intent(this, ExportActivity.class);
        startActivity(iExport);
        return true;

    case R.id.action_settings:
        Intent iSettings = new Intent(this, SettingsActivity.class);
        startActivity(iSettings);
        return true;

    case R.id.action_about:

        // thanks to F-Droid for the inspiration
        View view = null;
        LayoutInflater inflater = LayoutInflater.from(this);
        view = inflater.inflate(R.layout.about, null);

        try {
            PackageInfo pkgInfo = getPackageManager().getPackageInfo(getApplicationContext().getPackageName(),
                    0);
            ((TextView) view.findViewById(R.id.about_version)).setText(pkgInfo.versionName);
        } catch (Exception e) {
        }

        AlertDialog.Builder alertBuilder = null;
        alertBuilder = new AlertDialog.Builder(this).setView(view);

        AlertDialog dia = alertBuilder.create();
        dia.setIcon(R.drawable.ic_launcher_beepme);
        dia.setTitle(getString(R.string.about_title));
        dia.setButton(AlertDialog.BUTTON_NEUTRAL, getString(R.string.about_donate_button),
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int whichButton) {
                        Uri uri = Uri.parse("http://beepme.yourexp.at/support-beepme");
                        startActivity(new Intent(Intent.ACTION_VIEW, uri));
                    }
                });

        dia.setButton(AlertDialog.BUTTON_NEGATIVE, getString(android.R.string.ok),
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int whichButton) {
                    }
                });
        dia.show();
        return true;
    }
    return super.onOptionsItemSelected(item);
}

From source file:edu.rutgers.winlab.crowdpp.ui.MainActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main_activity_layout);

    // Create the adapter that will return a fragment for each of the three primary sections of the app.
    mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager());

    // Set up the action bar.
    final ActionBar actionBar = getActionBar();

    // Specify that the Home/Up button should not be enabled, since there is no hierarchical parent.
    actionBar.setHomeButtonEnabled(false);

    // Specify that we will be displaying tabs in the action bar.
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // Set up the ViewPager, attaching the adapter and setting up a listener for when the user swipes between sections.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mAppSectionsPagerAdapter);
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override/*from w  w  w .ja  v  a 2  s  .c  o  m*/
        public void onPageSelected(int position) {
            // When swiping between different app sections, select the corresponding tab.
            // We can also use ActionBar.Tab#select() to do this if we have a reference to the Tab.
            actionBar.setSelectedNavigationItem(position);
        }
    });

    // For each of the sections in the app, add a tab to the action bar.
    for (int i = 0; i < mAppSectionsPagerAdapter.getCount(); i++) {
        // Create a tab with text corresponding to the page title defined by the adapter.
        // Also specify this Activity object, which implements the TabListener interface, as the listener for when this tab is selected.
        actionBar.addTab(
                actionBar.newTab().setText(mAppSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }

    SharedPreferences settings = this.getSharedPreferences("config", Context.MODE_PRIVATE);
    ;
    SharedPreferences.Editor editor = settings.edit();

    // load the default parameters into SharedPreferences for the first time launch 
    int ct = settings.getInt("count", 0);
    if (ct == 0) {
        editor.putString("start", "9");
        editor.putString("end", "21");
        editor.putString("interval", "15");
        editor.putString("duration", "5");
        editor.putString("location", "On");
        editor.putString("upload", "On");
        TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
        editor.putString("IMEI", tm.getDeviceId());
        editor.putString("brand", Build.BRAND);
        editor.putString("model", Build.MODEL);
        String phone_type = Build.BRAND + "_" + Build.MODEL;

        // motoX
        if (phone_type.equals("motorola_XT1058")) {
            editor.putString("mfcc_dist_same_semi", "13");
            editor.putString("mfcc_dist_diff_semi", "18");
            editor.putString("mfcc_dist_same_un", "13");
            editor.putString("mfcc_dist_diff_un", "18");
        }
        // nexus 4
        else if (phone_type.equals("google_Nexus 4")) {
            editor.putString("mfcc_dist_same_semi", "17");
            editor.putString("mfcc_dist_diff_semi", "22");
            editor.putString("mfcc_dist_same_un", "17");
            editor.putString("mfcc_dist_diff_un", "22");
        }
        // s2
        else if (phone_type.equals("samsung_SAMSUNG-SGH-I727")) {
            editor.putString("mfcc_dist_same_semi", "18");
            editor.putString("mfcc_dist_diff_semi", "25");
            editor.putString("mfcc_dist_same_un", "18");
            editor.putString("mfcc_dist_diff_un", "25");
        }
        // s3 
        else if (phone_type.equals("samsung_SAMSUNG-SGH-I747")) {
            editor.putString("mfcc_dist_same_semi", "16");
            editor.putString("mfcc_dist_diff_semi", "21");
            editor.putString("mfcc_dist_same_un", "16");
            editor.putString("mfcc_dist_diff_un", "21");
        }
        // s4
        else if (phone_type.equals("samsung_SAMSUNG-SGH-I337")) {
            editor.putString("mfcc_dist_same_semi", "14");
            editor.putString("mfcc_dist_diff_semi", "24");
            editor.putString("mfcc_dist_same_un", "14");
            editor.putString("mfcc_dist_diff_un", "24");
        }
        // other devices
        else {
            editor.putString("mfcc_dist_same_semi", "15.6");
            editor.putString("mfcc_dist_diff_semi", "21.6");
            editor.putString("mfcc_dist_same_un", "15.6");
            editor.putString("mfcc_dist_diff_un", "21.6");
            Toast.makeText(this, "Your device is not recognized and the result might not be accurate...",
                    Toast.LENGTH_SHORT).show();
        }
        Log.i("Crowd++", "First time launched");

        AlertDialog dialog = new AlertDialog.Builder(this).create();
        dialog.setTitle("Welcome to Crowd++");
        dialog.setMessage(Constants.hello_msg);
        dialog.setButton(AlertDialog.BUTTON_POSITIVE, "Close", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {

            }
        });
        dialog.show();
        dialog.getButton(DialogInterface.BUTTON_POSITIVE).setTextSize(20);
    }

    editor.putInt("count", ++ct);
    editor.commit();
    Log.i("Launched Count", Integer.toString(ct));
    mConst = new Constants(this);
    if (!Constants.calibration())
        Toast.makeText(this, "You haven't calibrated the system.", Toast.LENGTH_SHORT).show();
}