start your application on camera button

1778 views
Skip to first unread message

nathab...@gmail.com

unread,
Nov 13, 2008, 11:42:05 PM11/13/08
to Android Developers
How can I set default preference to android open my application when
camera button is clicked?

Thanks in advance,
-abhi

david...@android.com

unread,
Nov 14, 2008, 2:53:31 AM11/14/08
to Android Developers
Register to receive the intent "android.intent.action.CAMERA_BUTTON".
Here's how you might add it to your app's manifest:

<receiver android:name="CameraButtonIntentReceiver">
<intent-filter>
<action android:name="android.intent.action.CAMERA_BUTTON"/>
</intent-filter>
</receiver>

On Nov 13, 8:42 pm, "nathabhis...@gmail.com" <nathabhis...@gmail.com>
wrote:

blindfold

unread,
Nov 14, 2008, 5:41:06 AM11/14/08
to Android Developers
What happens when more than one application has this in the manifest?

Thanks

On Nov 14, 8:53 am, "davidspa...@android.com"

Ludwig

unread,
Nov 14, 2008, 5:53:42 AM11/14/08
to android-d...@googlegroups.com
If you have more than one best matching activity for an intent is to offer you a list to pick the desired activity, with the option of using one as the default (ie do not ask again). It is easy to trigger, just by defining two activities with the same intent...
Ludwig

2008/11/14 blindfold <seeingw...@gmail.com>

blindfold

unread,
Nov 14, 2008, 6:22:06 AM11/14/08
to Android Developers
Thank you, Ludwig! That answers my question, as I was considering
adding the code to my app's manifest as well. Much appreciated.

On Nov 14, 11:53 am, Ludwig <ludwigbrinckm...@gmail.com> wrote:
> If you have more than one best matching activity for an intent is to offer
> you a list to pick the desired activity, with the option of using one as the
> default (ie do not ask again). It is easy to trigger, just by defining two
> activities with the same intent...Ludwig
>
> 2008/11/14 blindfold <seeingwithso...@gmail.com>

nathab...@gmail.com

unread,
Nov 14, 2008, 3:09:32 PM11/14/08
to Android Developers
Thanks Guys. I added a receiver with CAMERA_BUTTON intent-filter and
it then triggers my Main application. But I am not getting the choose
application dialog. Instead, both my Main application and camera
application opens.

<activity android:name="MainApp"
android:label="@string/app_name"
android:theme="@android:style/Theme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category
android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action
android:name="android.intent.action.MY_INTENT"></action>
<category
android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<receiver android:name="MyReceiver">
<intent-filter>
<action android:name="android.intent.action.CAMERA_BUTTON"/>
</intent-filter>
</receiver>

public class MyReceiver extends BroadcastReceiver {

@Override
public void onReceive(Context context, Intent intent) {
Intent newIntent = new Intent(".android.intent.action.MY_INTENT");
context.startActivity(newIntent);
}
}


-abhi

On Nov 14, 2:53 am, Ludwig <ludwigbrinckm...@gmail.com> wrote:
> If you have more than one best matching activity for an intent is to offer
> you a list to pick the desired activity, with the option of using one as the
> default (ie do not ask again). It is easy to trigger, just by defining two
> activities with the same intent...Ludwig
>
> 2008/11/14 blindfold <seeingwithso...@gmail.com>

armand.d...@gmail.com

unread,
Nov 24, 2008, 7:08:58 AM11/24/08
to Android Developers
Hi,

I did what is described above. However, pressing the "native"
camera button doesn't trigger the BroadcastReceiver.onReceive()
invocation. Do I need to specify a specific permission? Am I missing
something else? Is there any other "Camera button" on the SDK than
the central key?
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mycompany.android" android:versionCode="1"
android:versionName="1.0.0">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<application android:icon="@drawable/icon" android:label="@string/
app_name">
<activity android:name=".MyApp" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name=".main.MyReceiver">
<intent-filter>
<action android:name="android.intent.action.CAMERA_BUTTON" />
</intent-filter>
</receiver>
</application>
</manifest>


Armand

On Nov 14, 8:09 pm, "nathabhis...@gmail.com" <nathabhis...@gmail.com>
wrote:

shim...@gmail.com

unread,
Dec 3, 2008, 2:32:46 PM12/3/08
to Android Developers
Hi,

I cant get this to work. I am trying this for the CALL_BUTTON and on
the emulator.

Added the lines below to my manifest.
Created the MyReceiver class just like you do here.

Then trying to register the receiver in OnCreate:

IntentFilter filter = new IntentFilter
("android.intent.action.CAMERA_BUTTON");
Intent intnt = registerReceiver(mCallButtonIntentReceiver,
filter);

intnt always return null.

What am I doing wrong here ?

TIA

Shimon

On Nov 14, 10:09 pm, "nathabhis...@gmail.com" <nathabhis...@gmail.com>
wrote:

Dianne Hackborn

unread,
Dec 3, 2008, 3:26:41 PM12/3/08
to android-d...@googlegroups.com
The call button starts an activity, it doesn't send a broadcast, as described in the doc.  (Yes this is inconsistent with the camera button and the camera button should probably be changed.)
--
Dianne Hackborn
Android framework engineer
hac...@android.com

Note: please don't send private questions to me, as I don't have time to provide private support.  All such questions should be posted on public forums, where I and others can see and answer them.

shim...@gmail.com

unread,
Dec 10, 2008, 6:50:58 AM12/10/08
to Android Developers
Hi,

So are you saying it cant be done ?

There is no way I make my app launch when the user presses the CALL
button ?

Only access to 3rd party is by tapping their icon on the screen ?

Or can I pretent to be the built-in app ?

TIA
Shimon

On Dec 3, 10:26 pm, "Dianne Hackborn" <hack...@android.com> wrote:
> The call button starts an activity, it doesn't send a broadcast, as
> described in the doc.  (Yes this is inconsistent with the camera button and
> the camera button should probably be changed.)
>
> hack...@android.com
Reply all
Reply to author
Forward
0 new messages