Android studio Call method The 2019 Stack Overflow Developer Survey Results Are InIs there a way to run Python on Android?How do save an Android Activity state using save instance state?How do I call one constructor from another in Java?Close/hide the Android Soft KeyboardWhy is the Android emulator so slow? How can we speed up the Android emulator?Is there a unique Android device ID?How to call a method after a delay in AndroidWhat is 'Context' on Android?Proper use cases for Android UserManager.isUserAGoat()?Android Studio: Add jar as library?

What does "sndry explns" mean in one of the Hitchhiker's guide books?

How come people say “Would of”?

Realistic Alternatives to Dust: What Else Could Feed a Plankton Bloom?

Why is it "Tumoren" and not "Tumore"?

aging parents with no investments

How to reverse every other sublist of a list?

Monty Hall variation

What are the motivations for publishing new editions of an existing textbook, beyond new discoveries in a field?

What do the Banks children have against barley water?

What is a mixture ratio of propellant?

What is the use of option -o in the useradd command?

How was Skylab's orbit inclination chosen?

"Riffle" two strings

Manuscript was "unsubmitted" because the manuscript was deposited in Arxiv Preprints

"What time...?" or "At what time...?" - what is more grammatically correct?

Why could you hear an Amstrad CPC working?

Is flight data recorder erased after every flight?

Unbreakable Formation vs. Cry of the Carnarium

Dual Citizen. Exited the US on Italian passport recently

Spanish for "widget"

Is "plugging out" electronic devices an American expression?

Which Sci-Fi work first showed weapon of galactic-scale mass destruction?

Time travel alters history but people keep saying nothing's changed

Is bread bad for ducks?



Android studio Call method



The 2019 Stack Overflow Developer Survey Results Are InIs there a way to run Python on Android?How do save an Android Activity state using save instance state?How do I call one constructor from another in Java?Close/hide the Android Soft KeyboardWhy is the Android emulator so slow? How can we speed up the Android emulator?Is there a unique Android device ID?How to call a method after a delay in AndroidWhat is 'Context' on Android?Proper use cases for Android UserManager.isUserAGoat()?Android Studio: Add jar as library?



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I am having a problem with my code.
I have an activity with an EditText , when the activity opens for the first time I would like to pass the value of the EditText to my server and receive an answer.



The problem is if I call the method in onCreate () it does not work.



If instead I call the method from the
click ()
event of the button it works.



Is there a way to call the method from the onCreate () and display the contents of the EditText?



This is my code :



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

First_Name = (EditText)findViewById(R.id.editText50);

parseContent = new ParseContentRistoratore(this);
preferenceHelper = new PreferenceHelperRistoratore(this);

CheckEditTextIsEmptyOrNot();

UserRegisterFunction(F_Name_Holder);

prova = (Button) findViewById(R.id.button10);
// If EditText is not empty and CheckEditText = True then this block will execute.
prova.setOnClickListener(new View.OnClickListener()
@Override
public void onClick(View v)

);


//REGISTRATION
@RequiresApi(api = Build.VERSION_CODES.CUPCAKE)
public void UserRegisterFunction(final String fk_id_ristorante)
class UserRegisterFunctionClass extends AsyncTask<String,Void,String>
@Override
protected void onPostExecute(String httpResponseMsg)
super.onPostExecute(httpResponseMsg);

if(httpResponseMsg.equalsIgnoreCase("Prova gratuita terminata"))
// finish(); con finish(); l'attività finisce
Intent intent = new Intent(Main3Activity.this, Versione_scaduta.class);
startActivity(intent);



//REGISTRATION
@Override
protected String doInBackground(String... params)
hashMap.put("fk_id_ristorante",params[0]);
finalResult = httpParse.postRequest(hashMap, HttpURLRegister);
return finalResult;



UserRegisterFunctionClass userRegisterFunctionClass = new UserRegisterFunctionClass();
userRegisterFunctionClass.execute(fk_id_ristorante);


//REGISTRAZIONE
public void CheckEditTextIsEmptyOrNot()
F_Name_Holder = First_Name.getText().toString();

