Get intent Class loader . I want to set text a textView in secondActivity to name of firstActivity (Actually I need class loader name)

拟墨画扇 提交于 2019-12-02 10:10:10

The ClassLoader isn't going to tell you what loaded your Activity; it's for loading Classes.

A better approach would be to send some kind of info to Activity C that tells it who opened it. e.g.

Activity A:

Intent intent = new Intent(ActivityA.this, ActivityC.class);
intent.putExtra("from", "Activity A");
startActivity(intent);

And then in your onCreate(Bundle) method of Activity C you would get that value:

@Override
public void onCreate(Bundle savedInstance){
    ....

    String fromActivity = getIntent().getStringExtra("from");

    textViewNameOfFirstActivity.setText(fromActivity);
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!