1. Check out our companion app, Forums for Android! Download from Google Play

Auto upload of pictures to ftp

Discussion in 'Application Requests' started by LincKraker, Dec 11, 2009.

  1. LincKraker

    LincKraker Well-Known Member
    Thread Starter
    43

    Features
    - upload last picture taken with camera to FTP
    - take pictures every X secs
    - set name of picture on the ftp side with option to replace the current picture or add a number to the file name

    I plan on using it to upload the last picture taken with my camera to a blog or website. I had an app on my WM phone before switching.
     

    Advertisement

  2. Ajes

    Ajes New Member
    5

    Nov 8, 2010
    3
    0
    5
    yes please please make this app!

    or does anyone know an exitsting app that does this?
     
  3. aguywithathing

    16

    Oct 12, 2010
    18
    5
    16
    Ajes likes this.
  4. blandger

    blandger Member
    6

    Nov 10, 2010
    9
    1
    6
    Developer java/C#
    Europe
    Ajes likes this.
  5. Ajes

    Ajes New Member
    5

    Nov 8, 2010
    3
    0
    5

    only need 1 thing more..:

    an app that auto take a picture every 30 sec, or similar?
     
  6. ollyhicks

    ollyhicks New Member
    5

    Jun 7, 2011
    1
    0
    5
    Did you find anything? Might have a go and see if I could make such an app
     
  7. eurobears

    eurobears Member
    25

    Oct 3, 2011
    5
    0
    25
    Hi,
    I am working on that project,
    It works ...one shot, then it crash.
    I have created 2 activities, I m using alarmManager.setRepeating to repeat the camera thread.
    If you have time to help, here is my code::thinking:
    Manifest with 2 activity
    Code (Text):
    1.  
    2. <?xml version="1.0" encoding="utf-8"?>
    3. <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    4.       package="exo.com.FtpCam"
    5.       android:versionCode="1"
    6.       android:versionName="1.0">
    7.     <application android:icon="@drawable/icon" android:label="@string/app_name">
    8.         <activity android:name=".FtpCam"
    9.                   android:label="@string/app_name">
    10.             <intent-filter>
    11.                 <action android:name="android.intent.action.MAIN" />
    12.                 <category android:name="android.intent.category.LAUNCHER" />
    13.             </intent-filter>
    14.         </activity>:confused::confused:
    15.         <activity android:name=".AndroidCamera" android:label="@string/app_name">
    16.        </activity>
    17.         <service android:name=".MyAlarmService" />
    18.     </application>
    19.     <uses-sdk android:minSdkVersion="4" />
    20.     <uses-permission android:name="android.permission.FTP" />
    21.     <uses-permission android:name="android.permission.WIFI" />
    22.     <uses-permission android:name="android.permission.CAMERA" />
    23.     <uses-permission android:name="android.permision.WRITE_EXTERNAL_STORAGE" />
    24. </manifest>
    25.  
    The main
    Code (Text):
    1. package exo.com.FtpCam;
    2.  
    3. import java.util.Calendar;
    4.  
    5. import android.app.Activity;
    6. import android.app.AlarmManager;
    7. import android.app.PendingIntent;
    8. import android.content.Intent;
    9. import android.os.Bundle;
    10. import android.view.View;
    11. import android.widget.Button;
    12. import android.widget.Toast;
    13.  
    14. public class FtpCam extends Activity {
    15.  
    16. private PendingIntent pendingIntent;
    17.  
    18.  /** Called when the activity is first created. */
    19.  @Override
    20.  public void onCreate(Bundle savedInstanceState) {
    21.  
    22.      super.onCreate(savedInstanceState);
    23.  
    24.      Intent myIntent = new Intent(FtpCam.this, AndroidCamera.class);
    25.      :confused::confused:pendingIntent = PendingIntent.getActivity(FtpCam.this, 0, myIntent, 0);
    26.  
    27.      AlarmManager alarmManager = (AlarmManager)getSystemService(ALARM_SERVICE);
    28.  
    29.      Calendar calendar = Calendar.getInstance();
    30.      calendar.setTimeInMillis(System.currentTimeMillis());
    31.      calendar.add(Calendar.SECOND, 5);
    32.      alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), 20*1000, pendingIntent);}}
    The camera
    Code (Text):
    1. package exo.com.FtpCam;
    2.  
    3. import java.io.FileNotFoundException;
    4. import java.io.IOException;
    5. import java.io.OutputStream;
    6.  
    7. import android.app.Activity;
    8. import android.content.ContentValues;
    9. import android.content.pm.ActivityInfo;
    10. import android.graphics.Bitmap;
    11. import android.graphics.BitmapFactory;
    12. import android.graphics.PixelFormat;
    13. import android.hardware.Camera;
    14. import android.hardware.Camera.AutoFocusCallback;
    15. import android.hardware.Camera.PictureCallback;
    16. import android.net.Uri;
    17. import android.os.Bundle;
    18. import android.provider.MediaStore.Images.Media;
    19. import android.view.SurfaceHolder;
    20. import android.view.SurfaceView;
    21. import android.widget.Toast;
    22.  
    23. public class AndroidCamera extends Activity implements SurfaceHolder.Callback{
    24.  
    25. Camera camera;
    26. SurfaceView surfaceView;
    27. SurfaceHolder surfaceHolder;
    28. boolean previewing = false;;
    29.  
    30.   /** Called when the activity is first created. */
    31.   @Override
    32.   public void onCreate(Bundle savedInstanceState) {
    33.       super.onCreate(savedInstanceState);
    34.       setContentView(R.layout.main); //on utilise le xml main
    35.       setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    36.    
    37.       getWindow().setFormat(PixelFormat.UNKNOWN);
    38.       surfaceView = (SurfaceView)findViewById(R.id.camerapreview); //la zone dans le xml
    39.       surfaceHolder = surfaceView.getHolder();
    40.       surfaceHolder.addCallback(this);
    41.       surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
    42.   }
    43.  
    44. // ici les differentes callback :
    45.  
    46.   AutoFocusCallback myAutoFocusCallback = new AutoFocusCallback(){
    47.  
    48.       @Override
    49.       public void onAutoFocus(boolean arg0, Camera arg1) {
    50.        //take photo larque la photo est OK
    51.        camera.takePicture(null, null, myPictureCallback_JPG);
    52.        //camera.takePicture(null, null, null);
    53.       }};
    54.      
    55.   PictureCallback myPictureCallback_JPG = new PictureCallback(){
    56.  
    57.     public void onPictureTaken(byte[] arg0, Camera arg1) {
    58.       // TODO Auto-generated method stub
    59.       Uri uriTarget = getContentResolver().insert(Media.EXTERNAL_CONTENT_URI, new ContentValues());
    60.       OutputStream imageFileOS;
    61.       try {
    62.        imageFileOS = getContentResolver().openOutputStream(uriTarget);
    63.        imageFileOS.write(arg0);
    64.        imageFileOS.flush();
    65.        imageFileOS.close();
    66.  
    67.        /*Toast.makeText(AndroidCamera.this,
    68.          "Image saved: " + uriTarget.toString(),
    69.          Toast.LENGTH_LONG).show();*/
    70.        
    71.       } catch (FileNotFoundException e) {
    72.        // TODO Auto-generated catch block
    73.        e.printStackTrace();
    74.       } catch (IOException e) {
    75.        // TODO Auto-generated catch block
    76.        e.printStackTrace();
    77.       }
    78.      
    79.     }};
    80.  
    81. @Override
    82. public void surfaceChanged(SurfaceHolder holder, int format, int width,
    83.  int height) {
    84. // TODO Auto-generated method stub
    85. if(previewing){
    86.  camera.stopPreview();
    87.  previewing = false;
    88. }
    89.  
    90. if (camera != null){
    91.  try {
    92.   camera.setPreviewDisplay(surfaceHolder);
    93.   camera.startPreview();
    94.   previewing = true;
    95.  
    96.   //Autofocus, la photo est prise dans la callback, qui indique que l image est nette
    97.   camera.autoFocus(myAutoFocusCallback);
    98.  
    99.  
    100.  } catch (IOException e) {
    101.   // TODO Auto-generated catch block
    102.   e.printStackTrace();
    103.  }
    104. }
    105. }
    106.  
    107. @Override
    108. public void surfaceCreated(SurfaceHolder holder) {
    109. // TODO Auto-generated method stub
    110. camera = Camera.open();
    111. }
    112.  
    113.  
    114. // Mise en pause de l'application
    115. @Override
    116. public void onPause() {
    117.     super.onPause();
    118.  
    119.     if (camera != null) {
    120.         camera.release();
    121.         camera = null;
    122.     }
    123. }
    124.  
    125. @Override
    126. public void surfaceDestroyed(SurfaceHolder holder) {
    127. // TODO Auto-generated method stub
    128. camera.stopPreview();
    129. camera.release();
    130. camera = null;
    131. previewing = false;
    132. //super.onDestroy();
    133. Toast.makeText(this, "MyAlarmService.onDestroy()", Toast.LENGTH_LONG).show();
    134. }
    135. }
     
  8. eurobears

    eurobears Member
    25

    Oct 3, 2011
    5
    0
    25
    here is my first project
    the webcam wifi android is working on my sony x10 mini (2.1)

    the beta v1 apk is available here !

    Solar Android Webcam
     
  9. eurobears

    eurobears Member
    25

    Oct 3, 2011
    5
    0
    25
  10. eurobears

    eurobears Member
    25

    Oct 3, 2011
    5
    0
    25
  11. krikit

    krikit Active Member
    36

    Jul 22, 2010
    37
    4
    36
    Male
    Foldersync works pretty well. The photos taken on our phones are auto named by date and time, so I haven't needed that feature. If the option isn't there, there may be a separate app for such auto renaming.

    Also, you may only need the lite version of Foldersync. Hope that helps! :D
     

Share This Page

Loading...