我有2个应用程序:客户端应用程序和服务器应用程序。服务器应用程序包含客户端绑定到的服务。绑定是这样的:
Intent start = new Intent("com.example.myservice.ACTION_BIND");
start.setPackage("com.example.myservice");
startService(start);
bindService(start, mConnection, Context.BIND_AUTO_CREATE);
一切正常,直到我需要将productFlavors添加到服务器应用程序中为止。在productFlavors中,我更改了applicationId,然后客户端应用程序停止绑定到服务器应用程序。
<service
android:name=".service.MyService"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="${applicationId}.ACTION_BIND" />
</intent-filter>
</service>
客户端应用程序不知道服务器应用程序安装了哪个$ {applicationId}。
如何以编程方式获取服务器应用程序的applicationId?还是我该如何解决这个问题?