The Android Open Source Project | b64d345 | 2009-03-03 19:32:20 -0800 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package com.android.camera; |
| 18 | |
Ray Chen | 23c51b7 | 2009-04-10 03:41:00 -0700 | [diff] [blame] | 19 | import android.content.BroadcastReceiver; |
The Android Open Source Project | b64d345 | 2009-03-03 19:32:20 -0800 | [diff] [blame] | 20 | import android.content.Context; |
| 21 | import android.content.Intent; |
The Android Open Source Project | b64d345 | 2009-03-03 19:32:20 -0800 | [diff] [blame] | 22 | |
Chih-Chung Chang | b05be85 | 2009-04-20 18:40:43 +0800 | [diff] [blame] | 23 | public class CameraButtonIntentReceiver extends BroadcastReceiver { |
Ray Chen | 23c51b7 | 2009-04-10 03:41:00 -0700 | [diff] [blame] | 24 | public CameraButtonIntentReceiver() { |
| 25 | } |
Chih-Chung Chang | 0a475e1 | 2009-04-16 11:42:12 +0800 | [diff] [blame] | 26 | |
The Android Open Source Project | b64d345 | 2009-03-03 19:32:20 -0800 | [diff] [blame] | 27 | @Override |
| 28 | public void onReceive(Context context, Intent intent) { |
Owen Lin | 3f3c857 | 2009-08-18 13:33:49 +0800 | [diff] [blame] | 29 | // Try to get the camera hardware |
Owen Lin | d9e3240 | 2009-09-09 18:39:38 +0800 | [diff] [blame] | 30 | 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 Project | b64d345 | 2009-03-03 19:32:20 -0800 | [diff] [blame] | 36 | Intent i = new Intent(Intent.ACTION_MAIN); |
| 37 | i.setClass(context, Camera.class); |
Chih-Chung Chang | b05be85 | 2009-04-20 18:40:43 +0800 | [diff] [blame] | 38 | i.addCategory("android.intent.category.LAUNCHER"); |
The Android Open Source Project | b64d345 | 2009-03-03 19:32:20 -0800 | [diff] [blame] | 39 | i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| 40 | context.startActivity(i); |
| 41 | } |
| 42 | } |