无法启动服务 Intent flg=0x10000000 cmp=com.company.callrecorder/.CallStateListener :未找到

Posted

技术标签:

【中文标题】无法启动服务 Intent flg=0x10000000 cmp=com.company.callrecorder/.CallStateListener :未找到【英文标题】:Unable to start service Intent flg=0x10000000 cmp=com.company.callrecorder/.CallStateListener : not found无法启动服务 Intent flg=0x10000000 cmp=com.company.callrecorder/.CallStateListener :未找到 【发布时间】:2011-12-05 06:13:20 【问题描述】:

我正在尝试记录通话。但是启动服务意图有一个大问题。

WARN/ActivityManager(61):无法启动服务 Intent flg=0x10000000 >cmp=com.company.callrecorder/.CallStateListener :未找到

这是我的广播接收器代码:

        public class StartServicesAtStartUp extends BroadcastReceiver

公共静态意图phoneStateListener; public void onReceive(上下文上下文,意图) Log.d("DEBUG", "com.its.CallRecorder Initiated ..."); Toast.makeText(context,"通话录音已启动..", Toast.LENGTH_SHORT).show(); Start_CallRec(上下文);

    public static void Start_CallRec(Context context)
    
        if(!SharedData._Started )
        
            if(SharedData._AutoStart)
            
                Toast.makeText(context," Call Recording Auto-Start.. ", Toast.LENGTH_SHORT).show();
                phoneStateListener = new Intent(context, CallStateListener.class);
                phoneStateListener.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                context.startService(phoneStateListener);
                Log.d("DEBUG", "com.its.CallRecorder Call Recorder Started ...");
                TelephonyManager tManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
                CallStateListener callStateListener = new CallStateListener();
                tManager.listen(callStateListener,PhoneStateListener.LISTEN_CALL_STATE);
                SharedData._Started = true;
                Toast.makeText(context," Call Recording Started ... ", Toast.LENGTH_SHORT).show();
               
        
        else
        
            Toast.makeText(context," Call Recording Already Active.. ", Toast.LENGTH_SHORT).show();
        
    

    public static void Stop_CallRec(Context context)
    
        if(SharedData._Started )
        
            context.stopService(phoneStateListener);
            Toast.makeText(context," Call Recording Stopped  ... ", Toast.LENGTH_SHORT).show();
            SharedData._Started = false;                
        
        else
        
            Toast.makeText(context," Call Recording Already Stopped  ... ",  Toast.LENGTH_SHORT).show();
        
    

而CallStateListener.java代码是:

public class CallStateListener extends PhoneStateListener 
public void onCallStateChanged(int state, String incomingNumber)

    super.onCallStateChanged(state, incomingNumber);
    switch(state)
    
    case TelephonyManager.CALL_STATE_IDLE:
        if(SharedData._Recording) 
             Recorders_Stop(); 
        break;
    case TelephonyManager.CALL_STATE_RINGING:
        break;
    case TelephonyManager.CALL_STATE_OFFHOOK:
        String CallDate = SanityDate();
        String CallNum = SanityNum(incomingNumber);
        String RootDir = SharedData._Path ;  
        String CallDir = SharedData._Path + CallNum + "/" ;
        String CallFile = SharedData._Path +  CallNum + "/" + CallNum + "-" + CallDate ;
        if(!SharedData._Recording)
        
            SharedData._Recording = true;
            String med_state = android.os.Environment.getExternalStorageState();
            if(!med_state.equals(android.os.Environment.MEDIA_MOUNTED))
                 break; 

            File directory = null;
            directory = new File(RootDir + "text.txt" ).getParentFile();
            if (!directory.exists() && !directory.mkdirs())
                 break; 

            directory = new File(CallDir + "text.txt" ).getParentFile();
            if (!directory.exists() && !directory.mkdirs())
                 break; 

            Recoders_Init(CallFile);
            Recorder_Prepare();
        

        break;
    

【问题讨论】:

【参考方案1】:

我正在尝试记录通话。

这是不可能的,除非在免提模式下。

但是启动服务意图有一个大问题。

那是因为您没有Service。你有一个BroadcastReceiverBroadcastReceiver 不是 Service。您不能使用 Intent 标识 BroadcastReceiver 来调用 startService()

【讨论】:

感谢您的回答 CommonsWare。我在不使用免提电话的情况下使用此代码成功录制了通话。该问题基于不同类型的录制,例如:.3gp、.mp4 和 .amr。当我解决了重启mediarecorder的问题后,问题自然解决了。

以上是关于无法启动服务 Intent flg=0x10000000 cmp=com.company.callrecorder/.CallStateListener :未找到的主要内容,如果未能解决你的问题,请参考以下文章

接收广播Intent时出错{act = android.location.PROVIDERS_CHANGED flg = 0x10}

无法恢复活动:不允许启动服务 Intent,应用程序在后台

错误0x80070422:无法启动服务器,原因肯能是已被禁用或与其相关联的设备没有启动

无法从服务启动前台通知?

Android 8.0:java.lang.IllegalStateException:不允许启动服务 Intent

launchMode 为 singleTask 的 Activity 的两个实例