Problem with detecting that picture was taken by camera

Put your problem here if it does not fit any of the other categories.

Problem with detecting that picture was taken by camera

Postby mihalich2009 » Mon Sep 06, 2010 2:23 pm

Hello everyone.

I'm currently wiriting app which needs to work in background and react(upload picture/video file) when user takes picture/video by camera.

I was thinking about doing it using broadcast receiver.
This is quotes from http://developer.android.com/guide/topi ... ntals.html:

Many broadcasts originate in system code — for example, announcements that the timezone has changed, that the battery is low, that a picture has been taken, or that the user changed a language preference.


But I can't find intent action for this event(I found only ACTION_CAMERA_BUTTON but it's not what I'm looking for I think).

Does anyone know what action I need or can suggest how to realize such application in other way(may be I just should create service which will monitor folder with images/videos each minute for example and detect new ones)?

Thank you.

Best regards,
Andrew.
mihalich2009
Freshman
Freshman
 
Posts: 2
Joined: Mon Sep 06, 2010 2:11 pm

Top

Re: Problem with detecting that picture was taken by camera

Postby techkanika » Sat Sep 11, 2010 6:52 am

Hi mihalich2009

Try the following code. This will notify you whenever image is clicked.
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.        public class ImageObserver extends ContentObserver
  2.         {
  3.           .......................
  4.            .......................
  5.  
  6.  
  7.          public void startMonitoring()
  8.         {
  9.                 monitorStatus = false;
  10.                 if (!monitorStatus)
  11.                 {
  12.                         curval = context.getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, null, null, null, null);
  13.                         if (curval != null && curval.getCount() > 0)
  14.                         {
  15.                                 contactCount = curval.getCount();
  16.                         }
  17.                 }
  18.         }
  19.        
  20.         @Override
  21.         public boolean deliverSelfNotifications()
  22.         {
  23.                 return true;
  24.         }
  25.        
  26.         public void onChange(boolean selfChange)
  27.         {
  28.                 super.onChange(selfChange);
  29.                 startMonitoring();
  30.                 Thread thread = new Thread() {
  31.                 public void run()
  32.                 {
  33.                     try
  34.                      {
  35.                         cur = context.getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, null, null, null, null);
  36.                         curCount = 0;
  37.                         if (cur != null && cur.getCount() > 0)
  38.                         {
  39.                         curCount = cur.getCount();
  40.                         }
  41.                         if ((curCount >= contactCount))
  42.                         {
  43.                         contactCount = curCount;
  44.                         cur.moveToLast();
  45.                         name = cur.getString(cur.getColumnIndex(MediaStore.Images.Media.DISPLAY_NAME));
  46.                        Log.v("Image Added : ", name);
  47.                         }
  48.                         }
  49.                         catch (Exception e)
  50.                         {
  51.                                         Log.v("MyApp", "Exception in Monitor.onChange - " + e.getMessage());
  52.                         }
  53.                         }
  54.                 };thread.start();
  55.         }
  56. }
  57.  
Parsed in 0.036 seconds, using GeSHi 1.0.8.4


hope this will help you..

Kanika
Thanks
Kanika Rakheja
User avatar
techkanika
Experienced Developer
Experienced Developer
 
Posts: 83
Joined: Fri May 28, 2010 7:49 am

Re: Problem with detecting that picture was taken by camera

Postby mihalich2009 » Sat Sep 11, 2010 7:50 pm

Thank you,
very much.

Will try your code.

Best regards,
Andrew.
mihalich2009
Freshman
Freshman
 
Posts: 2
Joined: Mon Sep 06, 2010 2:11 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Exabot [Bot] and 20 guests