2

I created one remote service as follows:-

<service android:name=".XYZService"
            android:permission="com.xyz.service"
            android:exported="true">
            <intent-filter>
                <action android:name="com.abc.def.XYZService"/>
            </intent-filter>
        </service>

I am trying to bind with this service by using client application service as follows:- //client service onStartCommand code :

 @Override
            public int onStartCommand(Intent intent, int flags, int startId) {

                boolean ret;
                try {
                          Intent i = new Intent("com.abc.def.XYZService");
                    ret = getApplicationContext().bindService(i, serviceConnection,
                            Context.BIND_AUTO_CREATE);
                    if (ret == false) {
                        //log error
                    }

                } catch (SecurityException e) {
                                  e.printStackTrace();
                }
        return super.onStartCommand(intent, flags, startId);
            }

client application manifest has following permission:-

 <uses-permission android:name="com.xyz.service" />

Still, I am getting following exception:- Security Exception: The client Service does not have permission to bind to the xyz service.

My intention here is to protect my exported service with some permission and use that permission in client application to access exported service. Any help will be appreciated.

1 Answers1

0

Use this.

<permission
        android:name="myPermission"
        android:description="@string/myPermissionDescription"
        android:label="@string/myPermissionLabel">
    </permission>

more info: page 1 -- page 2

Community
  • 1
  • 1
Ali Bagheri
  • 3,068
  • 27
  • 28