广播接收方来电(获取两次来电号码)

时间:2015-10-16 10:59:45

标签: android broadcastreceiver incoming-call

为什么我两次收到来电号码?随着传出的细节它正常工作,但它只有一次,但我不知道传入的细节会发生什么。任何人都可以帮助我吗?

 public void onReceive(Context context, Intent intent) {

    Log.d("APP", "ACTION:" + intent.getAction());
    //this.context = context;
    final String stringExtra = intent.getStringExtra(TelephonyManager.EXTRA_STATE);

    if (Intent.ACTION_NEW_OUTGOING_CALL.equals(intent.getAction())){
        //outgoing call
        number=intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
        Log.i("tag", "Outgoing number : " +number);
        currentDateTimeString = DateFormat.getDateTimeInstance().format(new Date());
        Log.i("tag", "Date :" + currentDateTimeString);
       //doSaveCallRecord(1);
        Log.i("tag", "USER ID :" + context.getSharedPreferences("APPLICATION",Context.MODE_PRIVATE).getString(UserConstants.ID,null)+"");
    }
    if (TelephonyManager.EXTRA_STATE_RINGING.equals(stringExtra)) {
        final String incomingNumber = intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER);
        Log.d("APP", "incoming,ringing:" + incomingNumber);
        //doSaveCallRecord(0);
    }
}
<receiver android:name=".MyCallReceiver" > 
      <intent-filter> 
          <action android:name="android.intent.action.NEW_OUTGOING_CALL"/> 
          <action android:name="android.intent.action.PHONE_STATE"/> 
      </intent-filter>
</receiver>

1 个答案:

答案 0 :(得分:0)

以下是我检查传入号码到特定号码的代码:

WARN  [org.jboss.seam.Component] (http-cc850.company.com%2F10.129.201.221-8080-59) Exception calling stateful session bean default @Remove method: org.jboss.seam.transaction.synchronizations
javax.ejb.NoSuchEJBException: Could not find stateful bean: a3l5l65-rkshdp-ifsi9fz3-1-iftez6r5-pkp
  at org.jboss.ejb3.cache.simple.SimpleStatefulCache.get(SimpleStatefulCache.java:479)
  at org.jboss.ejb3.cache.simple.SimpleStatefulCache.get(SimpleStatefulCache.java:430)
  at org.jboss.ejb3.stateful.StatefulInstanceInterceptor.invoke(StatefulInstanceInterceptor.java:59)
  at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
  at org.jboss.ejb3.stateful.StatefulRemoveInterceptor.invoke(StatefulRemoveInterceptor.java:100)
  at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
  at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
  at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:190)
  at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
  at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
  at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
  at org.jboss.ejb3.tx.NullInterceptor.invoke(NullInterceptor.java:42)
  at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
  at org.jboss.ejb3.security.Ejb3AuthenticationInterceptorv2.invoke(Ejb3AuthenticationInterceptorv2.java:186)
  at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
  at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:41)
  at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
  at org.jboss.ejb3.BlockContainerShutdownInterceptor.invoke(BlockContainerShutdownInterceptor.java:67)
  at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
  at org.jboss.aspects.currentinvocation.CurrentInvocationInterceptor.invoke(CurrentInvocationInterceptor.java:67)
  at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
  at org.jboss.ejb3.session.SessionSpecContainer.invoke(SessionSpecContainer.java:176)
  at org.jboss.ejb3.session.SessionSpecContainer.invoke(SessionSpecContainer.java:216)
  at org.jboss.ejb3.proxy.impl.handler.session.SessionProxyInvocationHandlerBase.invoke(SessionProxyInvocationHandlerBase.java:207)
  at org.jboss.ejb3.proxy.impl.handler.session.SessionProxyInvocationHandlerBase.invoke(SessionProxyInvocationHandlerBase.java:164)
  at com.sun.proxy.$Proxy5618.destroy(Unknown Source)
  at sun.reflect.GeneratedMethodAccessor1076.invoke(Unknown Source)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:606)
  at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
  at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:32)
  at org.jboss.seam.intercept.ClientSideInterceptor$1.proceed(ClientSideInterceptor.java:76)
  at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
  at org.jboss.seam.intercept.ClientSideInterceptor.invoke(ClientSideInterceptor.java:54)
  at org.javassist.tmp.java.lang.Object_$$_javassist_seam_20.destroy(Object_$$_javassist_seam_20.java)
  at sun.reflect.GeneratedMethodAccessor1075.invoke(Unknown Source)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:606)
  at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
  at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:144)
  at org.jboss.seam.Component.callComponentMethod(Component.java:2275)
  at org.jboss.seam.Component.callDefaultRemoveMethod(Component.java:2180)
  at org.jboss.seam.Component.destroy(Component.java:1482)
  at org.jboss.seam.contexts.Contexts.destroy(Contexts.java:251)
  at org.jboss.seam.contexts.Contexts.flushAndDestroyContexts(Contexts.java:394)
  at org.jboss.seam.contexts.FacesLifecycle.endRequest(FacesLifecycle.java:129)
  at org.jboss.seam.jsf.SeamPhaseListener.afterResponseComplete(SeamPhaseListener.java:524)
  at org.jboss.seam.jsf.SeamPhaseListener.afterPhase(SeamPhaseListener.java:209)
  at com.sun.faces.lifecycle.Phase.handleAfterPhase(Phase.java:175)
  at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:114)
  at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:103)
  at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
  at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
  at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
  at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
  at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
  at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
  at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
  at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
  at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
  at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
  at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:206)
  at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
  at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
  at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)
  at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
  at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
  at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60)
  at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
  at com.extend.opencase.occ.client.web.filter.WebRequestSecurityFilter.doFilter(WebRequestSecurityFilter.java:50)
  at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
  at com.extend.opencase.occ.client.web.filter.RichFacesFirefox11Filter.doFilter(RichFacesFirefox11Filter.java:57)
  at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
  at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:638)
  at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:446)
  at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:382)
  at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:310)
  at org.apache.catalina.core.StandardHostValve.custom(StandardHostValve.java:416)
  at org.apache.catalina.core.StandardHostValve.status(StandardHostValve.java:342)
  at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:143)
  at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
  at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
  at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
  at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
  at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
  at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
  at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
  at java.lang.Thread.run(Thread.java:745)