How to call a Service through another application?

0

I have two applications, application 1 has several CRUDs, application 2 has several services and notifications.

When trying to start the Service by application 1, this is happening:

  

java.lang.SecurityException: Not allowed to start service Intent {   cmp = com.example.luiz.servicelocation / .LocationService} without   permission not exported from uid 10059

Would you like to start a service from my application 2 via a button in my application 1?

    
asked by anonymous 07.03.2016 / 14:18

1 answer

1

First look at your AndroidManifest.xml and copy the content inside the package, in the case "com.example.people.application".

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.pedro.aplicativo" ></manifest>

In your activity use the code below, in the package variable put the one you copied from package (com.example.pedro.aplicativo) and in the variable put the class name of the service you want to call (com.example.pedro .application.myService).

import android.content.ComponentName;

Intent intent = new Intent();
String pacote = "com.example.pedro.aplicativo";
String classe = "com.example.pedro.aplicativo.MeuServico";
intent.setComponent(new ComponentName(pacote, classe));
startService(intent);
    
07.03.2016 / 21:24