1

I am trying to make a RemoteService ,I have followed this guide : http://www.techotopia.com/index.php/Android_Remote_Bound_Services_%E2%80%93_A_Worked_Example

this is my service declaration in the Manifest:

 <service android:name=".RemoteService"
        android:process=":InnolertRemoteProcess"
        android:exported="true">
        <intent-filter>
            <action android:name="myService.RemoteService"/>
            <category android:name="android.intent.category.DEFAULT"/>
        </intent-filter>
    </service>

and this is how i bind to the service from my client app :

Intent intent = new Intent("myService.RemoteService");
bindService(intent, myConnection, Context.BIND_AUTO_CREATE);

i get this Exception :

  java.lang.IllegalArgumentException: Service Intent must be explicit: Intent { act=myService.RemoteService }
Maxim Toyberman
  • 1,906
  • 1
  • 20
  • 35
  • you have to use a `PackageManager` in order to get explicit `Intent`, for example `PackageManager#resolveService` or `PackageManager#queryIntentServices` – pskink Apr 26 '16 at 12:59

2 Answers2

2

Try this:

Intent i = new Intent();
i.setAction("myService.RemoteService");
i.setPackage("com.your_service_package.name");
boolean ret = bindService(i, connection, Context.BIND_AUTO_CREATE);
Log.d(TAG, "initService() bound with " + ret);
Pang
  • 9,564
  • 146
  • 81
  • 122
SAURABH_12
  • 2,262
  • 1
  • 19
  • 19
1

For me, the next line help me: intent.setPackage("myServicePackageName");

For Example:

    Intent intent = new Intent("com.something.REQUEST_SOMETHING");
    intent.setPackage("com.something");
    ctx.startService(intent);
Ester Kaufman
  • 708
  • 10
  • 20