Dim pdf As pdfView
pdfname = "vb2010.pdf"
If File.Exists(rp.GetSafeDirDefaultExternal(""),pdfname) = False Then
File.Copy(File.DirAssets,pdfname,rp.GetSafeDirDefaultExternal(""),pdfname)
pdf.Initialize("PDFView",File.Combine(File.DirRootExternal,pdfname),1,True,True)
End If
Honestly - you've been a member of this forum since 2014. You should have some idea on how to troubleshoot issues with your code. Add this line of code above your pdf.Initialize statement:
Run the code, then look in the Log tab (on the right hand side of the B4A IDE) & copy the line that starts with "File Combine:" & paste it into this thread.
1) File.Copy probably isn't a blocking method, therefore if you call pdf.Initialize immediately after File.Copy, the file might not yet be available. You should wait until you know that the file has been copied, but I'm not sure if Sleep(0) will work, so you could use an arbitrary sleep time - say 1 second. You could use a Do While Loop to pause execution until the file is copied, but my concern there is that if the file doesn't get copied you'll send up stuck in the loop (unless you also put a timeout in it).
2) You shouldn't repeatedly call rp.GetSafeDirDefaultExternal. If you are only using it in that one sub, then you should assign the first call to a local variable, then use that. If you're using it in other places, then create a global variable in your Starter service & assign it to that:
B4X:
Private pdf As pdfView
Private safeDir as String = rp.GetSafeDirDefaultExternal("")
pdfname = "vb2010.pdf"
If Not(File.Exists(safeDir, pdfname)) Then
File.Copy(File.DirAssets, pdfname, safeDir, pdfname)
Sleep(1000)
If File.Exists(safeDir, pdfname) Then
pdf.Initialize("PDFView",File.Combine(safeDir, pdfname),1,True,True)
Else
Log("File Not Copied!")
End If
End If
Honestly - you've been a member of this forum since 2014. You should have some idea on how to troubleshoot issues with your code. Add this line of code above your pdf.Initialize statement:
Run the code, then look in the Log tab (on the right hand side of the B4A IDE) & copy the line that starts with "File Combine:" & paste it into this thread.
This code to apear the pdf page . so mybe not need Permissions . alraedy pdf file in dir of phone
but need to access pdf file in the phone dir . mybe need to change DirDefaultExternal to other word
This thread should not take these many posts ( 28 posts) to solve. Your best bet is to export the project. I am sure someone in the forum will be able to figure it out. The community is always eager to help its members. Here is what you do:
1. In the IDE open your project, then click 'File'
2. Choose 'Export as zip'. Save the file under any given name and attach it to your post.
3. To make it easier for you and everyone else, perhaps you should use Google Translate to translate your post from Arabic to English, if that is possible.
This thread should not take these many posts ( 28 posts) to solve. Your best bet is to export the project. I am sure someone in the forum will be able to figure it out. The community is always eager to help its members. Here is what you do:
1. In the IDE open your project, then click 'File'
2. Choose 'Export as zip'. Save the file under any given name and attach it to your post.
3. To make it easier for you and everyone else, perhaps you should use Google Translate to translate your post from Arabic to English, if that is possible.