Android Question Intercept SMS messages without notification Android 4.4

Discussion in 'Android Questions' started by gawie007, Jan 27, 2014.

  1. gawie007

    gawie007 Member Licensed User

    Hi,

    It appears that the ability to intercept and consume SMS messages will not be allowed from Android 4.4 unless the program that we write is the default SMS App.

    I came across this on my almost fruitless search to try to delete an SMS from the store.
    http://android-developers.blogspot.co.uk/2013/10/getting-your-sms-apps-ready-for-kitkat.html

    My programs will be filling up the SMS stores with meaningless information (to the user) because of this change if my program is not the main receiver OR unless someone has a solution - besides installing older versions of Android.

    What are Google thinking?????
     
  2. qsrtech

    qsrtech Active Member Licensed User

    Looks like they are closing a security hole. Sounds like You'll still be able to get the message. Can you write it to your own store? Definitely gonna put you through a lot of hoops. Are you good at basketball?
     
  3. gawie007

    gawie007 Member Licensed User

    You will still be able to get the messages but can't intercept them and delete them before they get broadcast unless your App is the main App receiving the SMS. You then also have to deal with broadcasts etc.
    I have been able to get the message and prevent the phone from making a noise / flash LED / vibrate etc. now I may not be able to prevent this.
    My messages will still go into my SQLite DB.
    The user then has to go through his messages afterwards and remove each message by hand.

    It will have to be rugby I'm afraid. Will just have to crush their hoops! LOL!
     
  4. marcick

    marcick Well-Known Member Licensed User

    Hi Gavin,
    I'm facing too to this funny trouble .. did you discovered something other ?
    4.4 is not yet available on my HTC One, I'm waiting day by day to be able to download it and then touch with my hands the problem.
    For now I'm just reading about this and what is not clear to me is: what does it mean if let my app become the default SMS app ? Will then the user be able to send /receive messages with the stock SMS app of the phone or not ? I'm a bit confused.
    Marco
     
  5. gawie007

    gawie007 Member Licensed User

    Hi Marco,
    I have not yet pursued this as yet but from what I understand is that if your program takes responsibility for receiving the messages, it must also be responsible for broadcasting them for the rest of the android system to use.
    Unfortunately I haven't tested this myself, like you, I have no 4.4 operating systems as yet.
    Cheers
    Gavin
     
  6. marcick

    marcick Well-Known Member Licensed User

    Hi Gavin,
    but does it mean I have to write a graphic interface also for sending/receiving messages and the default messaging app of the phone becomes unuseful ?
    Marco
     
  7. gawie007

    gawie007 Member Licensed User

    Hi Marco,
    I know what you are saying but from what I can see, it will affect multi media messages.
    Any app can still send SMS's as long as they have permission.
    If you only need to intercept messages without deleting them then you won't need to worry about all of this because you will still be able to read them.
     
  8. marcick

    marcick Well-Known Member Licensed User

    Yes, I need to delete some of them and other nedds to be passed to the messaging application.
    Also I need to send SMS inside my app. So I think I must do modifications to my code, as described in the mentioned link in the first post.

    But .... I still have to understand what does involve if I set my app as default SMS application. Which changes sees the user normally using the phone ?
     
  9. gawie007

    gawie007 Member Licensed User

    Hi Marco,
    All that I know about this is here:
    http://android-developers.blogspot.co.uk/2013/10/getting-your-sms-apps-ready-for-kitkat.html
    I, like you will also need to test this.
    Sorry but I can't help much more than this.
     
  10. marcick

    marcick Well-Known Member Licensed User

    ok, needs to have 4.4 installed and see wwhat happens ...
    Thaks for your chat
    Marco
     
  11. gawie007

    gawie007 Member Licensed User

    No problem, keep us posted if you manage to get it sorted.
     
  12. marcick

    marcick Well-Known Member Licensed User

    Ok. I have installed 4.4 and this is the situation:

    1. I have the SMSinterceptor service that continue intercepting SMS as before.
    2. I'm not able to avoid they are passed to the messaging stock app and avoid the notification. "Return true" has no effect.
    3. I'm not able to delete SMS.
    4. I'm not able to send SMS with te code I was using before:

    Code:
    Sub SendSms(PhoneNumber As String, Text As String)
       
        
    Dim ps As PhoneSms   
        ps.Send2(PhoneNumber,Text, 
    FalseFalse)
       
    End Sub
    So, nothing of new, this is what Gavin said starting this thread.

    I'm reading and reading here: http://android-developers.blogspot.co.uk/2013/10/getting-your-sms-apps-ready-for-kitkat.html
    but I fall in an headache ... that document is everything but not clear on what do they want from me ...

    I've added this to the manifest:

    Code:
    AddApplicationText(
    <
    activity android:name=".ComposeSmsActivity" >
                <
    intent-filter>
                    <action android:name=
    "android.intent.action.SEND" />               
                    <action android:name=
    "android.intent.action.SENDTO" />
                    <category android:name=
    "android.intent.category.DEFAULT" />
                    <category android:name=
    "android.intent.category.BROWSABLE" />
                    <data android:scheme=
    "sms" />
                    <data android:scheme=
    "smsto" />
                    <data android:scheme=
    "mms" />
                    <data android:scheme=
    "mmsto" />
                </
    intent-filter>
            </
    activity>
    )
    and now my app is able to send SMS, but still not able to delete SMS from messaging app.

    I've added also this to the manifest:

    Code:
    AddApplicationText(
    <receiver android:name=
    ".SmsReceiver"
                    android:permission=
    "android.permission.BROADCAST_SMS">
                <
    intent-filter>
                    <action android:name=
    "android.provider.Telephony.SMS_DELIVER" />
                </
    intent-filter>
            </receiver>
    But still my app does not absorb the SMS that is received also from the messaging app. Looking in the system settings, I don't see my app listed as possible default SMS app (I see only Hangouts). I think the above sintax "AddApplicationText(" in the manifest is not correct.

    Any help ?
     
  13. Erel

    Erel Administrator Staff Member Licensed User

    1. Remove the code you added.
    2. Add this code (assuming that the service name is Service1):
    Code:
    SetReceiverAttribute(Service1, android:permission, "android.permission.BROADCAST_SMS")
    AddReceiverText(Service1, <
    intent-filter>
      <action android:name=
    "android.provider.Telephony.SMS_DELIVER" />
      </
    intent-filter>
    )
    3. Follow the code (not manifest editor code) here: http://www.basic4ppc.com/android/fo...sms-messages-in-the-background.20103/#content
    Make sure to check for the correct Intent.Action.
     
  14. marcick

    marcick Well-Known Member Licensed User

    Thanks Erel, so I have to change my code to intercept messages in a different way.
    But, if I understand well, the static receiver cannot "trap" the intercepted message and not display to the user in the SMS manager (like SMS Interceptor can do returning "true"), right ?
    Will I be able to do this with a dinamic receiver ?
     
  15. FabioG

    FabioG Active Member Licensed User

    I need the same information
     
  16. Erel

    Erel Administrator Staff Member Licensed User

    Only a single app will receive the android.provider.Telephony.SMS_DELIVER intent. So there is nothing to abort in this case.

    Starting from Android 4.4 it is no longer possible to abort the SMS_RECEIVED_ACTION intent.

    As far as I understand it is is no longer possible to prevent other apps from receiving the SMS_RECEIVED_ACTION intent.
     
  17. marcick

    marcick Well-Known Member Licensed User

    So, there is no longer way to decide if the stock messaging app can see the SMS or not ? :mad:
     
  18. marcick

    marcick Well-Known Member Licensed User

    what a headache ...
    If I follow all the sample : http://www.basic4ppc.com/android/fo...sms-messages-in-the-background.20103/#content on a 4.3 device, I can receive SMS.
    On a 4.4 this does not work. I have modified the manifest differently, as you say above, and checking the DELIVER.intent instead of RECEIVED.intent, but does not work. Am I missing some code to let this app to be the default SMS application ?
    Sample project attached.
     

    Attached Files:

  19. Erel

    Erel Administrator Staff Member Licensed User

    Turns out you need to manage all the options or it will not be listed. You need to have three services and add this code:
    Code:
    SetReceiverAttribute(service1, android:permission, "android.permission.BROADCAST_SMS")
    AddReceiverText(service1, <
    intent-filter>
      <action android:name=
    "android.provider.Telephony.SMS_DELIVER" />
      </
    intent-filter>
    )
    SetReceiverAttribute(service2, android:permission, 
    "android.permission.BROADCAST_WAP_PUSH")
    AddReceiverText(service2,  <
    intent-filter>
      <action android:name=
    "android.provider.Telephony.WAP_PUSH_DELIVER" />
      <data android:mimeType=
    "application/vnd.wap.mms-message" />
      </
    intent-filter>
    )
    SetServiceAttribute(service3, android:permission, 
    "android.permission.SEND_RESPOND_VIA_MESSAGE")
    SetServiceAttribute(service3, android:exported, 
    "true")
    AddServiceText(service3,  <
    intent-filter>
      <action android:name=
    "android.intent.action.RESPOND_VIA_MESSAGE" />
      <category android:name=
    "android.intent.category.DEFAULT" />
      <data android:scheme=
    "sms" />
      <data android:scheme=
    "smsto" />
      <data android:scheme=
    "mms" />
      <data android:scheme=
    "mmsto" />
      </
    intent-filter>
    )
    AddActivityText(main,
     <
    intent-filter>
      <action android:name=
    "android.intent.action.SEND" />   
      <action android:name=
    "android.intent.action.SENDTO" />
      <category android:name=
    "android.intent.category.DEFAULT" />
      <category android:name=
    "android.intent.category.BROWSABLE" />
      <data android:scheme=
    "sms" />
      <data android:scheme=
    "smsto" />
      <data android:scheme=
    "mms" />
      <data android:scheme=
    "mmsto" />
      </
    intent-filter>
    )
     
    koaunglay likes this.
  20. marcick

    marcick Well-Known Member Licensed User

    Yes Erel, now it works.
    Need also "AddPermission(android.permission.RECEIVE_SMS)" in the manifest and in the device-settings change the default SMS app.
    Now I realize how is terrible this new Android update and I'm brainstorming if there is a solution for my app, different than take a gun...

    Two more questions:

    1) if I set my app as "default SMS app" and silently capture all incoming SMS, is there a way to put them (only some of them) in the inbox of the stock messaging application so they can be read by the user ?

    2) can you help me for the b4a code needed to switch my app from default/non default SMS app ?

    Marco
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice