To transmit data to other applications I\'ve been using implicit intents as in examples below:
Intent intent = new Intent();
intent.setAction(\"com.example.OpenU
As @Commonsware pointed out in his blog, the 3 ways to resolve this are:
Intent i = new Intent("serviceName");
ResolveInfo info = ctx.getPackageManager().resolveService(i, Context.BIND_AUTO_CREATE);
i.setComponent(new ComponentName(info.serviceInfo.packageName,info.serviceInfo.name));
And use the intent to bind the service.
Intent i = new Intent("serviceName");
List infos = ctx.getPackageManager().queryIntentServices(i,Context.BIND_AUTO_CREATE);
if (infos.isEmpty()) {
throw new IllegalStateException("no service found");
}
if (infos.size() > 1) {
throw new SecurityException("multiple services found, could be a security issue");
}
i.setComponent(new ComponentName(infos.get(0).serviceInfo.packageName, infos.get(0).serviceInfo.name));
If the query returns more than one info, this could mean a malicous services is listening.
If you have the package name, you could just set the package name as @matiash said in his post:
Intent i = new Intent(MyClass.class.getName());
i.setPackage(MyClass.class.getPackage().getName())