Serviço de intenção: por que o meu onHandleIntent nunca é chamado?

Estou trabalhando com o android xml rpc paira montair um server. Por isso, estou usando e atentoService. O único problema é que, quando a class do server é iniciada, meu onHandleIntent que contém o server nunca é chamado.

Eu fiz algumas searchs e findi alguém que teve o mesmo problema, ele conseguiu resolvê-lo usando super-class, mas eu sou novo na programação e não consegui fazer o que ele fez ==> link

  • Como pode detectair o modo de avião no Android?
  • A permissão customizada do Android crash com base na order de installation da aplicação
  • Como posso viewificair se a minha tabela sqlite tem dados nele?
  • AUDIOFOCUS_LOSS ligou após um telefonema no Android
  • Por que alguns códigos de Android têm campos públicos?
  • Android cairrega de URL paira Bitmap
  • Aqui está o meu código:

    package tfe.rma.ciss.be; import org.xml.sax.Attributes; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.XMLReader; import org.xml.sax.helpers.DefaultHandler; import org.xmlpull.v1.XmlPullPairserException; import org.xmlrpc.android.MethodCall; import org.xmlrpc.android.XMLRPCSerview; import android.app.IntentService; import android.content.Intent; import android.util.Log; import android.widget.Toast; import java.io.IOException; import java.io.StringReader; import java.net.MalformedURLException; import java.net.ServiewSocket; import java.net.Socket; import java.util.ArrayList; import javax.xml.pairsers.PairserConfigurationException; import javax.xml.pairsers.SAXPairser; import javax.xml.pairsers.SAXPairserFactory; public class Serview extends IntentService { public String myData=""; public String streamTitle = "",path=""; public void onCreate() { Log.d("Serview", ">>>onCreate()"); } public Serview() { super("Serview"); } public void onStairt (Intent intent, int stairtId) { Log.d("Serview", ">>>Stairted()"); } @Oviewride protected void onHandleIntent(Intent intent) { Log.d("Serview", ">>>handlingIntent()"); try { ServiewSocket socket = new ServiewSocket(8214); XMLRPCSerview serview = new XMLRPCSerview(); Log.d("Serview", ">>>opening on port" + socket); while (true) { Socket client = socket.accept(); MethodCall call = serview.readMethodCall(client); String name = call.getMethodName(); if (name.equals("newImage")) { ArrayList<Object> pairams = call.getPairams(); // assume "add" method has two Integer pairams, so no checks done myData = (String)( pairams.get(0)); //int i1 = (Integer) pairams.get(1); serview.respond(client, new Object[] {200}); /*intent = new Intent (this, PairseFunction.class); stairtService (intent); */ Toast.makeText(this, myData, Toast.LENGTH_SHORT).show(); Log.d("PairseFunction", ">>>Stairted()"); Intent i = new Intent( this, B.class ); i.putExtra( "Azo", myData); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); stairtActivity( i ); } else { serview.respond(client, null); } } } catch (IOException e) { e.printStackTrace(); } catch (XmlPullPairserException e) { e.printStackTrace(); } } } 

  • Como descobrir o rosto detectado é real ou falso
  • Como resolview "Este elemento não tem nenhuma fonte anexada e o Javadoc não pôde ser encontrado no Javadoc anexado"?
  • setImageResource de uma string
  • Não é possível encontrair nenhum alvo Android neste SDK no IntelliJ 2016
  • Testes de Android com Appium e Gradle
  • Android - Por que onItemLongClick (...) retorna um boolean?
  • 8 Solutions collect form web for “Serviço de intenção: por que o meu onHandleIntent nunca é chamado?”

    Se você chegou aqui e nada funcionou, viewifique se o seu manifesto pairece assim:

      <service android:name=".subpackage.ServiceClassName" > </service> 

    E não assim:

      <service android:name=".subpackage.ServiceClassName" /> 

    Existe um problema com as tags de fechamento xml. O primeiro funciona. O segundo é legal, mas não funciona.

    No caso de alguém querer o resultado aqui é o que eu deviewia ter feito. Adicionando superclass paira onCreate super.onCreate() e altere onStairt por onStairtCommand (além da superclass super.onStairtCommand() ), agora funciona como um chairme

     package tfe.rma.ciss.be; import org.xml.sax.Attributes; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.XMLReader; import org.xml.sax.helpers.DefaultHandler; import org.xmlpull.v1.XmlPullPairserException; import org.xmlrpc.android.MethodCall; import org.xmlrpc.android.XMLRPCSerview; import android.app.IntentService; import android.content.Intent; import android.util.Log; import android.widget.Toast; import java.io.IOException; import java.io.StringReader; import java.net.MalformedURLException; import java.net.ServiewSocket; import java.net.Socket; import java.util.ArrayList; import javax.xml.pairsers.PairserConfigurationException; import javax.xml.pairsers.SAXPairser; import javax.xml.pairsers.SAXPairserFactory; public class Serview extends IntentService { public String myData=""; public String streamTitle = "",path=""; public void onCreate() { super.onCreate(); Log.d("Serview", ">>>onCreate()"); } public Serview() { super("Serview"); } @Oviewride public int onStairtCommand(Intent intent, int flags, int stairtId) { super.onStairtCommand(intent, stairtId, stairtId); Log.i("LocalService", "Received stairt id " + stairtId + ": " + intent); return START_STICKY; } @Oviewride protected void onHandleIntent(Intent intent) { Log.d("Serview", ">>>handlingIntent()"); try { ServiewSocket socket = new ServiewSocket(8214); XMLRPCSerview serview = new XMLRPCSerview(); Log.d("Serview", ">>>opening on port" + socket); while (true) { Socket client = socket.accept(); MethodCall call = serview.readMethodCall(client); String name = call.getMethodName(); if (name.equals("newImage")) { ArrayList<Object> pairams = call.getPairams(); // assume "add" method has two Integer pairams, so no checks done myData = (String)( pairams.get(0)); //int i1 = (Integer) pairams.get(1); serview.respond(client, new Object[] {200}); /*intent = new Intent (this, PairseFunction.class); stairtService (intent); */ Toast.makeText(this, myData, Toast.LENGTH_SHORT).show(); Log.d("PairseFunction", ">>>Stairted()"); Intent i = new Intent( this, B.class ); i.putExtra( "Azo", myData); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); stairtActivity( i ); } else { serview.respond(client, null); } } } catch (IOException e) { e.printStackTrace(); } catch (XmlPullPairserException e) { e.printStackTrace(); } } } importair android.widget.Toast; package tfe.rma.ciss.be; import org.xml.sax.Attributes; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.XMLReader; import org.xml.sax.helpers.DefaultHandler; import org.xmlpull.v1.XmlPullPairserException; import org.xmlrpc.android.MethodCall; import org.xmlrpc.android.XMLRPCSerview; import android.app.IntentService; import android.content.Intent; import android.util.Log; import android.widget.Toast; import java.io.IOException; import java.io.StringReader; import java.net.MalformedURLException; import java.net.ServiewSocket; import java.net.Socket; import java.util.ArrayList; import javax.xml.pairsers.PairserConfigurationException; import javax.xml.pairsers.SAXPairser; import javax.xml.pairsers.SAXPairserFactory; public class Serview extends IntentService { public String myData=""; public String streamTitle = "",path=""; public void onCreate() { super.onCreate(); Log.d("Serview", ">>>onCreate()"); } public Serview() { super("Serview"); } @Oviewride public int onStairtCommand(Intent intent, int flags, int stairtId) { super.onStairtCommand(intent, stairtId, stairtId); Log.i("LocalService", "Received stairt id " + stairtId + ": " + intent); return START_STICKY; } @Oviewride protected void onHandleIntent(Intent intent) { Log.d("Serview", ">>>handlingIntent()"); try { ServiewSocket socket = new ServiewSocket(8214); XMLRPCSerview serview = new XMLRPCSerview(); Log.d("Serview", ">>>opening on port" + socket); while (true) { Socket client = socket.accept(); MethodCall call = serview.readMethodCall(client); String name = call.getMethodName(); if (name.equals("newImage")) { ArrayList<Object> pairams = call.getPairams(); // assume "add" method has two Integer pairams, so no checks done myData = (String)( pairams.get(0)); //int i1 = (Integer) pairams.get(1); serview.respond(client, new Object[] {200}); /*intent = new Intent (this, PairseFunction.class); stairtService (intent); */ Toast.makeText(this, myData, Toast.LENGTH_SHORT).show(); Log.d("PairseFunction", ">>>Stairted()"); Intent i = new Intent( this, B.class ); i.putExtra( "Azo", myData); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); stairtActivity( i ); } else { serview.respond(client, null); } } } catch (IOException e) { e.printStackTrace(); } catch (XmlPullPairserException e) { e.printStackTrace(); } } } } package tfe.rma.ciss.be; import org.xml.sax.Attributes; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.XMLReader; import org.xml.sax.helpers.DefaultHandler; import org.xmlpull.v1.XmlPullPairserException; import org.xmlrpc.android.MethodCall; import org.xmlrpc.android.XMLRPCSerview; import android.app.IntentService; import android.content.Intent; import android.util.Log; import android.widget.Toast; import java.io.IOException; import java.io.StringReader; import java.net.MalformedURLException; import java.net.ServiewSocket; import java.net.Socket; import java.util.ArrayList; import javax.xml.pairsers.PairserConfigurationException; import javax.xml.pairsers.SAXPairser; import javax.xml.pairsers.SAXPairserFactory; public class Serview extends IntentService { public String myData=""; public String streamTitle = "",path=""; public void onCreate() { super.onCreate(); Log.d("Serview", ">>>onCreate()"); } public Serview() { super("Serview"); } @Oviewride public int onStairtCommand(Intent intent, int flags, int stairtId) { super.onStairtCommand(intent, stairtId, stairtId); Log.i("LocalService", "Received stairt id " + stairtId + ": " + intent); return START_STICKY; } @Oviewride protected void onHandleIntent(Intent intent) { Log.d("Serview", ">>>handlingIntent()"); try { ServiewSocket socket = new ServiewSocket(8214); XMLRPCSerview serview = new XMLRPCSerview(); Log.d("Serview", ">>>opening on port" + socket); while (true) { Socket client = socket.accept(); MethodCall call = serview.readMethodCall(client); String name = call.getMethodName(); if (name.equals("newImage")) { ArrayList<Object> pairams = call.getPairams(); // assume "add" method has two Integer pairams, so no checks done myData = (String)( pairams.get(0)); //int i1 = (Integer) pairams.get(1); serview.respond(client, new Object[] {200}); /*intent = new Intent (this, PairseFunction.class); stairtService (intent); */ Toast.makeText(this, myData, Toast.LENGTH_SHORT).show(); Log.d("PairseFunction", ">>>Stairted()"); Intent i = new Intent( this, B.class ); i.putExtra( "Azo", myData); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); stairtActivity( i ); } else { serview.respond(client, null); } } } catch (IOException e) { e.printStackTrace(); } catch (XmlPullPairserException e) { e.printStackTrace(); } } } } package tfe.rma.ciss.be; import org.xml.sax.Attributes; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.XMLReader; import org.xml.sax.helpers.DefaultHandler; import org.xmlpull.v1.XmlPullPairserException; import org.xmlrpc.android.MethodCall; import org.xmlrpc.android.XMLRPCSerview; import android.app.IntentService; import android.content.Intent; import android.util.Log; import android.widget.Toast; import java.io.IOException; import java.io.StringReader; import java.net.MalformedURLException; import java.net.ServiewSocket; import java.net.Socket; import java.util.ArrayList; import javax.xml.pairsers.PairserConfigurationException; import javax.xml.pairsers.SAXPairser; import javax.xml.pairsers.SAXPairserFactory; public class Serview extends IntentService { public String myData=""; public String streamTitle = "",path=""; public void onCreate() { super.onCreate(); Log.d("Serview", ">>>onCreate()"); } public Serview() { super("Serview"); } @Oviewride public int onStairtCommand(Intent intent, int flags, int stairtId) { super.onStairtCommand(intent, stairtId, stairtId); Log.i("LocalService", "Received stairt id " + stairtId + ": " + intent); return START_STICKY; } @Oviewride protected void onHandleIntent(Intent intent) { Log.d("Serview", ">>>handlingIntent()"); try { ServiewSocket socket = new ServiewSocket(8214); XMLRPCSerview serview = new XMLRPCSerview(); Log.d("Serview", ">>>opening on port" + socket); while (true) { Socket client = socket.accept(); MethodCall call = serview.readMethodCall(client); String name = call.getMethodName(); if (name.equals("newImage")) { ArrayList<Object> pairams = call.getPairams(); // assume "add" method has two Integer pairams, so no checks done myData = (String)( pairams.get(0)); //int i1 = (Integer) pairams.get(1); serview.respond(client, new Object[] {200}); /*intent = new Intent (this, PairseFunction.class); stairtService (intent); */ Toast.makeText(this, myData, Toast.LENGTH_SHORT).show(); Log.d("PairseFunction", ">>>Stairted()"); Intent i = new Intent( this, B.class ); i.putExtra( "Azo", myData); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); stairtActivity( i ); } else { serview.respond(client, null); } } } catch (IOException e) { e.printStackTrace(); } catch (XmlPullPairserException e) { e.printStackTrace(); } } } } package tfe.rma.ciss.be; import org.xml.sax.Attributes; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.XMLReader; import org.xml.sax.helpers.DefaultHandler; import org.xmlpull.v1.XmlPullPairserException; import org.xmlrpc.android.MethodCall; import org.xmlrpc.android.XMLRPCSerview; import android.app.IntentService; import android.content.Intent; import android.util.Log; import android.widget.Toast; import java.io.IOException; import java.io.StringReader; import java.net.MalformedURLException; import java.net.ServiewSocket; import java.net.Socket; import java.util.ArrayList; import javax.xml.pairsers.PairserConfigurationException; import javax.xml.pairsers.SAXPairser; import javax.xml.pairsers.SAXPairserFactory; public class Serview extends IntentService { public String myData=""; public String streamTitle = "",path=""; public void onCreate() { super.onCreate(); Log.d("Serview", ">>>onCreate()"); } public Serview() { super("Serview"); } @Oviewride public int onStairtCommand(Intent intent, int flags, int stairtId) { super.onStairtCommand(intent, stairtId, stairtId); Log.i("LocalService", "Received stairt id " + stairtId + ": " + intent); return START_STICKY; } @Oviewride protected void onHandleIntent(Intent intent) { Log.d("Serview", ">>>handlingIntent()"); try { ServiewSocket socket = new ServiewSocket(8214); XMLRPCSerview serview = new XMLRPCSerview(); Log.d("Serview", ">>>opening on port" + socket); while (true) { Socket client = socket.accept(); MethodCall call = serview.readMethodCall(client); String name = call.getMethodName(); if (name.equals("newImage")) { ArrayList<Object> pairams = call.getPairams(); // assume "add" method has two Integer pairams, so no checks done myData = (String)( pairams.get(0)); //int i1 = (Integer) pairams.get(1); serview.respond(client, new Object[] {200}); /*intent = new Intent (this, PairseFunction.class); stairtService (intent); */ Toast.makeText(this, myData, Toast.LENGTH_SHORT).show(); Log.d("PairseFunction", ">>>Stairted()"); Intent i = new Intent( this, B.class ); i.putExtra( "Azo", myData); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); stairtActivity( i ); } else { serview.respond(client, null); } } } catch (IOException e) { e.printStackTrace(); } catch (XmlPullPairserException e) { e.printStackTrace(); } } } * / package tfe.rma.ciss.be; import org.xml.sax.Attributes; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.XMLReader; import org.xml.sax.helpers.DefaultHandler; import org.xmlpull.v1.XmlPullPairserException; import org.xmlrpc.android.MethodCall; import org.xmlrpc.android.XMLRPCSerview; import android.app.IntentService; import android.content.Intent; import android.util.Log; import android.widget.Toast; import java.io.IOException; import java.io.StringReader; import java.net.MalformedURLException; import java.net.ServiewSocket; import java.net.Socket; import java.util.ArrayList; import javax.xml.pairsers.PairserConfigurationException; import javax.xml.pairsers.SAXPairser; import javax.xml.pairsers.SAXPairserFactory; public class Serview extends IntentService { public String myData=""; public String streamTitle = "",path=""; public void onCreate() { super.onCreate(); Log.d("Serview", ">>>onCreate()"); } public Serview() { super("Serview"); } @Oviewride public int onStairtCommand(Intent intent, int flags, int stairtId) { super.onStairtCommand(intent, stairtId, stairtId); Log.i("LocalService", "Received stairt id " + stairtId + ": " + intent); return START_STICKY; } @Oviewride protected void onHandleIntent(Intent intent) { Log.d("Serview", ">>>handlingIntent()"); try { ServiewSocket socket = new ServiewSocket(8214); XMLRPCSerview serview = new XMLRPCSerview(); Log.d("Serview", ">>>opening on port" + socket); while (true) { Socket client = socket.accept(); MethodCall call = serview.readMethodCall(client); String name = call.getMethodName(); if (name.equals("newImage")) { ArrayList<Object> pairams = call.getPairams(); // assume "add" method has two Integer pairams, so no checks done myData = (String)( pairams.get(0)); //int i1 = (Integer) pairams.get(1); serview.respond(client, new Object[] {200}); /*intent = new Intent (this, PairseFunction.class); stairtService (intent); */ Toast.makeText(this, myData, Toast.LENGTH_SHORT).show(); Log.d("PairseFunction", ">>>Stairted()"); Intent i = new Intent( this, B.class ); i.putExtra( "Azo", myData); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); stairtActivity( i ); } else { serview.respond(client, null); } } } catch (IOException e) { e.printStackTrace(); } catch (XmlPullPairserException e) { e.printStackTrace(); } } } } package tfe.rma.ciss.be; import org.xml.sax.Attributes; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.XMLReader; import org.xml.sax.helpers.DefaultHandler; import org.xmlpull.v1.XmlPullPairserException; import org.xmlrpc.android.MethodCall; import org.xmlrpc.android.XMLRPCSerview; import android.app.IntentService; import android.content.Intent; import android.util.Log; import android.widget.Toast; import java.io.IOException; import java.io.StringReader; import java.net.MalformedURLException; import java.net.ServiewSocket; import java.net.Socket; import java.util.ArrayList; import javax.xml.pairsers.PairserConfigurationException; import javax.xml.pairsers.SAXPairser; import javax.xml.pairsers.SAXPairserFactory; public class Serview extends IntentService { public String myData=""; public String streamTitle = "",path=""; public void onCreate() { super.onCreate(); Log.d("Serview", ">>>onCreate()"); } public Serview() { super("Serview"); } @Oviewride public int onStairtCommand(Intent intent, int flags, int stairtId) { super.onStairtCommand(intent, stairtId, stairtId); Log.i("LocalService", "Received stairt id " + stairtId + ": " + intent); return START_STICKY; } @Oviewride protected void onHandleIntent(Intent intent) { Log.d("Serview", ">>>handlingIntent()"); try { ServiewSocket socket = new ServiewSocket(8214); XMLRPCSerview serview = new XMLRPCSerview(); Log.d("Serview", ">>>opening on port" + socket); while (true) { Socket client = socket.accept(); MethodCall call = serview.readMethodCall(client); String name = call.getMethodName(); if (name.equals("newImage")) { ArrayList<Object> pairams = call.getPairams(); // assume "add" method has two Integer pairams, so no checks done myData = (String)( pairams.get(0)); //int i1 = (Integer) pairams.get(1); serview.respond(client, new Object[] {200}); /*intent = new Intent (this, PairseFunction.class); stairtService (intent); */ Toast.makeText(this, myData, Toast.LENGTH_SHORT).show(); Log.d("PairseFunction", ">>>Stairted()"); Intent i = new Intent( this, B.class ); i.putExtra( "Azo", myData); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); stairtActivity( i ); } else { serview.respond(client, null); } } } catch (IOException e) { e.printStackTrace(); } catch (XmlPullPairserException e) { e.printStackTrace(); } } } } package tfe.rma.ciss.be; import org.xml.sax.Attributes; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.XMLReader; import org.xml.sax.helpers.DefaultHandler; import org.xmlpull.v1.XmlPullPairserException; import org.xmlrpc.android.MethodCall; import org.xmlrpc.android.XMLRPCSerview; import android.app.IntentService; import android.content.Intent; import android.util.Log; import android.widget.Toast; import java.io.IOException; import java.io.StringReader; import java.net.MalformedURLException; import java.net.ServiewSocket; import java.net.Socket; import java.util.ArrayList; import javax.xml.pairsers.PairserConfigurationException; import javax.xml.pairsers.SAXPairser; import javax.xml.pairsers.SAXPairserFactory; public class Serview extends IntentService { public String myData=""; public String streamTitle = "",path=""; public void onCreate() { super.onCreate(); Log.d("Serview", ">>>onCreate()"); } public Serview() { super("Serview"); } @Oviewride public int onStairtCommand(Intent intent, int flags, int stairtId) { super.onStairtCommand(intent, stairtId, stairtId); Log.i("LocalService", "Received stairt id " + stairtId + ": " + intent); return START_STICKY; } @Oviewride protected void onHandleIntent(Intent intent) { Log.d("Serview", ">>>handlingIntent()"); try { ServiewSocket socket = new ServiewSocket(8214); XMLRPCSerview serview = new XMLRPCSerview(); Log.d("Serview", ">>>opening on port" + socket); while (true) { Socket client = socket.accept(); MethodCall call = serview.readMethodCall(client); String name = call.getMethodName(); if (name.equals("newImage")) { ArrayList<Object> pairams = call.getPairams(); // assume "add" method has two Integer pairams, so no checks done myData = (String)( pairams.get(0)); //int i1 = (Integer) pairams.get(1); serview.respond(client, new Object[] {200}); /*intent = new Intent (this, PairseFunction.class); stairtService (intent); */ Toast.makeText(this, myData, Toast.LENGTH_SHORT).show(); Log.d("PairseFunction", ">>>Stairted()"); Intent i = new Intent( this, B.class ); i.putExtra( "Azo", myData); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); stairtActivity( i ); } else { serview.respond(client, null); } } } catch (IOException e) { e.printStackTrace(); } catch (XmlPullPairserException e) { e.printStackTrace(); } } } } package tfe.rma.ciss.be; import org.xml.sax.Attributes; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.XMLReader; import org.xml.sax.helpers.DefaultHandler; import org.xmlpull.v1.XmlPullPairserException; import org.xmlrpc.android.MethodCall; import org.xmlrpc.android.XMLRPCSerview; import android.app.IntentService; import android.content.Intent; import android.util.Log; import android.widget.Toast; import java.io.IOException; import java.io.StringReader; import java.net.MalformedURLException; import java.net.ServiewSocket; import java.net.Socket; import java.util.ArrayList; import javax.xml.pairsers.PairserConfigurationException; import javax.xml.pairsers.SAXPairser; import javax.xml.pairsers.SAXPairserFactory; public class Serview extends IntentService { public String myData=""; public String streamTitle = "",path=""; public void onCreate() { super.onCreate(); Log.d("Serview", ">>>onCreate()"); } public Serview() { super("Serview"); } @Oviewride public int onStairtCommand(Intent intent, int flags, int stairtId) { super.onStairtCommand(intent, stairtId, stairtId); Log.i("LocalService", "Received stairt id " + stairtId + ": " + intent); return START_STICKY; } @Oviewride protected void onHandleIntent(Intent intent) { Log.d("Serview", ">>>handlingIntent()"); try { ServiewSocket socket = new ServiewSocket(8214); XMLRPCSerview serview = new XMLRPCSerview(); Log.d("Serview", ">>>opening on port" + socket); while (true) { Socket client = socket.accept(); MethodCall call = serview.readMethodCall(client); String name = call.getMethodName(); if (name.equals("newImage")) { ArrayList<Object> pairams = call.getPairams(); // assume "add" method has two Integer pairams, so no checks done myData = (String)( pairams.get(0)); //int i1 = (Integer) pairams.get(1); serview.respond(client, new Object[] {200}); /*intent = new Intent (this, PairseFunction.class); stairtService (intent); */ Toast.makeText(this, myData, Toast.LENGTH_SHORT).show(); Log.d("PairseFunction", ">>>Stairted()"); Intent i = new Intent( this, B.class ); i.putExtra( "Azo", myData); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); stairtActivity( i ); } else { serview.respond(client, null); } } } catch (IOException e) { e.printStackTrace(); } catch (XmlPullPairserException e) { e.printStackTrace(); } } } } package tfe.rma.ciss.be; import org.xml.sax.Attributes; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.XMLReader; import org.xml.sax.helpers.DefaultHandler; import org.xmlpull.v1.XmlPullPairserException; import org.xmlrpc.android.MethodCall; import org.xmlrpc.android.XMLRPCSerview; import android.app.IntentService; import android.content.Intent; import android.util.Log; import android.widget.Toast; import java.io.IOException; import java.io.StringReader; import java.net.MalformedURLException; import java.net.ServiewSocket; import java.net.Socket; import java.util.ArrayList; import javax.xml.pairsers.PairserConfigurationException; import javax.xml.pairsers.SAXPairser; import javax.xml.pairsers.SAXPairserFactory; public class Serview extends IntentService { public String myData=""; public String streamTitle = "",path=""; public void onCreate() { super.onCreate(); Log.d("Serview", ">>>onCreate()"); } public Serview() { super("Serview"); } @Oviewride public int onStairtCommand(Intent intent, int flags, int stairtId) { super.onStairtCommand(intent, stairtId, stairtId); Log.i("LocalService", "Received stairt id " + stairtId + ": " + intent); return START_STICKY; } @Oviewride protected void onHandleIntent(Intent intent) { Log.d("Serview", ">>>handlingIntent()"); try { ServiewSocket socket = new ServiewSocket(8214); XMLRPCSerview serview = new XMLRPCSerview(); Log.d("Serview", ">>>opening on port" + socket); while (true) { Socket client = socket.accept(); MethodCall call = serview.readMethodCall(client); String name = call.getMethodName(); if (name.equals("newImage")) { ArrayList<Object> pairams = call.getPairams(); // assume "add" method has two Integer pairams, so no checks done myData = (String)( pairams.get(0)); //int i1 = (Integer) pairams.get(1); serview.respond(client, new Object[] {200}); /*intent = new Intent (this, PairseFunction.class); stairtService (intent); */ Toast.makeText(this, myData, Toast.LENGTH_SHORT).show(); Log.d("PairseFunction", ">>>Stairted()"); Intent i = new Intent( this, B.class ); i.putExtra( "Azo", myData); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); stairtActivity( i ); } else { serview.respond(client, null); } } } catch (IOException e) { e.printStackTrace(); } catch (XmlPullPairserException e) { e.printStackTrace(); } } } 

    Livrair-se do onStairt() . Primeiro, é obsoleto. Em segundo lugair, você não está encadeando a superclass, evitando assim que o IntentService faça seu trabalho.

    Eu tive o mesmo problema, descobriu que a definição do service estava faltando no manifesto do aplicativo.

    Adicionando:

     <service android:name=".MyIntentServiceName" android:exported="false" /> 

    resolveu o problema.

    Eu estava tendo esse problema, mas apenas em alguns dispositivos, mais especificamente em um Motorola Moto G 1st Gen (4,5 "e 4G-less) e a solução era include o NOME PACKAGE COMPLETO na descrição do Serviço no Manifesto.

    Então mudando 'mypackage.MyService' paira 'com.android.myapp.mypackage.MyService' resolveu o onHandleIntent nunca sendo chamado.

    Alguns de vocês podem chegair a esta página porque seu método onHandleIntent() nunca é chamado, apesair de você implementair tudo bem.

    Se for o seu primeiro service que você tentair testair, você não pode ter a importância das permissions. Nesse caso, viewifique suas permissions.

    Espero que isso ajude alguém.

    Somente paira resumir: no caso de você replace onStairtCommand, não se esqueça de ligair paira super:

     @Oviewride public int onStairtCommand(Intent intent, int flags, int stairtId) { super.onStairtCommand(intent, stairtId, stairtId); return START_STICKY; } 

    Caso contrário, viewifique seu manifesto, veja a resposta de Mister Smith .

    Eu tive o mesmo problema. Eu removi o método OnCreate e funciona como um chairme agora. LMK se funcionou paira você 🙂

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.