Android Question CreateResource Problem

fabio borges

Member
Licensed User
Longtime User
When i create a resource in the manifest using CreateResource my app crash with this error:

Trying to use:
CreateResource(xml, provider_paths,
<external-path name="name" path="" />
)

ERROR:
** Service (httputils2service) Start **
** Activity (main) Pause, UserClosed = false **
** Activity (utilsatualizaversao) Create, isFirst = true **
utilsatualizaversao_carregaactionbar (java line: 618)
android.content.res.Resources$NotFoundException: Resource ID #0x7f08001c
at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:216)
at android.content.res.Resources.getDimension(Resources.java:657)
at de.amberhome.SimpleActionBar.ActionBar.<init>(ActionBar.java:312)
at de.amberhome.SimpleActionBar.ActionBarWrapper.innerInitialize(ActionBarWrapper.java:86)
at anywheresoftware.b4a.objects.ViewWrapper.Initialize(ViewWrapper.java:67)
at de.amberhome.SimpleActionBar.ActionBarWrapper.Initialize2(ActionBarWrapper.java:79)
at de.amberhome.SimpleActionBar.ActionBarWrapper.Initialize(ActionBarWrapper.java:63)
at dmuller.comercial.utilsatualizaversao._carregaactionbar(utilsatualizaversao.java:618)
at

In my project I use AHActionBar Lib, apparently this is the problem but I cant solve.

Any suggest?

Fabio
 

DonManfred

Expert
Licensed User
Longtime User
dmuller.comercial.utilsatualizaversao._carregaactionbar(utilsatualizaversao.java:618)
what is at this code line in the generated java source?
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Trying to use:
CreateResource(xml, provider_paths,
<external-path name="name" path="" />
)
i don´t think the error is related to this CreateResource. The CreateResource you are using because you are implementing Fileprovider but the error has another reason.

Best is to upload a small project which shows the issue.
 
Upvote 0

fabio borges

Member
Licensed User
Longtime User
Its the procedure that load AHActionBar.

B4X:
#Region Module Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    Dim vSQLCnx             As SQL   
End Sub

Sub Globals
    Private acb                 As AHActionBar
    Private HomeIcon             As BitmapDrawable
    Private vReceber             As Boolean = False
    Private vBtConecta             As Button
    Private vCursorCnx             As Cursor
    Private vLabelVersaoAtual    As Label
    Private vLabelNovaVersao    As Label
    Private Label_Titulo         As Label
    Private vProgresso             As ProgressBar
    Private vEndAcesso            As String
    Private phone                 As Phone
    Private vNomePacote            As String = "dmuller.apk"
   
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Dim vTamABC                As Int

      Activity.Color=Colors.White
   
    Label_Titulo.Initialize("")
    vProgresso.Initialize("")
   
    vSQLCnx.Initialize(Starter.vPathDB, "Database.db3", False)   

    vCursorCnx=vSQLCnx.ExecQuery("SELECT * FROM CONFIGURACOES")
    vCursorCnx.Position=0
    If vCursorCnx.GetString("ID_AMBIENTE")="N" Then
        vEndAcesso    = vCursorCnx.GetString("END_VERSAO").Trim
    Else
        vEndAcesso    = vCursorCnx.GetString("END_VERSAO_HOMOLOGACAO").Trim
    End If
    vCursorCnx.Close
   
    CarregaActionBar
   
    vTamABC = acb.Top+acb.Height
   
    vLabelVersaoAtual.Initialize("")
    vLabelVersaoAtual.Text = "Versão Atual: "&Starter.vAppVersao
    Activity.AddView(vLabelVersaoAtual, 5dip, vTamABC+5dip, 100%x, 20dip)
   
    vLabelNovaVersao.Initialize("")
    vLabelNovaVersao.Text = "Versão Disponível: N/A"
    Activity.AddView(vLabelNovaVersao, 5dip, vTamABC+20dip, 100%x, 20dip)
   
    vBtConecta.Initialize("Conecta")
    vBtConecta.Text="Atualizar"
    vBtConecta.TextSize=16 * Starter.vFontSize
    vBtConecta.Typeface=Typeface.DEFAULT_BOLD
    Activity.AddView(vBtConecta,1dip,140dip,100%x-2dip,60dip)   
   
    Label_Titulo.Gravity=Gravity.CENTER_HORIZONTAL
    Label_Titulo.TextSize=18 * Starter.vFontSize

    Activity.AddView(Label_Titulo,0, 50%y, 100%x,30dip)

    Dim j As HttpJob

    j.Initialize("", Me)
    j.GetRequest.Timeout=150000
    j.PostString(vEndAcesso & "Android.VerificarVersao","")
    Wait For (j) JobDone(j As HttpJob)
   
    If j.Success Then
        Dim vResposta As String = j.GetString
        vLabelNovaVersao.Text = "Versão Disponível: "&vResposta.Replace(".apk","")
       
        If vResposta.Replace(".apk","") > Starter.vAppVersao Then
            vReceber = True
        Else
            vReceber = False
        End If
    Else
        Log("Verificando versão: " & j.GetString)
    End If
    j.Release
