Broadcast receiver for ACTION_UP of the camera button in android

Samsung Galaxy, Android 1.5. I'm trying to detect when the user releases the camera button. I have a receiver that gets the ACTION_CAMERA_BUTTON intent and examines the EXTRA_KEY_EVENT that comes with it,using the following code (in the onReceive() in the receiver)

public void onReceive(Context context, Intent intent) {
    String intent_action = intent.getAction(); 
     if (intent_action.equals(Intent.ACTION_CAMERA_BUTTON) ) {
                KeyEvent key = (KeyEvent) intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT);

            if ( key.getAction() == KeyEvent.ACTION_DOWN )
                Toast.makeText(context, "press", Toast.LENGTH_SHORT).show();
            else if ( key.getAction() == KeyEvent.ACTION_UP )
                Toast.makeText(context, "release", Toast.LENGTH_SHORT).show();
            else if ( key.getAction() == KeyEvent.ACTION_MULTIPLE )
                Toast.makeText(context, "multi", Toast.LENGTH_SHORT).show();

When I press the button, I only get the "press" popup.

Is this a limitation in the phone or in Android? Is there another way to detect the release of the camera key?

Asked by: Emma838 | Posted: 25-01-2022

Similar questions

Broadcast receiver that listens to hard button in android

Is there a cross device hard button in android that a background service can listen to and act when it is pressed/released? Thanks

java - Broadcast Intent when network state has changend

Does Android broadcast an intent when the network state has changend, i.e. from GSM to Wifi? And if so what permission do I need and what is the intent action called?

android - handling broadcast receiver

I have an app which has MainActivity(without gui.. please just flow with it:) ) now this MainActivity running a service, this service using sendBroadcast() in order to comunnicate with the MainActivity.. now ofcourse i need to registerReceiver in the onResume() of the MainActivity. but i also need to add unregisterReceiver(receiver) in the onDestroy...

Logging broadcast Intents and manually trigger them (Android)

during my development in android I've missed a function that can log every broadcast intent that occur. Sometimes it had been very useful to have a function like that... I'm also wondering how to trigger those broadcast intents manually on the emulator. Is there an entire overview of available broadcast intents? Would be great if someone would have some answers, greets, poeschlorn

widget - Send a public broadcast from an AppWidget in Android

I have a widget for a music player and want to be able to send broadcasts when pushing the different buttons. What I want to do is when a button is pushed, the widget sends a public broadcast to another BroadcastReceiver so it can handle the different actions. In my activity class with the BroadcastReceiver: private BroadcastReceiver broadcastReceiver = new BroadcastReceiver() { @Override public...

android - how can I notify a running activity from a broadcast receiver?

I have an activity, it needs to response to a broadcast event. Since an activity can not be a broadcast receiver at the same time, I made a broadcast receiver. My question is: how can I notify the activity from the broadcast receiver? I believe this is a common situation, so is there a design pattern for this?

java - Cell broadcast support on Android?

Does anyone know if there is a support for cell broadcast on Android? If yes, can anyone point me to any example that shows how to use it? (e.g. receive messages on some channel) Thank you.

android - Update Widget on System Broadcast Intent

I'm working on an Android widget that will show the current network state (i.e 1xRTT, EvDo Rev. A, WiMax, etc.). It may seem like a pointless idea, but for whatever the reason, the Evo doesn't differentiate between 1x & EvDo, it just says 3G for both, which is annoying if you're in a fringe 3G area. Anyways, to the point: I have the widget complete and it updates with the current network just fine, but how can ...

android - sending broadcast intent from runnable

I want to send a broadcast from a new thread is start. This is what i tried : new Thread(new Runnable() { public void run() { //some other code for timing. // .. // .. Intent broadcastIntent = new Intent(); broadcastIntent.setAction(Intent.ACTION_ANSWER); this.sendBroadcast(broadcastIntent); } }).star...

android - How to create a new Intent for another app's broadcast receiver?

In the examples, they create Intent as: Intent intent = new Intent(this, AlarmReceiver.class); But suppose my AlarmReceiver class is in another app, how do I create this intent? I've tried with new Intent("") but nothing happens.. It was not called.. Any idea? --Broadcast definition added using the manifest ...

Still can't find your answer? Check out these communities...

Android Google Support | Android Community | Android Community (Facebook) | Android