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 5936009
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:20:15+00:00 2026-05-22T15:20:15+00:00

I am looking for a way to pass data from an activity onto a

  • 0

I am looking for a way to pass data from an activity onto a dialog box. I am trying to call showDialog(int);, however i don’t see a way to pass any data to the dialog box.
I need to pass a string to the dialog box in order to display a confirmation 🙂

Cheers

  • 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-22T15:20:16+00:00Added an answer on May 22, 2026 at 3:20 pm

    If you are targeting Android 2.2 (API Level 8 or higher) you can use

     public final boolean showDialog (int id, Bundle args)
    

    And pass your arguments in Bundle. See documentation.

    If you want to support older Android versions, you should save your arguments in Activity class members and then access them from your onPrepareDialog function. Note that onCreateDialog won’t fit your needs as it’s called only once for dialog creation.

    class MyActivity {
    
        private static int MY_DLG = 1;
        private String m_dlgMsg;
    
        private showMyDialog(String msg){
            m_dlgMsg = msg;
            showDialog(MY_DLG);
        }
    
        private doSomething() {
            ...
            showMyDlg("some text");
        }
    
        protected void onCreateDialog(int id){
            if(id == MY_DLG){
                AlertDialog.Builder builder = new AlertDialog.Builder(this); 
                ....
                return builder.create();
             }
             return super.onCreateDialog(id);
        }        
    
        @Override
        protected void onPrepareDialog (int id, Dialog dialog){ 
             if(id == MY_DLG){ 
                AlertDialog adlg = (AlertDialog)dialog;
                adlg.setMessage(m_dlgMsg);
             } else {
                super.onPrepareDialog(id, dialog);
             }             
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to pass data to my app upon install from a
I'm looking for the best practice on how to pass data from page to
I am looking forward for a method to pass data from page to page
I'm trying to pass data from tab n to tab n+1 activities, based on
I am looking for a way to pass NumPy arrays to Matlab. I've managed
I'm looking for a way to pass different options as a parameter to a
I am looking for a way to pass an object ( vector<long> in my
I am looking for a way to pass a string containg the * character
I'm looking for a way to pass a variable or string or anything into
im looking for a way to print the array as is after each pass.

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.