1

こんにちはすべて私のアプリですべての着信に応答するアンドロイドアプリを作っています。 以下ロリポップだけでなく、マシュマロのためにそれを行うにしたいと上記の、私はR & Dの多くをしましたが、任意の満足解決策を見つけていないので、私はコードの下に自分のmarshmallow以上のAndroidでプログラムで着信コールに応答するにはどうすればいいですか?(セキュリティパッチの更新日の1/09/16)

は、上記のマシュマロとのために働いていない私のことで求めています。 このコードはLolipopまで動作しています。

private void acceptCall_n() { 

      // for HTC devices we need to broadcast a connected headset 
      boolean broadcastConnected = MANUFACTURER_HTC.equalsIgnoreCase(Build.MANUFACTURER) 
        && !audioManager.isWiredHeadsetOn(); 



      if (broadcastConnected) { 
       broadcastHeadsetConnected(false); 
      } 

      try { 

       try { 
        // logger.debug("execute input keycode headset hook"); 
        Runtime.getRuntime().exec("input keyevent " + 
          Integer.toString(KeyEvent.KEYCODE_HEADSETHOOK)); 


       } catch (IOException e) { 

        Log.e("Call Exception ",e.toString()); 
        HelperMethods.showToastS(getBaseContext(),"Call Exception one "+e.toString()); 
        // Runtime.exec(String) had an I/O problem, try to fall back 
        // logger.debug("send keycode headset hook intents"); 
        String enforcedPerm = "android.permission.CALL_PRIVILEGED"; 
        Intent btnDown = new Intent(Intent.ACTION_MEDIA_BUTTON).putExtra(
          Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_DOWN, 
            KeyEvent.KEYCODE_HEADSETHOOK)); 
        Intent btnUp = new Intent(Intent.ACTION_MEDIA_BUTTON).putExtra(
          Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_UP, 
            KeyEvent.KEYCODE_HEADSETHOOK)); 

        sendOrderedBroadcast(btnDown, enforcedPerm); 
        sendOrderedBroadcast(btnUp, enforcedPerm); 
       } 
      }catch (Exception e){ 
       e.printStackTrace(); 
       Log.e("Call Exception two",e.toString()); 
       HelperMethods.showToastS(getBaseContext(),"Call Exception two "+e.toString()); 
      }finally { 
       if (broadcastConnected) { 
        broadcastHeadsetConnected(false); 
       } 
      } 
     } 

答えて

0

私は同じ問題に直面しました。根本的な原因は、実行中のコマンドがSELinuxルールで許可されていないことです。 thisソリューションを使用してみてください。私はAndroid Marshmallowでそれをテストしました。

+0

https://stackoverflow.com/help/how-to-answerの品質に関する回答を参照してください。 – jagapathi