End Sub


Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub ACB_ItemClicked(ItemID As Int)
    Select ItemID
        Case Starter.ID_ACTION_HOME
            vSQLCnx.Close
            Activity.Finish
    End Select
End Sub

Sub CarregaActionBar
    HomeIcon.Initialize(        LoadBitmap(File.DirAssets, "Home_48.png"))
   
    acb.Initialize("ACB")
    acb.Title=""
    Activity.Title="Atualiza Versão"
    acb.ActionWidth = 58dip
    acb.addHomeAction(Starter.ID_ACTION_HOME, HomeIcon)
    acb.Background=Utils.abColor(Null)
    Activity.AddView(acb, 0, 0, 100%x, 60dip)
End Sub

Sub Conecta_Click
    If vReceber Then
        Label_Titulo.Text="[ Conectando Servidor ]"
       
        ProgressDialogShow2("Fazendo download da aplicação...",False)
       
        acb.RemoveView
        vBtConecta.RemoveView
       
        Dim j As HttpJob

        j.Initialize("", Me)
        j.GetRequest.Timeout=150000
        j.Download(vEndAcesso&"Android.BuscarVersao")
       
        Wait For (j) JobDone(j As HttpJob)
   
        If j.Success Then
            If File.Exists(File.DirInternalCache ,vNomePacote)=True Then
                File.Delete(File.DirInternalCache,vNomePacote)
            End If

            Try
                Dim MyStream As OutputStream
                MyStream = File.OpenOutput(File.DirInternalCache, vNomePacote, False)
                File.Copy2(j.GetInputStream,MyStream) ' save the file
                MyStream.Close
           
                If File.Exists(File.DirInternalCache,vNomePacote) Then
                    SendInstallIntent
                    ExitApplication
                    Activity.Finish
                End If
            Catch
                Log(LastException.Message)
                Msgbox("Erro no recebimento da versão, verifique se existe espaço no cartão de memória...","Atenção")
                j.Release
                Activity.Finish
            End Try
        End If
        j.Release
    End If
End Sub


Private Sub SendInstallIntent
    Dim i As Intent
    If phone.SdkVersion >= 24 Then
        i.Initialize("android.intent.action.INSTALL_PACKAGE", CreateFileProviderUri(File.DirInternalCache, vNomePacote))
        i.Flags = Bit.Or(i.Flags, 1) 'FLAG_GRANT_READ_URI_PERMISSION
    Else
        i.Initialize(i.ACTION_VIEW, "file://" & File.Combine(File.DirInternalCache, vNomePacote))
        i.SetType("application/vnd.android.package-archive")
    End If
    StartActivity(i)
End Sub

Sub CreateFileProviderUri (Dir As String, FileName As String) As Object
    Dim FileProvider As JavaObject
    Dim context As JavaObject
    context.InitializeContext
    FileProvider.InitializeStatic("android.support.v4.content.FileProvider")
    Dim f As JavaObject
    f.InitializeNewInstance("java.io.File", Array(Dir, FileName))
    Return FileProvider.RunMethod("getUriForFile", Array(context, Application.PackageName & ".provider", f))   'ERROR HERE
End Sub
 
Upvote 0
Top