B4A Library AndroidProviders (Calendars, Contacts, Calls Log, Telephony, SMS, MMS and more

Discussion in 'Additional libraries, classes and official updates' started by DonManfred, Aug 20, 2015.

  1. DonManfred

    DonManfred Expert Licensed User

    This is a wrapper for this Github project.

    [​IMG]

    AndroidProviders
    Author: Manfred Ssykor <DonManfred>
    Version: 1.1
    • BrowserProvider
      Methods:
      • Initialize
      • IsInitialized As Boolean
      Permissions:
      • com.android.browser.permission.READ_HISTORY_BOOKMARKS
      Properties:
      • Bookmarks As Cursor [read only]
      • Searches As Cursor [read only]
    • CalendarProvider
      Methods:
      • Initialize
      • IsInitialized As Boolean
      • getCalendarByID (calendarId As Long) As Calendar
      • getEvents (calendarId As Long) As Cursor
      • updateCalendar As Int
      Permissions:
      • android.permission.READ_CALENDAR
      • android.permission.WRITE_CALENDAR
      Properties:
      • Calendars As Cursor [read only]
    • CallsProvider
      Methods:
      • Initialize
      • IsInitialized As Boolean
      Permissions:
      • android.permission.READ_CALL_LOG
      Properties:
      • Calls As Cursor [read only]
    • ContactsProvider
      Methods:
      • Initialize
      • IsInitialized As Boolean
      Permissions:
      • android.permission.READ_CONTACTS
      Properties:
      • Contacts As Cursor [read only]
    • DictionaryProvider
      Methods:
      • Initialize
      • IsInitialized As Boolean
      Permissions:
      • android.permission.READ_USER_DICTIONARY
      Properties:
      • Words As Cursor [read only]
    • MediaProvider
      Methods:
      • Initialize
      • IsInitialized As Boolean
      Permissions:
      • android.permission.READ_EXTERNAL_STORAGE
      Properties:
      • AlbumsExternal As Cursor [read only]
      • AlbumsInternal As Cursor [read only]
      • ArtistsExternal As Cursor [read only]
      • ArtistsInternal As Cursor [read only]
      • AudiosExternal As Cursor [read only]
      • AudiosInternal As Cursor [read only]
      • FilesExternal As Cursor [read only]
      • FilesInternal As Cursor [read only]
      • GenresExternal As Cursor [read only]
      • GenresInternal As Cursor [read only]
      • ImagesExternal As Cursor [read only]
      • ImagesInternal As Cursor [read only]
      • PlaylistsExternal As Cursor [read only]
      • PlaylistsInternal As Cursor [read only]
      • VideosExternal As Cursor [read only]
      • VideosInternal As Cursor [read only]
    • TelephonyProvider
      Methods:
      • Initialize
      • IsInitialized As Boolean
      • getMMS (filter As String) As Cursor
      • getSMS (filter As String) As Cursor
      Permissions:
      • android.permission.READ_SMS
      Properties:
      • Carriers As Cursor [read only]
      • Conversations As Cursor [read only]
      • Threads As Cursor [read only]


    Notes:
    - ALL Content-Providers doe only READ as yet. For the Calendars-Povider i´ll make an update where you can Update Events and Calendars. It is not done as yet. All other Providers except Calendars does not have any update-methods. So you just can READ all the data

    - ALL Providers will return a CURSOR to iterate through the results!

    As Example i´ll post code to get all Contacts. ALL other Providers can be used similar.

    Code:
    Sub Globals
        
    'These global variables will be redeclared each time the activity is created.
        'These variables can only be accessed from this module.
        Dim contp As ContactsProvider
    End Sub
    Sub Activity_Create(FirstTime As Boolean)
        
    'Do not forget to load the layout file created with the visual designer. For example:
        'Activity.LoadLayout("Layout1")
        contp.Initialize("")
        
    '
        Dim c As Cursor
        c = contp.Contacts
        
    If c.RowCount > 0 Then
            
    For i = 0 To c.RowCount-1
                c.Position = i
                LogColor(
    "==========================="Colors.Green)
                
    Dim colcount As Int = c.ColumnCount
                
    Log("columns="&colcount)
                
    For o = 0 To colcount -1
                    
    Log(c.GetColumnName(o)&"="&c.GetString(c.GetColumnName(o)))           
                
    Next           
            
    Next
        
    End If
        
    Log("Contacts = "&c.RowCount)
    If you want to donate for my work building the wrapper you can do it here: [​IMG]
     

    Attached Files:

    Last edited: Mar 14, 2016
    scsjc, JohnC, u2005k and 17 others like this.
  2. Peter Simpson

    Peter Simpson Expert Licensed User

    Ooh nice...
     
    jsanchezc likes this.
  3. jsanchezc

    jsanchezc Member Licensed User

    Great Job!
     
  4. DonManfred

    DonManfred Expert Licensed User

    ohh, i see it now. Forgot to describe some methods :oops:. Wil do this tomorrow ;)
     
  5. wineos

    wineos Member Licensed User

    Hi

    I have tried the getEvent function, and found that the no. of columns of the returned cursor was not stable. Different event records will have different columns exist.

    Any idea?

    Thanks!
     
  6. DonManfred

    DonManfred Expert Licensed User

    No. That´s how the Google Events work. Your description does not sound like an bug

    for ex: an non recurring event will not have an recurrence rule.
    an event may have 0 or more attendees
     
  7. wineos

    wineos Member Licensed User

    Hi,

    I want to access the calendar Instances records, read, update and delete. How can I use your library to do these functions?

    When will the Calendar Provider be ready for update?

    Thanks!
     
  8. DonManfred

    DonManfred Expert Licensed User

    I can´t say this as of today... I need some time for this. But the last weeks i did not had much time at all. For nothing. :-/
     
  9. wineos

    wineos Member Licensed User

    I will wait for you. :D
     
  10. wineos

    wineos Member Licensed User

    Sorry DonManfred,

    At last, I found that CalendarContract.Instances is only readable. It cannot edit. :p

    Thanks!
     
  11. DonManfred

    DonManfred Expert Licensed User

    ALL Providers are readonly at this point
     
  12. wineos

    wineos Member Licensed User

  13. DonManfred

    DonManfred Expert Licensed User

    It will work hopefully when i´m ready with this lib. Need time for this as i already said.

    Due to the docu of the lib

    Calendars, Events, Instances can be updated.
     
  14. wineos

    wineos Member Licensed User

    Wow, great, long for your good job! :)

    Thank you DonManfred.
     
  15. swamisantosh

    swamisantosh Member Licensed User

    CallsProvider
    Methods:

    • Initialize (EventName As String)
    • IsInitialized As Boolean
    • getMMS (filter As String) As Cursor
    • getSMS (filter As String) As Cursor
    i'm new in coding
    please provide code to read SMS and CallsProvider
     
  16. DonManfred

    DonManfred Expert Licensed User

    Then learn the language.

    There are an example for a provider in post #1
    The other providers are similar and are easily to create by yourself

    Code:
    Sub Globals
        
    'These global variables will be redeclared each time the activity is created.
        'These variables can only be accessed from this module.
        Dim cp As CallsProvider
    End Sub
    Code:
    cp.Initialize("Calls")
        
    Dim aint As Cursor
        aint = cp.getSMS(
    "ALL")
        
    Log("SMS = "&aint.RowCount)
        
    If aint.RowCount > 0 Then
            
    For i = 0 To aint.RowCount-1
                aint.Position = i
              
                
    Dim colcount As Int = aint.ColumnCount
                
    Log("columns="&colcount)
                
    For o = 0 To colcount -1
                    
    Log(aint.GetColumnName(o)&"="&aint.GetString(aint.GetColumnName(o)))              
                
    Next              
                LogColor(
    "---------------------------"Colors.Magenta)
            
    Next
        
    End If
     
    Last edited: Dec 25, 2015
  17. JohnC

    JohnC Well-Known Member Licensed User

    Please provide more examples/Syntax for the "Filer" parameter of the .getSMS(filter) and .MMS(filter) calls.

    I ask because no matter what I put for 'filter' using ("inbox") or ("send"), the routine will always return ALL SMS records.

    Thanks!
     
  18. DonManfred

    DonManfred Expert Licensed User

    I guess it comes from the wrong filter you are using....

    Code:
    public Cursor getSMS(String filter){
        Filter f= Filter.ALL;
            
    switch (filter) {
        
    case "ALL":
          f = Filter.ALL;
          break;
        
    case "INBOX":
          f = Filter.INBOX;
          break;
        
    case "OUTBOX":
            f = Filter.OUTBOX;
            break;
        
    case "SENT":
            f = Filter.SENT;
            break;
        
    case "DRAFT":
            f = Filter.DRAFT;
            break;
            
    }
            Data<Sms> calls = this.getObject().getSms(f);
            Cursor c = calls.getCursor();
          
            return c;
        }
    Default is ALL

    Filters are "ALL", "INBOX", "OUTBOX", "SENT" and "DRAFT" (in THIS CASE)
     
  19. JohnC

    JohnC Well-Known Member Licensed User

    Thanks for the quick response.

    Curious, the stock SMS/MMS messaging app on my Samsung S4 doesn't have any of folders in it - is this the norm or is just Samsung not implementing these folders?
     
  20. DonManfred

    DonManfred Expert Licensed User

    I dont know, sorry
     
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