Issue
I wonder if this is possible, the truth I imagine it must be a bad practical but only to test some things. I would like to call the same activity from itself, not if I explain.
Call to Activity A from Activity A
what I get is clean all sight. I've tried calling the method onResume
, onRestart
but I can not get it to work, for some strange reason the application stops working.
Nor I can see the error, since USB have connected the Code bar reader and not the device connected to the computer to view the log.
Solution
This is the best way to refresh your activity:
public void refresh() {
Intent intent = getIntent();
overridePendingTransition(0, 0);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
finish();
overridePendingTransition(0, 0);
startActivity(intent);
}
EDIT 06.11.2021 Kotlin way to refresh activity
private fun refresh() {
val intent = Intent(applicationContext, YourActivity::class.java)
startActivity(intent)
finish()
}
Answered By - Stanojkovic
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.