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;
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
|
show 6 more comments
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
Try putting timer inonCreate()
.
– 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
|
show 6 more comments
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
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
java android
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 inonCreate()
.
– 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
|
show 6 more comments
Try putting timer inonCreate()
.
– 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
|
show 6 more comments
1 Answer
1
active
oldest
votes
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.
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
add a comment |
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.
add a comment |
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.
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.
answered Mar 8 at 12:48
Vrushi PatelVrushi Patel
380321
380321
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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