if(TextUtils.isEmpty(F_Name_Holder) )

CheckEditText = false;

else
CheckEditText = true ;



@Override
protected void onResume()
super.onResume();

AccountKit.getCurrentAccount(new AccountKitCallback<Account>()
@Override
public void onSuccess(Account account)
//editUserId = (EditText)findViewById(R.id.editUserEmail);
// editUserId.setText(String.format("Email Id %s",account.getEmail()));

First_Name.setText(String.format("r%s", account.getId()));


@Override
public void onError(AccountKitError accountKitError)

);


}


If you can not do it, I'd like to know something else instead.



Why in my PHP code if I remove the Else from the IF Cycle the code does not work when it is started on Android studio?



<?php
if($_SERVER['REQUEST_METHOD']=='POST')

include 'config.php';

$con = mysqli_connect($HostName,$HostUser,$HostPass,$DatabaseName);

$fk_id_ristorante = $_POST['fk_id_ristorante'];



$CheckSQL = "SELECT * FROM R_Iscrizioni WHERE data_scadenza < CURDATE() AND fk_id_ristorante='$fk_id_ristorante' AND pagamento = 'No' ";

$check = mysqli_fetch_array(mysqli_query($con,$CheckSQL));

if(isset($check))

echo 'Prova gratuita terminata';

else
echo 'Hello';


mysqli_close($con);
?>









share|improve this question
























  • Try putting timer in onCreate() .

    – Vrushi Patel
    Mar 8 at 8:41











  • Excuse me for what do I need the timer?

    – Simone Bruziches
    Mar 8 at 8:44











  • You said that your code works fine if you put that in click() event , so instead of doing that onClick() give system some time for being ready and execute code properly Mr.

    – Vrushi Patel
    Mar 8 at 8:47











  • Check out Activity life cycle and fragment life cycle

    – raj kavadia
    Mar 8 at 8:58











  • Thanks for the advice, after I will try to set up a Timer and see if it works.

    – Simone Bruziches
    Mar 8 at 9:14

















0















I am having a problem with my code.
I have an activity with an EditText , when the activity opens for the first time I would like to pass the value of the EditText to my server and receive an answer.



The problem is if I call the method in onCreate () it does not work.



If instead I call the method from the
click ()
event of the button it works.



Is there a way to call the method from the onCreate () and display the contents of the EditText?



This is my code :



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

First_Name = (EditText)findViewById(R.id.editText50);

parseContent = new ParseContentRistoratore(this);
preferenceHelper = new PreferenceHelperRistoratore(this);

CheckEditTextIsEmptyOrNot();

UserRegisterFunction(F_Name_Holder);

prova = (Button) findViewById(R.id.button10);
// If EditText is not empty and CheckEditText = True then this block will execute.
prova.setOnClickListener(new View.OnClickListener()
@Override
public void onClick(View v)

);


//REGISTRATION
@RequiresApi(api = Build.VERSION_CODES.CUPCAKE)
public void UserRegisterFunction(final String fk_id_ristorante)
class UserRegisterFunctionClass extends AsyncTask<String,Void,String>
@Override
protected void onPostExecute(String httpResponseMsg)
super.onPostExecute(httpResponseMsg);

if(httpResponseMsg.equalsIgnoreCase("Prova gratuita terminata"))
// finish(); con finish(); l'attività finisce
Intent intent = new Intent(Main3Activity.this, Versione_scaduta.class);
startActivity(intent);



//REGISTRATION
@Override
protected String doInBackground(String... params)
hashMap.put("fk_id_ristorante",params[0]);
finalResult = httpParse.postRequest(hashMap, HttpURLRegister);
return finalResult;



UserRegisterFunctionClass userRegisterFunctionClass = new UserRegisterFunctionClass();
userRegisterFunctionClass.execute(fk_id_ristorante);


//REGISTRAZIONE
public void CheckEditTextIsEmptyOrNot()
F_Name_Holder = First_Name.getText().toString();

if(TextUtils.isEmpty(F_Name_Holder) )

