Guest User

Untitled

a guest
Jan 23rd, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.39 KB | None | 0 0
  1. <application
  2. android:allowBackup="true"
  3. android:icon="@mipmap/ic_launcher"
  4. android:label="@string/app_name"
  5. android:supportsRtl="true"
  6. android:theme="@style/AppTheme">
  7. <activity
  8. android:name=".MainActivity"
  9. android:exported="true">
  10. <intent-filter>
  11. <action android:name="android.intent.action.MAIN" />
  12.  
  13. <category android:name="android.intent.category.LAUNCHER" />
  14. </intent-filter>
  15. </activity>
  16.  
  17.  
  18.  
  19. <receiver android:name=".BlockCallReceiver" android:exported="true">
  20. <intent-filter>
  21. <action android:name="android.intent.action.PHONE_STATE" />
  22. <action android:name="android.intent.action.USER_PRESENT" />
  23. <category android:name="android.intent.category.DEFAULT" />
  24. </intent-filter>
  25. </receiver>
  26.  
  27.  
  28.  
  29. </application>
  30.  
  31. public class PhoneStateReceiver extends BroadcastReceiver {
  32. public void onReceive(Context context, Intent intent) {
  33. // TODO Auto-generated method stub
  34. String str = intent.getAction();
  35. if ("android.intent.action.PHONE_STATE".equals(str))
  36. inComing(context, intent);
  37.  
  38. if ("android.intent.action.NEW_OUTGOING_CALL".equals(str))
  39. outGoing(context, intent);
  40. }
  41.  
  42. private void inComing(Context context, Intent intent){
  43. String callState = intent.getStringExtra("state");
  44. if ("RINGING".equals(callState)){
  45. Log.i(TAG, "RINGING SENDS BUSY");
  46. }else if ("OFFHOOK".equals(callState)){
  47. Log.i(TAG, "OFFHOOK SENDS BUSY");
  48. }else if("IDLE".equals(callState)){
  49. Log.i(TAG, "IDLE SENDS AVAILABLE");
  50. }
  51. }
  52.  
  53. private void trueCallerOutgoing(Context context, Intent intent)
  54. {
  55. String callState = intent.getStringExtra("state");
  56. if ("RINGING".equals(callState)){
  57. Log.i(TAG, "RINGING SENDS BUSY");
  58. }else if ("OFFHOOK".equals(callState)){
  59. Log.i(TAG, "OFFHOOK SENDS BUSY");
  60. }else if("IDLE".equals(callState)){
  61. Log.i(TAG, "IDLE SENDS AVAILABLE");
  62. }
  63. }
  64. }
  65.  
  66. <receiver android:name="PhoneStateReceiver" >
  67. <intent-filter>
  68. <action android:name="android.intent.action.PHONE_STATE" />
  69. <action android:name="android.intent.action.NEW_OUTGOING_CALL" />
  70. </intent-filter>
  71. </receiver>
  72.  
  73. <uses-permission android:name="android.permission.READ_PHONE_STATE" />
Add Comment
Please, Sign In to add comment