Android call method from another app

Maybe you can broadcast an Intent to call it.

Intent it = new Intent("com.android.test2.Main2method");
context.sendBroadcast(it)

Make a BroadcastReceiver in com.android.test2.Main2 to receive the broadcast:

public class ActionReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        if ("com.android.test2.Main2method".equalsIgnoreCase(intent.getAction())) {
            Main2method();
        } 
    }
}

Register the receiver in onCreate method of class Main1:

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ...

    receiver = new ActionReceiver();
    IntentFilter filter = new IntentFilter();
    filter.addAction("com.android.test2.Main2method");
    registerReceiver(receiver, filter);
    ...
}

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)

in order to call method between different application you will need to use, Intent

also you will need intent-filter and BroadcastReceiver