Android call method from another app

后端 未结 4 985
有刺的猬
有刺的猬 2020-12-08 23:56

I have 2 android apps. Both are installed on the phone. Lets say the package name for the two are com.android.test1 and com.android.test2. How can i call the method M

4条回答
  •  甜味超标
    2020-12-09 00:01

    If you want to send callbacks from app1 to app2:

    1. you should throw your own Intent with data from app1. (take look at PendingIntent).
    2. into yout app2 you should register BroadcastReceiver which will handle your app1's Intents.
    3. broadcastreceiver's onReceive method (in app2) will be called each time when your Intent will be thrown by app1 and catched by app2. (put your logics there)

提交回复
热议问题