Post by rcollins on Mar 20, 2017 21:06:27 GMT
Hey all,
I am have been having some trouble with getting the IMAGE_CAPTURE intent to actually save an image. I have read that this could be a bug within Rho due to the fact the intent is expecting a URI yet we are sending a string. I just wanted to know if there was any information you could give.
Below is a rendition of the code I am testing with:
Controller:
View (showpic.erb)
How I understand, if we specify the output URI for that intent action, it should save the full image there. If one is not specified, it will return a down-sized (thumbnail) image in bmp format. I have not had either work but am really interested in just saving the pic period.
I am not interested in using the Camera API due to other issues. Just really curious about the handling of the intent.
Any help would be appreciated!
Thanks!
Ryan
I am have been having some trouble with getting the IMAGE_CAPTURE intent to actually save an image. I have read that this could be a bug within Rho due to the fact the intent is expecting a URI yet we are sending a string. I just wanted to know if there was any information you could give.
Below is a rendition of the code I am testing with:
Controller:
def intenttest
file = File.join("/sdcard","1234")
intent_params = {
:intentType => Rho::Intent::START_ACTIVITY,
:action => "android.media.action.IMAGE_CAPTURE",
:data => { :output => "content://#{file}" }
}
Rho::Intent.send intent_params, url_for(:action => :intentcallback)
end
def intentcallback
@data = "nothing"
if(!@params['data'].nil?)
@data = @params['data'].to_s()
if (!@params['data']['output'].nil?)
@data = @params['data']['output'].to_s()
end
end
#test due to reset connect err
sleep(3)
WebView.navigate(url_for(:action=>:showpic, :query=> { :data => @data }))
end
def showpic
@data = @params['data']
@files = []
root_path = "/sdcard"
entries = Rho::RhoFile.listDir(root_path)
if !entries.nil?
entries.each do |entry|
unless (entry == "." || entry == "..")
#(Rho::RhoFile.isDir(Rho::RhoFile.join(root_path,entry)) ? folders : files) << entry
if (!Rho::RhoFile.isDir(Rho::RhoFile.join(root_path,entry)))
@files << entry
end
end
end
end
SettingsButtonLink(url_for(:action => :index))
render
rescue Exception => ex
ApplicationHelper.ShowErrorMessage(self,ex,"back")
end
View (showpic.erb)
<div data-role="page">
<h2>Intent Callback</h2>
<p>
data returned:
<br />
<%=@data%>
</p>
<p>
<% if !@files.length != 0 %>
<% @files.each do |file| %>
<div><%=file.to_s()%></div>
<%end%>
<%end%>
</p>
</div>
How I understand, if we specify the output URI for that intent action, it should save the full image there. If one is not specified, it will return a down-sized (thumbnail) image in bmp format. I have not had either work but am really interested in just saving the pic period.
I am not interested in using the Camera API due to other issues. Just really curious about the handling of the intent.
Any help would be appreciated!
Thanks!
Ryan