how to call a method in another Activity from Activity

后端 未结 6 1843
广开言路
广开言路 2020-11-27 21:34

\'m developing an Android Application in which I have

I\'ve two classes class A and Class B .

In class A , I tried the code Snippets like below,

6条回答
  •  悲哀的现实
    2020-11-27 22:16

    You should not create an instance of the activity class. It is wrong. Activity has ui and lifecycle and activity is started by startActivity(intent)

    You can use startActivityForResult or you can pass the values from one activity to another using intents and do what is required. But it depends on what you intend to do in the method.

提交回复
热议问题