Android 4.4.2 - java.lang.RuntimeException: Performing stop of activity that is not resumed
That doesn't seem right to me. The splash activity would now be the top activity in the stack, so the HomeActivity
onStop lifecycle method would get called eventually. Coincidentally, I moved the startActivity
call for the splash activity from onCreate
to onResume
in the HomeActivity
, and the error goes away.
Performing stop of activity that is not resumed - Android
I had the same problem and the answer by @sheetal solved my issue.
https://stackoverflow.com/a/23246159/4871489
The issue will still be there on all HighEnd phones with 4.4.2 and
above including NEXUS 5,Samsumg s4 since onResume gets called but
still it is in animation stage.So if you try to start a activity in
onResume the issue will replicate.
I created a handler to start my intent with a small delay and the issue disappeared.
Hope it helps
Activity in loop - Performing stop of activity that is not resumed
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
new getFavoritos().execute(email);
}
private class getFavoritos extends AsyncTask<String, String,List<Podcasts>>{
@Override
protected void onPreExecute() {
dialog.show();
}
@Override
protected JSONObject doInBackground(String... args) {
//operations
return favoritos;
}
@Override
protected void onPostExecute(List<Podcasts> favoritos) {
if (dialog != null && dialog.isShowing()) {
dialog.dismiss();
}
if(List<Podcasts>!=null){
showFavoritosList(List<Podcasts>)
}
}
}
public void showFavoritosList(List<Podcasts>){
final LinearLayoutManager layoutManager = new LinearLayoutManager(this);
layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
mRecyclerView.setLayoutManager(layoutManager);
MainAdapter adapter = new MainAdapter(favoritos);
mRecyclerView.setAdapter(adapter);
}
try this, this might work.
UPDATE
mRecyclerView = new RecyclerView(this);
mRecyclerView = (RecyclerView) findViewById(R.id.my_recycler_view);
I saw this line in your code, you don't need to initialize recycler view twice. when you are using findViewById
you will get an object of RecyclerView, so new RecyclerView(this);
is not required and no use in this situation.
UPDATE 2
As I suspect you are again starting MainActivity in your checkLogin method that is a wrong approach, instead of that you can return the boolean directly.
ex:
@Override
protected void onCreate(Bundle savedInstanceState) {
boolean isSessionExist = sessionManager.isLoggedIn();
if(isSessionExist){
//open home screen
}else{
//open login screen
}
}
isLoggedIn
public boolean isLoggedIn(){
return pref.getBoolean(IS_LOGGED, false);
}
}
RuntimeException: Performing pause of activity that is not resumed
I've just had this problem because I was calling activity.recreate() (or .finish() and .startActivity() - depending on android version).
Of course, you would only call those functions because you want to reload language, reset orientation and similar stuff that you can only do with activity recreation.
You can't call those functions (.finish() or .recreate()) from onResume() though.
If you do, you will receive the mentioned non-fatal exception.
I "solved" the issue by delaying the .recreate() call for one millisecond so that the activity gets properly resumed and is only then killed.
Handler handler = new Handler();
handler.postDelayed(new Runnable()
{
@Override
public void run()
{
log.i("TX.refresh", "Switching to %s from %s", lang, lang);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB)
{
ctx.finish();
ctx.startActivity(ctx.getIntent());
} else ctx.recreate();
}
}, 1);
Error when launching app on device start
Similar problem found here: Similar Issue on SO. The solution seemed to be adding your Intent to either onResume() or onPostResume(). This is due to the app running on higher end phones.
public void onResume(){
super.onResume();
//XML parse and intent here
}
or:
public void onPostResume(){
super.onPostResume();
//XML parse and intent here
}
Also this was another viable answer:
Handler handler = new Handler(new Handler.Callback() {
@Override
public boolean handleMessage(Message msg) {
switch (msg.what) {
case 1:
//start activity with intent here
default:
break;
}
return false;
}
});
And in onResume call this.
handler.sendEmptyMessageDelayed(1, 1000);
Side note: I'd also like to suggest creating an intent as follows:
Intent i = new Intent(MainActivity.this, Result.class);
I can provide a long winded answer as to why, but in short don't use getApplicationContext() unless you know why :)
Related Topics
How to Make a Portion of a Checkbox's Text Clickable
Remove Unwanted White Space in Webview Android
How to Implement Ssl Certificate Pinning While Using React Native
Set Animated .Gif as Background Android
How to Avoid Restarting Activity When Orientation Changes on Android
How to Make an Android View That Flips Between Views on Swipe/Fling
Set Visibility of Progress Bar Gone on Completion of Image Loading Using Glide Library
Using Audiotrack in Android to Play a Wav File
Switch Back/Front Camera on Fly
Dialogfragment.Getdialog Returns Null
Programmatically Lock into Portrait Mode for Certain Operations
How to Click on an Item Inside a Recyclerview in Espresso
Error:Execution Failed for Task ':App:Kaptdebugkotlin'
How to Set Margins for Textview Programmatically