Delayed image capturing - android

I know that is easy to fire an intent for image capturing and then after the user press on the capture button to take the image location of the image...
But I want to do something like this:
-user press a button
-camera app is started
-after 10seconds the image is taken automatically (no user interaction needed)

i think for your custom use case, you could write your own camera activity and then capture at 10 seconds
Edit: you can use this tutorial http://code.google.com/p/openmobster/wiki/CameraTutorial
Also the camera preview is present in apidemos application. It is present at Graphics->CameraPreview.

hmmm, maybe have a handler with a counter updating a TextView every second (So the app isnt seen as frozen) and then once the counter has reached ten take the photo
int counter2 = 0;
private Runnable mUpdateTimeTask2 = new Runnable() {
public void run() {
if (counter2 == 10){
takepicture();
}
counter2++;
mHandler.postDelayed(this, 1000);
}
};

Related

I want to start a service only when a new picture is clicked in android. How do I go about doing that?

I want to start a service only when a new picture is captured from the phone camera in android. How do I go about doing that? Currently, I am running a background task that runs every 3 seconds to check if a new picture has been clicked.
You can have tracks for image clicks then check those tracks every 3 seconds.
final boolean hasClicked = false;
new View.OnClickListener() { //image onclick listener
hasClicked = true;
}
new Timer.schedule(new TimerTask() {
if ( hasClicked ) {
// start your service
}
}, 3000, 3000);
If you need to track how many times the user clicked the image before the interval you can make a counter for it. be careful about the spam clicks.
There are currently no APIs for logging and monitoring camera activity, probably for privacy and security reasons

android: checking and changing image of button

in my application i'm checking image of button for 1sec.n changing it.what happen is when first time it checks n changes image of button.and the 2nd time its not changing the image.
here is the code-
myTimer.schedule(new TimerTask() {
#Override
public void run() {
runOnUiThread(new Runnable() {
public void run() {
Random rand=new Random();
int num = rand.nextInt(buttonIds.length);
int buttonId = buttonIds[num];
Button bb=(Button) findViewById(buttonId);
Drawable a=bb.getBackground();
if(getResources().getDrawable(R.drawable.happy).equals(a))
{
bb.setBackgroundResource(R.drawable.happy);
}
else
{
bb.setBackgroundResource(R.drawable.whoa);
}
}
});
}
},0, 1000);
first time image of button is happy(name of image file).
how can i change image of button and also check??
Thanku
I think your if condition is not correct, you a checking if the background image is happy, you are again setting happy..instead you should set whoa...
If I were you, I would use a boolean(isHappy) to notify if the picture is happy or not, it is easier and faster since you don't have to instance the current image and maybe it will solve your problem, I am not completely sure about "equals" works like that, but is only my guess.
Anyway I think your code has a small mistake, the condition makes the picture to be always happy.

Dynamic ImageView in android

I'm a newbie in android so please don't judge me hard.
I'm trying to create a screen with two areas, an image area and a text area.
In the image area several images should be changed within a periodical time, 3-4 seconds. (Please see the image: )
Can you please give me an example how can I accomplish this?
Thank you.
You can use CountDownTimer class for this.
Or you can use a Gallery with Thread and Handler to achieve this.
Here is a link to the project called AutoSlideGallery,
https://github.com/nixit28/AutoSlideGallery
The core logic is here,
(new Thread() {
public void run() {
myslideshow();
handler.postDelayed(this, 2000); // execute every two second.
}
}
).start();
And the method which performs the action,
private void myslideshow() {
PicPosition = gallery.getSelectedItemPosition() + 1;
if (PicPosition >= pics.length)
gallery.setSelection(0); // stop
else
gallery.setSelection(PicPosition);// move to the next gallery
// element.
}

do while with android button

Can you please help me some in this simple task? please see the attachment. you can do the task there.
I want to start a do-while loop by pressing a button to print some numbers,
in the mean time the button will be ready for take next touch, (I mean one button will work for two task.)
in the next touch the button will stop to print those numbers.
if again I touch the same button then it will start print the numbers from the beginning.
Like: I press the button...its prining 1,2,3,4,5,6,7 then I press the button again then it stoped. then again I press the same button the its start to print 1,2,3...and so on.
means The process will run one the back of the interface.
I hope you can understand me.
can you please hep me on that?
Something like this should work. No need for multithreading really.
{
Handler mHandler = new Handler();
private boolean running;
myButton.setOnClickListener(this);
}
public void onClick(View v) {
if(!running) {
mHandler.post(numberPrinter);
} else {
mHandler.removeCallBacks(numberPrinter);
running = false;
}
}
Runnable numberPrinter = new Runnable() {
int i = 0;
public void run(){
running = true;
System.out.println(i++);
mHandler.postDelayed(this, 1000);
};
hey u can do it with multi threading .
create a thread that will do printing .
and on onClick event of button call the method that will call the Thread and Start and Stop the same.

Shorter delay in android slideshow

So im making a slideshow in android that i want to move very fast to look almost as though an animation. Bellow is the code that i am using but i want it go move faster(smaller delay) but i cant make the postDelay any smaller. How would i do this? If its not possible what would a better way to do this be?
private Runnable runnable = new Runnable() {
public void run() {
myslideshow();
handler.postDelayed(this, 1);
}
};
private void myslideshow()
{
if (position < imageIDs.length){
iv.setImageResource(imageIDs[position]);
position++;
}
else{
iv.setImageResource(R.drawable.logo);
}
}
Could the Android Animation API help instead?
You can use a gallery. On click of some button or anything you can run a for loop to
display next element in the gallery till the last element (image in your case) is displayed

Categories

Resources