简体   繁体   中英

android studio ethereum wallet loading message

I am doing an app that creates an ethereum wallet and send some ether when you touch the button register, it takes about 1 minute to do this, while it happens I want to show a message saying: Creating a wallet, wait please.

When I show the message it won't create the wallet or it will create the wallet but it won't show the message.

PS: If someone knows how to down the time to do this, it will help me a lot.

Thanks

thanks for the help... and the negative.

I have solved it anyway, I leave my solution below:

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

    errorMsg = new AlertDialog.Builder(this);

    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            new MyAsyncTasks().execute();
        }
    });

}

class MyAsyncTasks extends AsyncTask<Void, Void, String> {

   // ProgressDialog dialog;
    @Override

    //It will show a message during your background
    protected void onPreExecute() {
        dialog = new ProgressDialog(mainActivity.this);
        dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
        dialog.setTitle("Add title");
        dialog.setMessage("Add message");
        dialog.setIndeterminate(true);
        dialog.setCanceledOnTouchOutside(false);
        dialog.show();
    }

    @Override
    protected void onPostExecute() {

        dialog.dismiss(); // Close the Dialog
        //Show a window with error or operation succesfully
        if(hash.equals("Error")){
            displayError("Error", "Error");
            dialog.cancel();
        }
        else{

            displayConfirmation("Operation Succesfully");
            dialog.cancel();
        }
    }

    @Override
    protected String doInBackground(Void... voids) {

        dialog.show();

        // your code to do you background activity
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM