blob: 0d9c4fb204df9d46eac5f6c0bc670be867521c28 [file] [log] [blame]
The Android Open Source Projectb64d3452009-03-03 19:32:20 -08001/*
2 * Copyright (C) 2007 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.camera;
18
Ray Chen23c51b72009-04-10 03:41:00 -070019import android.content.BroadcastReceiver;
The Android Open Source Projectb64d3452009-03-03 19:32:20 -080020import android.content.Context;
21import android.content.Intent;
The Android Open Source Projectb64d3452009-03-03 19:32:20 -080022
Chih-Chung Changb05be852009-04-20 18:40:43 +080023public class CameraButtonIntentReceiver extends BroadcastReceiver {
Ray Chen23c51b72009-04-10 03:41:00 -070024 public CameraButtonIntentReceiver() {
25 }
Chih-Chung Chang0a475e12009-04-16 11:42:12 +080026
The Android Open Source Projectb64d3452009-03-03 19:32:20 -080027 @Override
28 public void onReceive(Context context, Intent intent) {
Owen Lin3f3c8572009-08-18 13:33:49 +080029 // Try to get the camera hardware
Owen Lind9e32402009-09-09 18:39:38 +080030 CameraHolder holder = CameraHolder.instance();
31 if (holder.tryOpen() == null) return;
32
33 // We are going to launch the camera, so hold the camera for later use
34 holder.keep();
35 holder.release();
The Android Open Source Projectb64d3452009-03-03 19:32:20 -080036 Intent i = new Intent(Intent.ACTION_MAIN);
37 i.setClass(context, Camera.class);
Chih-Chung Changb05be852009-04-20 18:40:43 +080038 i.addCategory("android.intent.category.LAUNCHER");
The Android Open Source Projectb64d3452009-03-03 19:32:20 -080039 i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
40 context.startActivity(i);
41 }
42}