It is currently Tue Apr 25, 2017 7:27 am



Welcome
Welcome to rfobasic

You are currently viewing our boards as a guest, which gives you limited access to view most discussions and access our other features. By joining our free community, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content, and access many other special features. In addition, registered members also see less advertisements. Registration is fast, simple, and absolutely free, so please, join our community today. **You are not required to provide truthful information to any registration questions. Be whomever you wish to be.!


Post new topic Reply to topic  [ 12 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: file sharing using
Unread postPosted: Sun Mar 29, 2015 2:45 am 
Offline

Joined: Thu Aug 15, 2013 9:26 am
Posts: 102
Location: South Africa
I have made a work around for sharing any type of file using the built in android share with selection.

It needs a bit of work and the use of a separate app that I have created, myshare2_1.apk and will have to be installed

To use you will have to code into your app a routine that creates two files on the sdcard root directory ie. ("../../mysharepoint" a pointer containing the filename to share)
And ("../../mysharemsg" a file containing a message)

The pointer contained in the mysharepoint file should be formatted like this.

/sdcard/<your_app_folder>/<filename>

----
Here is an example of the code I have used

file.dir "../../rfo-basic/data/", dir_list$[]
dialog.select dl,dir_list$[],s$
CLS
print "/sdcard/rfo-basic/data/" +dir_list$[dl]
console.save "../../mysharepoint"
cls
print "Hello"
console.save "../../mysharemsg"
cls


act$ = "android.intent.action.MAIN"
pkg$ = "appinventor.ai_morneydeetlefs69.myshare2_1"
cmp$ = ".Screen1"
debug.on
AM.START act$, , pkg$, pkg$+cmp$
end


Attachments:
myshare2_1.apk [1.3 MiB]
Downloaded 40 times
Top
 Profile  
 
 Post subject: Re: file sharing using
Unread postPosted: Mon Mar 30, 2015 12:16 am 
Offline

Joined: Thu Aug 15, 2013 9:26 am
Posts: 102
Location: South Africa
Is there a way to package this app in basic code?


Top
 Profile  
 
 Post subject: Re: file sharing using
Unread postPosted: Wed Apr 08, 2015 7:16 am 
Offline

Joined: Wed Oct 03, 2012 9:53 am
Posts: 2795
Location: Colorado, U.S.
I'm sorry, I don't understand the question. Do you mean add commands to do what your app does? Add commands that interface with your app? Can you give me an example of what commands you want added?

I plan to add capability to interact with other apps (some day!), but I don't want to make BASIC! depend on any specific third-party app.

- Marc


Top
 Profile  
 
 Post subject: Re: file sharing using
Unread postPosted: Thu Apr 09, 2015 11:06 am 
Offline
User avatar

Joined: Thu Nov 21, 2013 7:00 pm
Posts: 630
If we're talking about the 'sdcard', Basic! already uses 'shared' storage.
Code:
Primary External Shared Storage
      e.g /mnt/sdcard/

          no sandboxing restrictions.
          not cleared upon app-uninstall.
          Environment.getExternalStorageDirectory() e.g /mnt/sdcard

          android.permission.WRITE_EXTERNAL_STORAGE grants sdcard_rw
          membership on same volume. Otherwise the volume is read-only.


i.e Any other app with WRITE_EXTERNAL_STORAGE can get access to the sdcard.

_________________
- Failure is not an option. It is bundled with the software. -


Top
 Profile  
 
 Post subject: Re: file sharing using
Unread postPosted: Sun Dec 04, 2016 5:51 am 
Offline

Joined: Thu Aug 15, 2013 9:26 am
Posts: 102
Location: South Africa
Hi everyone.Is there any way of opening an image file using something like the browse command opens a pdf file?


Top
 Profile  
 
 Post subject: Re: file sharing using
Unread postPosted: Sun Dec 04, 2016 7:54 am 
Offline
User avatar

Joined: Tue Jan 03, 2012 9:31 am
Posts: 5485
Location: Paris, France
Try the following:
Code:
file.root r$: f$=r$+"/cartman.png"
app.start "android.intent.action.VIEW", f$ ,,, "image/png",,, HEX("10000000") %FLAG_ACTIVITY_NEW_TASK

_________________
- Creator of the Android BASIC! Compiler


Top
 Profile  
 
 Post subject: Re: file sharing using
Unread postPosted: Sun Dec 04, 2016 8:26 am 
Offline

Joined: Thu Aug 15, 2013 9:26 am
Posts: 102
Location: South Africa
Thank you M. Exactly what I was looking for but image not loading.
the svar f$ is returning

"/storage/emulated/0/rfo-basic/data/cartman.png"


Top
 Profile  
 
 Post subject: Re: file sharing using
Unread postPosted: Sun Dec 04, 2016 9:10 am 
Offline
User avatar

Joined: Wed Jul 10, 2013 8:11 am
Posts: 299
mougino wrote:
Try the following:
Code:
file.root r$: f$=r$+"/cartman.png"
app.start "android.intent.action.VIEW", f$ ,,, "image/png",,, HEX("10000000") %FLAG_ACTIVITY_NEW_TASK


You can use "image/*" instead of "image/png". So you have to change the filename only.

But on my tablet just the Ghost Commander Imageviewer show me the image.

If you try my test version http://rfobasic.freeforums.org/post34392.html#p34392 with

Code:
FN.DEF ViewImage(fileName$)

LIST.CREATE S, commandListPointer
LIST.ADD commandListPointer~
"new Intent(Intent.ACTION_VIEW);" ~
"setDataAndType("+CHR$(34)+fileName$+CHR$(34)+","+CHR$(34)+ "image/*"+CHR$(34)+");" ~
"addCategory(Intent.CATEGORY_DEFAULT);" ~
"addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);" ~
"addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);" ~
"EOCL"
BUNDLE.PL appVarPointer,"_CommandList", commandListPointer

APP.SAR appVarPointer

FN.RTN appVarPointer

FN.END

debug.off
  file.root dataPath$
  fileName$ =  "file://"+ dataPath$ + "/" + "cartman.png"
  PRINT "FileName: " , fileName$
  myVarPointer = ViewImage (fileName$)

END

, all other suitable apps should show you your image.

Happy coding
Gregor


Top
 Profile  
 
 Post subject: Re: file sharing using
Unread postPosted: Sun Dec 04, 2016 9:53 am 
Offline

Joined: Thu Aug 15, 2013 9:26 am
Posts: 102
Location: South Africa
Thanks it works perfectly


Top
 Profile  
 
 Post subject: Re: file sharing using
Unread postPosted: Sun Dec 04, 2016 10:56 am 
Offline

Joined: Thu Aug 15, 2013 9:26 am
Posts: 102
Location: South Africa
Was having some difficulty with the above mentioned code, I was playing with the code and ended up with this

file.root r$
f$=r$+"/cartman.png"
app.start "android.intent.action.VIEW", f$ ,,,"image/png"

The problem is that the native apps 'photos' and 'Gallery' would not open the image but a downloaded app 'Es file explorer' would. What is the difference?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ]  Go to page 1, 2  Next


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
suspicion-preferred