Android - New Intent starts particular method

前端 未结 4 1359
心在旅途
心在旅途 2021-01-01 15:09

I want to start one of my existing activities and force the activity to call a specific method after it starts. Is this possible?

Can I define a method that should b

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-01 15:51

    You question seems interesting, but there is no way you can do it using Intent. You have to understand that when you start an activity, it goes through a life cycle which is : onCreate()->onStart()->OnResume(). So what you can do is start that method from onResume() like this:

    @Override
    protected void onResume() {
        super.onResume();
        myMethod();//start your method from here
    }
    

    I'm just trying to help,give me some more information about your problem if this approach does not solve your problem.

提交回复
热议问题