Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我们可以调用另一个活动的函数 onBackPresses() 吗?例如,像这样:---在 second_activity----
if(i==10) first_activity.onBackPressed();
如果您想通过按下第三个活动的后退按钮来打开第一个活动,请将其放在您的第三个活动中:
@Override public void onBackPressed() { Intent intent; intent = new Intent(this, FirstActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); finish(); startActivity(intent); }