tags:

views:

22

answers:

2

Hello all,

I wanted to display an Alert Dialogue inside thread or alternatively such a way that AlertDialogue opens up directly after finding some records in database negative, w/o clicking on any button.. Alert dialogue may contain Few lines and 2-3 buttons..

referred following link and tried on my own but not getting how to create an AlertDialogue without using onClickListener as its working with it(onClickListener) very smoothly:

http://developer.android.com/guide/topics/ui/dialogs.html#CustomDialog

Thanks in Advance.

A: 

check out the below link http://developer.android.com/guide/topics/ui/dialogs.html ---> expand(click) on "Example ProgressDialog with a second thread". This will solve your problem.

Maneesh
I think i couldn't explain my question. Actually is it possible to pop up a Dialogue box with 3 buttons(ActivityDialog) ,on Splash Screen where no buttons are clicked??
Ankit
Alert Dialog is use to show Dialog where some event has to call the same. If you want to show splash screen as popup window , you need to open Activity class in pop up mode with timers inside it. Hope it wil solve your problem.
Maneesh
No brother, i have different problem, imagine my splash screen is running and in background gathering some information at the same time i wanted to pop up an Activity Dialogue which says sorry u haven't provided this information would u like to give it now.. so ultimately that dialogue will have some text and 3 buttons viz. positive, negative and say never.
Ankit
A solution code has been posted as answer. Hope will solve your problem.
Maneesh
A: 
public class jar_layut extends Activity {
    /** Called when the activity is first created. */
    boolean out=false;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        new Thread(new Runnable() 
        { public void run() 
        { 
            try {
                out=first_check_pic_on_device();

                mHandlerMySpace5.post(mUpdateResultsMySpace5);
            } catch (Exception e) {
                // TODO Auto-generated catch block
                mHandlerMySpace5.post(mUpdateResultsMySpace5);
            }

        }
      } ).start();
    }
    private boolean first_check_pic_on_device()
    {
         Context contextMySpace= this;;

        try {
            FileInputStream stream =contextMySpace.openFileInput("prf.png");

                  try {



                      return true;

                  } catch (Exception e) {
                        // TODO Auto-generated catch block

                      return false;
                    }
        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            return false;
        }
    }
    final Handler mHandlerMySpace5 = new Handler();

    final Runnable mUpdateResultsMySpace5 = new Runnable() {
        public void run() {
            if(!out)
            {
                showDialog();
            }

        }
    };
    private void showDialog()
    {

         final CharSequence[] items = {"one", "two"};
        AlertDialog.Builder builder = new AlertDialog.Builder(this);

            builder.setSingleChoiceItems(items, -1, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int item) {

                    if(item==0)
                    {


                    }
                    if(item==1)
                    {

                    }
                }
            });
            AlertDialog alert = builder.create();
            alert.show();

    }
}
Maneesh
Thank u very much Maneesh. It works..
Ankit