Android Example Base app for new user to rapid build app

Discussion in 'Tutorials & Examples' started by tuhatinhvn, Aug 20, 2018.

  1. tuhatinhvn

    tuhatinhvn Active Member Licensed User

    Update 29/8/2018: i uploaded new version without FIREBASE to help who dont need

    B4A is very good app to build Android app.
    I want to use it built app same as Android Studio, so i make a "BASE" app to make more apps from it
    Since 8/2018, you must set target SDK is 26, so many changes to your old app to make it!

    This base app has "Drawer","Search","Multi Layout", "AdMOD ads", Runtime Permission
    Dialog,....
    very EASY to USE and READ

    After run , your app is ready to make more

    [​IMG]

    Have some menu on Drawer

    [​IMG]

    Has two layout demo, you can add more, and add banner admob too, you can change your admob id to use!
    [​IMG]

    Search dialog demo

    [​IMG]
    Runtime Permission support tooo

    You need add these library to use(almost them is core of B4A >8)
    [​IMG]

    When you build new app, you only need change appname, add some menu, load your layout, ENJOY!

    If you has any update, please post here, i will update in #1 post to other member can see and reuse for fast developing

    New app with base template app:
    Download profile picture for instagram

    Please download and try it and rate if you like ^^
    If anyone need know more about this app how to work, can ask to me to answer

    https://play.google.com/store/apps/details?id=com.download.profilepicture.forinstagram
     

    Attached Files:

    Last edited: Aug 29, 2018
  2. peacemaker

    peacemaker Well-Known Member Licensed User

    Thanks for the good template !
    I'd like to suggest also some of my code:
    Code:
    #Region  Service Attributes
        
    #StartAtBoot: False
        
    #ExcludeFromLibrary: True
    #End Region

    Sub Process_Globals
        
    'These global variables will be declared once when the application starts.
        'These variables can be accessed from all modules.

        
    Dim InternetConnected As Boolean, ph As PhoneEvents
        
    Public logs As StringBuilder
        
    Private logcat As LogCat
    End Sub

    Sub Service_Create
        
    'This is the program entry point.
        'This is a good place to load resources that are not specific to a single activity.
        logs.Initialize
        
    #if RELEASE
        logcat.LogCatStart(Array As String("-v","raw","*:F","B4A:v"), "logcat")
        
    #end if
        ph.Initialize(
    "ph")

    End Sub

    Sub Service_Start (StartingIntent As Intent)

    End Sub

    Sub Service_TaskRemoved
        
    'This event will be raised when the user removes the app from the recent apps list.
    End Sub

    'Return true to allow the OS default exceptions handler to handle the uncaught exception.
    Sub Application_Error (Error As Exception, StackTrace As StringAs Boolean
        
    'wait for 500ms to allow the logs to be updated.
        Dim jo As JavaObject
        
    Dim l As Long = 500
        jo.InitializeStatic(
    "java.lang.Thread").RunMethod("sleep"Array(l))
        
    logcat.LogCatStop
        logs.Append(StackTrace)

        
    Dim email1 As Email
        email1.To.Add(
    "developer@ofThisApp.com")
        email1.Subject = 
    Application.LabelName & ": app crash v." & Application.VersionName
        
        
    Dim hw1 As Phone
        email1.Body = 
    "Mf=" & hw1.Manufacturer & "; Model=" & hw1.Model & "; Product=" & hw1.Product & "; SdkVersion=" & hw1.SdkVersion & CRLF & CRLF & logs
        
    Dim intent As Intent = email1.GetIntent
        
    intent.WrapAsIntentChooser("Email:")
        
    StartActivity(email1.GetIntent)
        
    ToastMessageShow(Application.LabelName & ": send this bug-report to the developers now"True)
        
    Return True
    End Sub

    Sub Service_Destroy

    End Sub

    Private Sub logcat_LogCatData (Buffer() As Byte, Length As Int)
        logs.Append(
    BytesToString(Buffer, 0, Length, "utf8"))
        
    If logs.Length > 20000 Then
            logs.Remove(
    0, logs.Length - 19000)
        
    End If
    End Sub

    Sub ph_ConnectivityChanged (NetworkType As String, State As StringIntent As Intent)
        
    If State = "CONNECTED" Then
            
    Log("ph_ConnectivityChanged: CONNECTED" & "," & NetworkType)
            InternetConnected = 
    True
        
    Else    'NO INTERNET
            Log("ph_ConnectivityChanged: DISCONNECTED")
            InternetConnected = 
    False
        
    End If
    End Sub

    Dependecies: Phone and JavaObject libs.
    Features:
    * system crash bug report via email
    * Internet-connection state
     
  3. Josias

    Josias Member Licensed User

    Thx for sharing this example. When I compile I get a build error stating that it 'Could not find file - Issue-Example\AppCompat\google-services.json'.

    Any idea why this is the case?
     
  4. konradwalsh

    konradwalsh Active Member Licensed User

    Thats because you dont have
    Code:
    Example\AppCompat\google-services.json'
    You need to set up your google services and download YOUR json file.. It might be better to search the forums. You will find plenty of help on that exact question
     
  5. Colin Evans

    Colin Evans Active Member Licensed User

    Good idea but I wouldn't want to use Google services or Firebase every time I wanted to create an app
     
  6. konradwalsh

    konradwalsh Active Member Licensed User

    I think that's the point..
    He has put together many of the things someone wants.
    Its a lot easier to turn something off and still use the base
     
  7. MarkusR

    MarkusR Well-Known Member Licensed User

    i think every app have different requirements, but a template app with everything to look how it is done is good to have.
    as example text input via voice, sqlite usage, using of web apis, collecting photos, read barcodes, send mails, custom controls, ...
     
  8. Colin Evans

    Colin Evans Active Member Licensed User

    I do think this would be a brilliant app for novice's like myself if it didn't rely on Google Service / Firebase but as a novice I wouldn't know which bits to 'turn off' to be able to use the app in its current form
     
  9. tuhatinhvn

    tuhatinhvn Active Member Licensed User

    Last edited: Aug 29, 2018
  10. konradwalsh

    konradwalsh Active Member Licensed User

    Whilst interesting.. I think adding this is diluting the benefits of what you have created here. Extremely few people will want an instagram downloader in their app. I would suggest moving that to a separate thread
     
  11. tuhatinhvn

    tuhatinhvn Active Member Licensed User

    Sorry about it, i want to show that from this base template app, anyone can make more good apps, i dont include sourcode of instagram downloader app because it not main function of this thread
     
  12. konradwalsh

    konradwalsh Active Member Licensed User

    I think you are doing something quite amazing so far..

    I think it would be amazing if @Erel included it in B4X as a well-commented example base application that people can learn from. I imagine it would reduce the amount start questions
     
    tuhatinhvn likes this.
  13. Colin Evans

    Colin Evans Active Member Licensed User

    Excellent for novice programmers like myself, its a good starting point and shows extremely well what can be done, and I agree Erel would make it easier for all the new comers to B4A if something similar to this was included, it would lessen the amount of start up questions

    'tuhatinhvn' well done and thank you
     
    tuhatinhvn likes this.
  14. Bothwell

    Bothwell Member Licensed User

    Hi

    in B4A version 9.01.2 I cant find the TabStripViewPager on the libraries on the sceenshot below


     
  15. tuhatinhvn

    tuhatinhvn Active Member Licensed User

  16. Bothwell

    Bothwell Member Licensed User

    Thanks this works, but when I add CustomListView this line of code fails with too many parameters



    clvmenu.Add(CreateListItem("home.png","Home",False, clvmenu.AsView.Width, 50dip), 50dip, "Home")


    is the example application still valid in 2019 ? or can it be updated to use the latest libraries as a new B4A user it will help a lot
     
  17. asales

    asales Well-Known Member Licensed User

    1 - Add XUI Views to the project.
    2 - change the clvmenu component in the Left layout to the new customlistview
    3 - Change the lines of clvmenu to:
    Code:
    clvmenu.Add(CreateListItem("home.png","Home",False, clvmenu.AsView.Width, 50dip), "Home")
     
  18. asales

    asales Well-Known Member Licensed User

    Here the example without Firebase updated.
     

    Attached Files:

  19. Bothwell

    Bothwell Member Licensed User

    I am trying the updated version but it fails with "unknown type " as it is missing inputDialog library

    Code:
    Dim searchdia As InputDialog
    are you able to share your additional libraries folder so I can at least compile this ? or share the link where the inputDialog library is

    where do i get B4A libraries, its seems they are not located in one place but various threads throughout the forum ? I find this a little bit frustrating. how do we know you are reading the correct thread with the latest library ? are they not located in a central repository of some sort ?
     
  20. asales

    asales Well-Known Member Licensed User

    Here the list of libraries uses in the example:
    libs_baseapp3.jpg
    Correct. You need to the the forum search.
    See the information in the post of the library, like this:
    V4.01 is released with several improvements
    https://www.b4x.com/android/forum/threads/dialogs-library.6776/
    Correct. You need to the the forum search.
     
    Bothwell likes this.
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