Android Question How to access default SMS manager

Discussion in 'Android Questions' started by ThRuST, May 1, 2015.

  1. ThRuST

    ThRuST Well-Known Member Licensed User

    (B4A) Hello I wonder how to start the default SMS manager intent in android? I have tried the packagemanager without luck, but I can read email that way but not SMS.

    I can access the phones settings this way, perhaps it makes it easier.

    Dim intent1 As Intent
    intent1.Initialize("android.settings.WIFI_SETTINGS", "")
    StartActivity(intent1)

    Anyone?
     
  2. NJDude

    NJDude Expert Licensed User

    Something like this:
    Code:
    Private i As Intent

    i.Initialize(i.ACTION_VIEW, 
    "sms:")
    i.PutExtra(
    "sms_body""Hello There!")

    StartActivity(i)
     
  3. ThRuST

    ThRuST Well-Known Member Licensed User

    Thanks NJDude. I allready know how how to send SMS, I need to read them from intent and not any list (SMS main menu) from the SMS manager as specified in my post. Can you solve it? :)
     
  4. NJDude

    NJDude Expert Licensed User

    If you mean to intercept SMS messages then try THIS
     
  5. ThRuST

    ThRuST Well-Known Member Licensed User

    I was hoping there was an intent available to access the 'SMS inbox message handler'. A running service was not really the prime answer to this question. Thanks anyway.
    This is the closest I could get:

    Dim intent1 As Intent
    intent1.Initialize("android.provider.Telephony.SMS_RECEIVED")
    StartActivity(intent1)

    Perhaps you or someone else can help me solve it by looking at this page:
    http://developer.android.com/reference/android/telephony/SmsManager.html
     
  6. ThRuST

    ThRuST Well-Known Member Licensed User

  7. ThRuST

    ThRuST Well-Known Member Licensed User

    I solved this myself. Here's how to start the SMS inbox handler:

    ' Start SMS handler intent
    Dim PM As PackageManager
    Dim StartIntent As Intent
    Dim iStr As String
    Dim Packages As List

    Packages = PM.GetInstalledPackages
    For i = 0 To Packages.size - 1
    iStr=Packages.Get(i)

    If iStr.Contains("mms") = True Then
    StartIntent=PM.GetApplicationIntent(iStr)
    If StartIntent.IsInitialized Then StartActivity(StartIntent)
    Exit
    End If
    Next
     
  8. NJDude

    NJDude Expert Licensed User

    You could also do this:
    Code:
    Private i As Intent

    i.Initialize(i.ACTION_MAIN, 
    "")
    i.SetType(
    "vnd.android-dir/mms-sms")

    StartActivity(i)
     
  9. ThRuST

    ThRuST Well-Known Member Licensed User

    Thank you NJDude, brilliant solution :D
     
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