CheckEditText = false;

else
CheckEditText = true ;



@Override
protected void onResume()
super.onResume();

AccountKit.getCurrentAccount(new AccountKitCallback<Account>()
@Override
public void onSuccess(Account account)
//editUserId = (EditText)findViewById(R.id.editUserEmail);
// editUserId.setText(String.format("Email Id %s",account.getEmail()));

First_Name.setText(String.format("r%s", account.getId()));


@Override
public void onError(AccountKitError accountKitError)

);


}


If you can not do it, I'd like to know something else instead.



Why in my PHP code if I remove the Else from the IF Cycle the code does not work when it is started on Android studio?



<?php
if($_SERVER['REQUEST_METHOD']=='POST')

include 'config.php';

$con = mysqli_connect($HostName,$HostUser,$HostPass,$DatabaseName);

$fk_id_ristorante = $_POST['fk_id_ristorante'];



$CheckSQL = "SELECT * FROM R_Iscrizioni WHERE data_scadenza < CURDATE() AND fk_id_ristorante='$fk_id_ristorante' AND pagamento = 'No' ";

$check = mysqli_fetch_array(mysqli_query($con,$CheckSQL));

if(isset($check))

echo 'Prova gratuita terminata';

else
echo 'Hello';


mysqli_close($con);
?>









share|improve this question
























  • Try putting timer in onCreate() .

    – Vrushi Patel
    Mar 8 at 8:41











  • Excuse me for what do I need the timer?

    – Simone Bruziches
    Mar 8 at 8:44











  • You said that your code works fine if you put that in click() event , so instead of doing that onClick() give system some time for being ready and execute code properly Mr.

    – Vrushi Patel
    Mar 8 at 8:47











  • Check out Activity life cycle and fragment life cycle

    – raj kavadia
    Mar 8 at 8:58











  • Thanks for the advice, after I will try to set up a Timer and see if it works.

    – Simone Bruziches
    Mar 8 at 9:14













0












0








0








I am having a problem with my code.
I have an activity with an EditText , when the activity opens for the first time I would like to pass the value of the EditText to my server and receive an answer.



The problem is if I call the method in onCreate () it does not work.



If instead I call the method from the
click ()
event of the button it works.



Is there a way to call the method from the onCreate () and display the contents of the EditText?



This is my code :



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

First_Name = (EditText)findViewById(R.id.editText50);

parseContent = new ParseContentRistoratore(this);
preferenceHelper = new PreferenceHelperRistoratore(this);

CheckEditTextIsEmptyOrNot();

UserRegisterFunction(F_Name_Holder);

prova = (Button) findViewById(R.id.button10);
// If EditText is not empty and CheckEditText = True then this block will execute.
prova.setOnClickListener(new View.OnClickListener()
@Override
public void onClick(View v)

);


//REGISTRATION
@RequiresApi(api = Build.VERSION_CODES.CUPCAKE)
public void UserRegisterFunction(final String fk_id_ristorante)
class UserRegisterFunctionClass extends AsyncTask<String,Void,String>
@Override
protected void onPostExecute(String httpResponseMsg)
super.onPostExecute(httpResponseMsg);

if(httpResponseMsg.equalsIgnoreCase("Prova gratuita terminata"))
// finish(); con finish(); l'attività finisce
Intent intent = new Intent(Main3Activity.this, Versione_scaduta.class);
startActivity(intent);



//REGISTRATION
@Override
protected String doInBackground(String... params)
hashMap.put("fk_id_ristorante",params[0]);
finalResult = httpParse.postRequest(hashMap, HttpURLRegister);
return finalResult;



UserRegisterFunctionClass userRegisterFunctionClass = new UserRegisterFunctionClass();
userRegisterFunctionClass.execute(fk_id_ristorante);


//REGISTRAZIONE
public void CheckEditTextIsEmptyOrNot()
F_Name_Holder = First_Name.getText().toString();

if(TextUtils.isEmpty(F_Name_Holder) )

CheckEditText = false;

else
CheckEditText = true ;



@Override
protected void onResume()
super.onResume();

AccountKit.getCurrentAccount(new AccountKitCallback<Account>()
@Override
public void onSuccess(Account account)
//editUserId = (EditText)findViewById(R.id.editUserEmail);
// editUserId.setText(String.format("Email Id %s",account.getEmail()));

First_Name.setText(String.format("r%s", account.getId()));


@Override
public void onError(AccountKitError accountKitError)

);


}


If you can not do it, I'd like to know something else instead.



Why in my PHP code if I remove the Else from the IF Cycle the code does not work when it is started on Android studio?



<?php
if($_SERVER['REQUEST_METHOD']=='POST')

include 'config.php';

$con = mysqli_connect($HostName,$HostUser,$HostPass,$DatabaseName);

$fk_id_ristorante = $_POST['fk_id_ristorante'];



$CheckSQL = "SELECT * FROM R_Iscrizioni WHERE data_scadenza < CURDATE() AND fk_id_ristorante='$fk_id_ristorante' AND pagamento = 'No' ";

$check = mysqli_fetch_array(mysqli_query($con,$CheckSQL));

if(isset($check))

echo 'Prova gratuita terminata';

else
echo 'Hello';


mysqli_close($con);
?>









share|improve this question
















I am having a problem with my code.
I have an activity with an EditText , when the activity opens for the first time I would like to pass the value of the EditText to my server and receive an answer.



The problem is if I call the method in onCreate () it does not work.



If instead I call the method from the
click ()
event of the button it works.



Is there a way to call the method from the onCreate () and display the contents of the EditText?



This is my code :



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

First_Name = (EditText)findViewById(R.id.editText50);

parseContent = new ParseContentRistoratore(this);
preferenceHelper = new PreferenceHelperRistoratore(this);

CheckEditTextIsEmptyOrNot();

UserRegisterFunction(F_Name_Holder);

prova = (Button) findViewById(R.id.button10);
// If EditText is not empty and CheckEditText = True then this block will execute.
prova.setOnClickListener(new View.OnClickListener()
@Override
public void onClick(View v)

);


//REGISTRATION
@RequiresApi(api = Build.VERSION_CODES.CUPCAKE)
public void UserRegisterFunction(final String fk_id_ristorante)
class UserRegisterFunctionClass extends AsyncTask<String,Void,String>
@Override
protected void onPostExecute(String httpResponseMsg)
super.onPostExecute(httpResponseMsg);

if(httpResponseMsg.equalsIgnoreCase("Prova gratuita terminata"))
// finish(); con finish(); l'attività finisce
Intent intent = new Intent(Main3Activity.this, Versione_scaduta.class);
startActivity(intent);



//REGISTRATION
@Override
protected String doInBackground(String... params)
hashMap.put("fk_id_ristorante",params[0]);
finalResult = httpParse.postRequest(hashMap, HttpURLRegister);
return finalResult;



UserRegisterFunctionClass userRegisterFunctionClass = new UserRegisterFunctionClass();
userRegisterFunctionClass.execute(fk_id_ristorante);


//REGISTRAZIONE
public void CheckEditTextIsEmptyOrNot()
F_Name_Holder = First_Name.getText().toString();

if(TextUtils.isEmpty(F_Name_Holder) )

CheckEditText = false;

else
CheckEditText = true ;



@Override
protected void onResume()
super.onResume();

AccountKit.getCurrentAccount(new AccountKitCallback<Account>()
@Override
public void onSuccess(Account account)
//editUserId = (EditText)findViewById(R.id.editUserEmail);
// editUserId.setText(String.format("Email Id %s",account.getEmail()));

First_Name.setText(String.format("r%s", account.getId()));


@Override
public void onError(AccountKitError accountKitError)

);


}


If you can not do it, I'd like to know something else instead.



Why in my PHP code if I remove the Else from the IF Cycle the code does not work when it is started on Android studio?



<?php
if($_SERVER['REQUEST_METHOD']=='POST')

include 'config.php';

