Guest User

Untitled

a guest
Oct 19th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.10 KB | None | 0 0
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  3. package="com.reporting2you.r2ym">
  4.  
  5. <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
  6. <uses-permission android:name="android.permission.READ_PHONE_STATE" />
  7.  
  8. <application
  9. android:allowBackup="true"
  10. android:icon="@mipmap/ic_launcher"
  11. android:label="@string/app_name"
  12. android:roundIcon="@mipmap/ic_launcher_round"
  13. android:supportsRtl="true"
  14. android:theme="@style/AppTheme">
  15. <activity android:name=".MainActivity">
  16. <intent-filter>
  17. <action android:name="android.intent.action.MAIN" />
  18.  
  19. <category android:name="android.intent.category.LAUNCHER" />
  20. </intent-filter>
  21. </activity>
  22.  
  23. <service
  24. android:name="com.reporting2you.services.FloatingViewService"
  25. android:enabled="true"
  26. android:exported="false" />
  27.  
  28. <activity android:name=".FloatingActivity" />
  29.  
  30. <receiver
  31. android:name="com.reporting2you.broadcastReceiver.CallReceiver"
  32. android:enabled="true"
  33. android:exported="true">
  34. <intent-filter>
  35. <action android:name="android.intent.action.PHONE_STATE" />
  36. </intent-filter>
  37. </receiver>
  38. </application>
  39.  
  40. </manifest>
  41.  
  42. public class CallReceiver extends BroadcastReceiver {
  43.  
  44. @Override
  45. public void onReceive(Context context, Intent intent) {
  46. Bundle extras = intent.getExtras();
  47. if (extras != null) {
  48. String state = extras.getString(TelephonyManager.EXTRA_STATE);
  49. Log.w("MY_DEBUG_TAG", state);
  50. if (state.equals(TelephonyManager.EXTRA_STATE_RINGING)) {
  51. context.startActivity(new Intent(context, FloatingActivity.class));
  52. ((MainActivity)context).finish();
  53. String phoneNumber = extras
  54. .getString(TelephonyManager.EXTRA_INCOMING_NUMBER);
  55. Log.w("MY_DEBUG_TAG", phoneNumber);
  56. }
  57. }
  58.  
  59. }
  60. }
Add Comment
Please, Sign In to add comment