OnResume Methods are not executing on launching new activity using startActivity(intent)
up vote
-1
down vote
favorite
Suppose i have activity 'A' which is showing data fetched from online database say Number of questions attended.
User goes from Activity 'A' -> 'B' where he attended the questions and comes back to Activity 'A' after pressing 'back' button.
Inside Activity 'A' I have methods executing correctly, fetching data online and updating the TextViews, Which i am calling in from onResume() method..
Now problem is when i go back from Activity 'B' to Activity 'A', onResume is not executing and those methods are not executing..
When i click power button and put the screen on sleep and awake the screen, data is getting updated correctly.
I know the Lifecycle it says that onResume will execute.
I am simply using the below code for going back from 'B' -> 'A'
backProfileImgView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
finish();
startActivity(new Intent(getApplicationContext(),ProfileActivity.class));
}
});
and Activity 'A' is having onResume() method as
public void onResume() {
super.onResume();
setContentView(R.layout.activity_profile);
new GetContacts().execute();
updateAllViews();
pDialog.dismiss();
}
But i dont know where i am doing wrong. Please advise
android
add a comment |
up vote
-1
down vote
favorite
Suppose i have activity 'A' which is showing data fetched from online database say Number of questions attended.
User goes from Activity 'A' -> 'B' where he attended the questions and comes back to Activity 'A' after pressing 'back' button.
Inside Activity 'A' I have methods executing correctly, fetching data online and updating the TextViews, Which i am calling in from onResume() method..
Now problem is when i go back from Activity 'B' to Activity 'A', onResume is not executing and those methods are not executing..
When i click power button and put the screen on sleep and awake the screen, data is getting updated correctly.
I know the Lifecycle it says that onResume will execute.
I am simply using the below code for going back from 'B' -> 'A'
backProfileImgView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
finish();
startActivity(new Intent(getApplicationContext(),ProfileActivity.class));
}
});
and Activity 'A' is having onResume() method as
public void onResume() {
super.onResume();
setContentView(R.layout.activity_profile);
new GetContacts().execute();
updateAllViews();
pDialog.dismiss();
}
But i dont know where i am doing wrong. Please advise
android
1
your ques is very unclear, please replace A, B with real activity name
– Touhidul Islam
Nov 11 at 10:28
I think you must add Activity A and B code or just told me the names im confused
– Radesh
Nov 11 at 10:48
add a comment |
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
Suppose i have activity 'A' which is showing data fetched from online database say Number of questions attended.
User goes from Activity 'A' -> 'B' where he attended the questions and comes back to Activity 'A' after pressing 'back' button.
Inside Activity 'A' I have methods executing correctly, fetching data online and updating the TextViews, Which i am calling in from onResume() method..
Now problem is when i go back from Activity 'B' to Activity 'A', onResume is not executing and those methods are not executing..
When i click power button and put the screen on sleep and awake the screen, data is getting updated correctly.
I know the Lifecycle it says that onResume will execute.
I am simply using the below code for going back from 'B' -> 'A'
backProfileImgView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
finish();
startActivity(new Intent(getApplicationContext(),ProfileActivity.class));
}
});
and Activity 'A' is having onResume() method as
public void onResume() {
super.onResume();
setContentView(R.layout.activity_profile);
new GetContacts().execute();
updateAllViews();
pDialog.dismiss();
}
But i dont know where i am doing wrong. Please advise
android
Suppose i have activity 'A' which is showing data fetched from online database say Number of questions attended.
User goes from Activity 'A' -> 'B' where he attended the questions and comes back to Activity 'A' after pressing 'back' button.
Inside Activity 'A' I have methods executing correctly, fetching data online and updating the TextViews, Which i am calling in from onResume() method..
Now problem is when i go back from Activity 'B' to Activity 'A', onResume is not executing and those methods are not executing..
When i click power button and put the screen on sleep and awake the screen, data is getting updated correctly.
I know the Lifecycle it says that onResume will execute.
I am simply using the below code for going back from 'B' -> 'A'
backProfileImgView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
finish();
startActivity(new Intent(getApplicationContext(),ProfileActivity.class));
}
});
and Activity 'A' is having onResume() method as
public void onResume() {
super.onResume();
setContentView(R.layout.activity_profile);
new GetContacts().execute();
updateAllViews();
pDialog.dismiss();
}
But i dont know where i am doing wrong. Please advise
android
android
asked Nov 11 at 10:04
amulbhatia
216
216
1
your ques is very unclear, please replace A, B with real activity name
– Touhidul Islam
Nov 11 at 10:28
I think you must add Activity A and B code or just told me the names im confused
– Radesh
Nov 11 at 10:48
add a comment |
1
your ques is very unclear, please replace A, B with real activity name
– Touhidul Islam
Nov 11 at 10:28
I think you must add Activity A and B code or just told me the names im confused
– Radesh
Nov 11 at 10:48
1
1
your ques is very unclear, please replace A, B with real activity name
– Touhidul Islam
Nov 11 at 10:28
your ques is very unclear, please replace A, B with real activity name
– Touhidul Islam
Nov 11 at 10:28
I think you must add Activity A and B code or just told me the names im confused
– Radesh
Nov 11 at 10:48
I think you must add Activity A and B code or just told me the names im confused
– Radesh
Nov 11 at 10:48
add a comment |
1 Answer
1
active
oldest
votes
up vote
2
down vote
accepted
do not call finish()
use this
backProfileImgView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//call only onBackPressed
onBackPressed();
}
});
Not working, finish() will destroy the current activity i.e. 'B' but my data is not populating in 'A', which is not getting refreshed while coming back from B to A
– amulbhatia
Nov 11 at 10:17
@amulbhatia your A activity is ProfileActivity and your B activity is ... ??
– Radesh
Nov 11 at 10:19
@amulbhatia check edited code
– Radesh
Nov 11 at 10:25
Activity B is showing list of questions.. in recyclerview (Still not working after using onBackPressed)
– amulbhatia
Nov 11 at 10:43
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
do not call finish()
use this
backProfileImgView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//call only onBackPressed
onBackPressed();
}
});
Not working, finish() will destroy the current activity i.e. 'B' but my data is not populating in 'A', which is not getting refreshed while coming back from B to A
– amulbhatia
Nov 11 at 10:17
@amulbhatia your A activity is ProfileActivity and your B activity is ... ??
– Radesh
Nov 11 at 10:19
@amulbhatia check edited code
– Radesh
Nov 11 at 10:25
Activity B is showing list of questions.. in recyclerview (Still not working after using onBackPressed)
– amulbhatia
Nov 11 at 10:43
add a comment |
up vote
2
down vote
accepted
do not call finish()
use this
backProfileImgView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//call only onBackPressed
onBackPressed();
}
});
Not working, finish() will destroy the current activity i.e. 'B' but my data is not populating in 'A', which is not getting refreshed while coming back from B to A
– amulbhatia
Nov 11 at 10:17
@amulbhatia your A activity is ProfileActivity and your B activity is ... ??
– Radesh
Nov 11 at 10:19
@amulbhatia check edited code
– Radesh
Nov 11 at 10:25
Activity B is showing list of questions.. in recyclerview (Still not working after using onBackPressed)
– amulbhatia
Nov 11 at 10:43
add a comment |
up vote
2
down vote
accepted
up vote
2
down vote
accepted
do not call finish()
use this
backProfileImgView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//call only onBackPressed
onBackPressed();
}
});
do not call finish()
use this
backProfileImgView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//call only onBackPressed
onBackPressed();
}
});
edited Nov 11 at 10:24
answered Nov 11 at 10:10
Radesh
2,71411229
2,71411229
Not working, finish() will destroy the current activity i.e. 'B' but my data is not populating in 'A', which is not getting refreshed while coming back from B to A
– amulbhatia
Nov 11 at 10:17
@amulbhatia your A activity is ProfileActivity and your B activity is ... ??
– Radesh
Nov 11 at 10:19
@amulbhatia check edited code
– Radesh
Nov 11 at 10:25
Activity B is showing list of questions.. in recyclerview (Still not working after using onBackPressed)
– amulbhatia
Nov 11 at 10:43
add a comment |
Not working, finish() will destroy the current activity i.e. 'B' but my data is not populating in 'A', which is not getting refreshed while coming back from B to A
– amulbhatia
Nov 11 at 10:17
@amulbhatia your A activity is ProfileActivity and your B activity is ... ??
– Radesh
Nov 11 at 10:19
@amulbhatia check edited code
– Radesh
Nov 11 at 10:25
Activity B is showing list of questions.. in recyclerview (Still not working after using onBackPressed)
– amulbhatia
Nov 11 at 10:43
Not working, finish() will destroy the current activity i.e. 'B' but my data is not populating in 'A', which is not getting refreshed while coming back from B to A
– amulbhatia
Nov 11 at 10:17
Not working, finish() will destroy the current activity i.e. 'B' but my data is not populating in 'A', which is not getting refreshed while coming back from B to A
– amulbhatia
Nov 11 at 10:17
@amulbhatia your A activity is ProfileActivity and your B activity is ... ??
– Radesh
Nov 11 at 10:19
@amulbhatia your A activity is ProfileActivity and your B activity is ... ??
– Radesh
Nov 11 at 10:19
@amulbhatia check edited code
– Radesh
Nov 11 at 10:25
@amulbhatia check edited code
– Radesh
Nov 11 at 10:25
Activity B is showing list of questions.. in recyclerview (Still not working after using onBackPressed)
– amulbhatia
Nov 11 at 10:43
Activity B is showing list of questions.. in recyclerview (Still not working after using onBackPressed)
– amulbhatia
Nov 11 at 10:43
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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%2f53247625%2fonresume-methods-are-not-executing-on-launching-new-activity-using-startactivity%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
1
your ques is very unclear, please replace A, B with real activity name
– Touhidul Islam
Nov 11 at 10:28
I think you must add Activity A and B code or just told me the names im confused
– Radesh
Nov 11 at 10:48