$con = mysqli_connect($HostName,$HostUser,$HostPass,$DatabaseName);

$fk_id_ristorante = $_POST['fk_id_ristorante'];



$CheckSQL = "SELECT * FROM R_Iscrizioni WHERE data_scadenza < CURDATE() AND fk_id_ristorante='$fk_id_ristorante' AND pagamento = 'No' ";

$check = mysqli_fetch_array(mysqli_query($con,$CheckSQL));

if(isset($check))

echo 'Prova gratuita terminata';

else
echo 'Hello';


mysqli_close($con);
?>






java android






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 8 at 10:24









Michael

43.7k84595




43.7k84595










asked Mar 8 at 8:38









Simone BruzichesSimone Bruziches

54




54












  • Try putting timer in onCreate() .

    – Vrushi Patel
    Mar 8 at 8:41











  • Excuse me for what do I need the timer?

    – Simone Bruziches
    Mar 8 at 8:44











  • You said that your code works fine if you put that in click() event , so instead of doing that onClick() give system some time for being ready and execute code properly Mr.

    – Vrushi Patel
    Mar 8 at 8:47











  • Check out Activity life cycle and fragment life cycle

    – raj kavadia
    Mar 8 at 8:58











  • Thanks for the advice, after I will try to set up a Timer and see if it works.

    – Simone Bruziches
    Mar 8 at 9:14

















  • Try putting timer in onCreate() .

    – Vrushi Patel
    Mar 8 at 8:41











  • Excuse me for what do I need the timer?

    – Simone Bruziches
    Mar 8 at 8:44











  • You said that your code works fine if you put that in click() event , so instead of doing that onClick() give system some time for being ready and execute code properly Mr.

    – Vrushi Patel
    Mar 8 at 8:47











  • Check out Activity life cycle and fragment life cycle

    – raj kavadia
    Mar 8 at 8:58











  • Thanks for the advice, after I will try to set up a Timer and see if it works.

    – Simone Bruziches
    Mar 8 at 9:14
















Try putting timer in onCreate() .

– Vrushi Patel
Mar 8 at 8:41





Try putting timer in onCreate() .

– Vrushi Patel
Mar 8 at 8:41













Excuse me for what do I need the timer?

– Simone Bruziches
Mar 8 at 8:44





Excuse me for what do I need the timer?

– Simone Bruziches
Mar 8 at 8:44













You said that your code works fine if you put that in click() event , so instead of doing that onClick() give system some time for being ready and execute code properly Mr.

– Vrushi Patel
Mar 8 at 8:47





You said that your code works fine if you put that in click() event , so instead of doing that onClick() give system some time for being ready and execute code properly Mr.

– Vrushi Patel
Mar 8 at 8:47













Check out Activity life cycle and fragment life cycle

– raj kavadia
Mar 8 at 8:58





Check out Activity life cycle and fragment life cycle

– raj kavadia
Mar 8 at 8:58













Thanks for the advice, after I will try to set up a Timer and see if it works.

– Simone Bruziches
Mar 8 at 9:14





Thanks for the advice, after I will try to set up a Timer and see if it works.

– Simone Bruziches
Mar 8 at 9:14












1 Answer
1






active

oldest

votes


















0














What you need to do is just use CountDownTimer to let system load and be ready to let your code be execute right way.



Hope this helped you.






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55059457%2fandroid-studio-call-method%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    What you need to do is just use CountDownTimer to let system load and be ready to let your code be execute right way.



    Hope this helped you.






    share|improve this answer



























      0














      What you need to do is just use CountDownTimer to let system load and be ready to let your code be execute right way.



      Hope this helped you.






      share|improve this answer

























        0












        0








        0







        What you need to do is just use CountDownTimer to let system load and be ready to let your code be execute right way.



        Hope this helped you.






        share|improve this answer













        What you need to do is just use CountDownTimer to let system load and be ready to let your code be execute right way.



        Hope this helped you.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 8 at 12:48









        Vrushi PatelVrushi Patel

        380321




        380321





























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55059457%2fandroid-studio-call-method%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

            Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

            Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved