Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7517229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:22:44+00:00 2026-05-30T01:22:44+00:00

I’m trying to make an alert box that appears only when the app is

  • 0

I’m trying to make an alert box that appears only when the app is installed; I need the user to input their phone number before they are allowed to use the app. I have an alert dialog in my onCreate() method, but if the user taps outside of the alert box, it goes away. I’ve tried adding alert.setFinishOnTouchOutside(true) as you can see, but I get an error (Add cast to ‘Alert’). What do I need to do to stop the alert from cancelling if the user taps outside of the window? Thanks

    AlertDialog.Builder alert = new AlertDialog.Builder(this);

    alert.setTitle("Please Enter Your Phone Number");
    alert.setMessage("You must enter your phone number in order to use this application");
    alert.setFinishOnTouchOutside(true);

    // Set an EditText view to get user input 
    final EditText input = new EditText(this);
    alert.setView(input);

    alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
    public void onClick(DialogInterface dialog, int whichButton) {
    Editable value = input.getText();

     // Do something with value!
     }
    });
     alert.show();
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T01:22:45+00:00Added an answer on May 30, 2026 at 1:22 am

    I’m trying to make an alert box that appears only when the app is installed

    This is not possible. You do not get control at install time.

    I need the user to input their phone number before they are allowed to use the app.

    Then ask them for the value on the first run of your app, or if your desired data is not there (e.g., user cleared your app’s data).

    I have an alert dialog in my onCreate() method, but if the user taps outside of the alert box, it goes away.

    It will also go away if they press the BACK button.

    I’ve tried adding alert.setFinishOnTouchOutside(true) as you can see, but I get an error (Add cast to ‘Alert’)

    setFinishOnTouchOutside() is a method on Activity. It is not a method on AlertDialog.Builder.

    What do I need to do to stop the alert from cancelling if the user taps outside of the window?

    Call setCanceledOnTouchOutside() on the AlertDialog built by the Builder. This is not available on the Builder itself.

    Of course, it would be better if you did not use an AlertDialog in the first place, as your proposed UX is user-hostile.

    The user downloads and installs your app, opens it, and the first thing they encounter is a dialog box that they may not understand. And, your goal is that they cannot get to anything in your app that would actually explain:

    • What phone number? (home? work? mobile? sex line?)
    • What will the phone number be used for?
    • Will they be able to change the phone number?
    • Will they be able to set up multiple phone numbers?
    • Why should they honor your request in the first place? What do they get for providing you with such personal information?

    Instead of the dialog, if you detect, in onResume(), that you do not have the phone number, start up an activity to allow them to provide the number. Make use of the screen to explain a bit about why you need the number, and allow them to get to online help to explain matters further. Even if they BACK out of that activity, your original onResume() will fire again, so they cannot proceed further. An even better UX would be to allow them into the app, but disable things that require the phone number for use, just as you can open up Microsoft Word without being forced at gunpoint to load an existing Word doc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to clean up various Word 'smart' characters in user input, including but
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.