0

I need a workaround for the following task: I have a JPG (of whatever) picture on my sd card, and I need to send it to another device in the background. How should I do that? Best way (in theory) would be via MMS, but after a lof of searching, I can say that there is no official and trustful (and working) way to do that in the background.

Any ideas, samples, even proofs that it can be done are welcomed! All that matters is that a remote device must have access to that image.

keybee
  • 1,428
  • 19
  • 28
  • Make it clear? do you want it to do in program or via device? – Kailash Ahirwar Sep 17 '13 at 08:37
  • I need this feautre in my app (to be able to give access for a file for remote devices). Like sending sms silently, in the background - the problem is I have images, not only text. – keybee Sep 17 '13 at 08:54
  • is sender know about sending process?? if not then i think it would a security breach. Accessing someone's data without his consent is security issue. Android does not permits that. – Kailash Ahirwar Sep 17 '13 at 09:06
  • The user is not allowed to know that. It is exactly for security reasons, since it is a security app. Android permits almost everything if the app has neccessary permissions. You can download and upload content in the background, turn on and off network, send sms in background silently, make photos --> with the permissions, all these things can be done without any user interactivity. (You could even set up programmatically a password protected screen lock) – keybee Sep 17 '13 at 09:11
  • you have necessary permissions to read file. Convert it to base64 code & make a http request to your server. Send base64 code via url PUT or POST HTTP request. On server you can easily receive PUT or POST data via php global arrays – Kailash Ahirwar Sep 17 '13 at 09:19

3 Answers3

0

if you want the sending to happen in background you could use android beam, but you would have to get both devices cloth together.

And as i am not sure about what u mean by background i can't be sure that thats what you want. :)

Kailash Ahirwar
  • 755
  • 3
  • 13
Daniel Bo
  • 2,478
  • 1
  • 16
  • 28
  • I mean, without the user knowing it (i have a security app), whithout popping up any apps. My app is running, and it should send an image over the network. android beam is not good for me, it should work even if the other device is on the other side of the word. Like sending sms silently from code, in the background. – keybee Sep 17 '13 at 08:58
0

First of all you need to create a "Service" in App which will run in background and do all tasks given below. A central PHP Server required for this task. Other device can download that file by the same HTTP request method.

  • Convert image to base64 string--

How to convert a image into Base64 string?

you can convert byte array to suitable types- string or delimiter(, or .) separated string

  • Then create a HTTP request--

Make an HTTP request with android

for HTTP request create a url like this - https://www.yoursite.com/post/?code="base64 string goes here"

-Receive data in php file on your server by $_GET global array

$code = $_GET['code']
  • In php file convert base64 code to original image.

How to decode a base64 string (gif) into image in PHP / HTML

get image from base64 string

Community
  • 1
  • 1
Kailash Ahirwar
  • 755
  • 3
  • 13
0

Maybe I explained badly my needs. An important thing I missed is that the same person has access to both device. I solved it by uploading the image to google drive.

keybee
  • 1,428
  • 19
  • 28