2016-12-29 20 views
1

twilioを呼び出すための実装では、twilioロジックの代わりに放送受信機を使用しようとしています。私の放送受信機はonReceive()を介してインテントを捕まえることになっていますが、実際には受信しません。 コールが聞こえます!しかし、イベントをキャッチし、私のbroadcastreceiver(TwilioBroadCastReceiver)が含まれている私の活動の中twitterで放送されていない放送受信機

を続行できません。私の活動の

@Override 
public void onReceive(Context context, Intent intent) { 
     if (intent != null) { 
     /* 
     * Determine if the receiving Intent has an extra for the incoming connection. If so, 
     * remove it from the Intent to prevent handling it again next time the Activity is resumed 
     */ 
     Device device = intent.getParcelableExtra(Device.EXTRA_DEVICE); 
     Connection incomingConnection = intent.getParcelableExtra(Device.EXTRA_CONNECTION); 

     if (incomingConnection == null && device == null) { 
      return; 
     } 
     intent.removeExtra(Device.EXTRA_DEVICE); 
     intent.removeExtra(Device.EXTRA_CONNECTION); 

     pendingConnection = incomingConnection; 
     pendingConnection.setConnectionListener(this); 
     showIncomingDialog(); 
    } 
} 

private void createDevice(String capabilityToken) { 
    try { 
     if (clientDevice == null) { 
      clientDevice = Twilio.createDevice(capabilityToken, this); 
      Intent intent = new Intent(mActivity, TwilioBroadcastReceiver.class); 
      PendingIntent pendingIntent = PendingIntent.getBroadcast(mActivity, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); 
      clientDevice.setIncomingIntent(pendingIntent); 
     } else { 
      clientDevice.updateCapabilityToken(capabilityToken); 
     } 

    } catch (Exception e) { 
     Log.e(TAG, "An error has occured updating or creating a Device: \n" + e.toString()); 
     Toast.makeText(mActivity, "Device error", Toast.LENGTH_SHORT).show(); 
    } 
} 

を:

mReceiver = new TwilioBroadcastReceiver(this, clientProfile); 

誰かがANを持っていますアイディア ? tks

マニフェスト、hummm ....何かが不足しているようですか?

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
package="client.twilio.com.quickstart"> 

<!-- needed for monitoring network availability --> 
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> 
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/> 

<!-- needed for processing on the network --> 
<uses-permission android:name="android.permission.INTERNET"/> 

<!-- needed to enable/disable the speakerphone --> 
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/> 

<!-- needed to receive audio from microphone during a call --> 
<uses-permission android:name="android.permission.RECORD_AUDIO"/> 

<application 
    android:allowBackup="true" 
    android:icon="@mipmap/ic_launcher" 
    android:label="@string/app_name" 
    android:supportsRtl="true" 
    android:theme="@style/AppTheme"> 
    <activity android:name=".ClientActivity" 
     android:screenOrientation="portrait" 
     android:launchMode="singleTop"> 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 

      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
    </activity> 

    <service android:name="com.twilio.client.TwilioClientService" android:exported="false" android:stopWithTask="true"/> 
</application> 


</manifest> 
+0

あなたの活動にあなたの放送を登録しましたか?もしそうでなければ、この投稿をチェックしてください。http://stackoverflow.com/questions/4805269/programmatically-register-a-broadcast-receiver – AndroidRuntimeException

+0

私もこれについて考えました。私は私のためにそれを行う必要がありますTwilio Sdkを使用します:PendingIntent pendingIntent = PendingIntent.getBroadcast(mActivity.getApplicationContext()、0、intent、PendingIntent.FLAG_UPDATE_CURRENT); – marc

+0

....これ以外にも、登録するフィルター仕様はありません。 – marc

答えて

1

あなたがマニフェストにBroadcastReceiverを持っている必要があります:

<receiver android:name=".TwilioBroadcastReceiver"/> 

そうでない場合は、TwilioのアプリケーションがそれにPendingIntentを配信することはできません。 <receiver>にはIntentを明示的に指定しているため、<intent-filter>は必要ありません。

関連する問題