0

在我的项目中,我尝试在 onReceive 方法中实现相机动作。单击相机图标时,我们可以打印日志。我在广播接收器中尝试过。但我无法得到结果。我在这里附上了我的一段代码。

    public void onReceive(Context context, Intent intent) {

        if (intent.getAction().equals(Intent.ACTION_CAMERA_BUTTON)) {

            Log.e("cam0","cam");
        //Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
        //context.startService(cameraIntent);
   // startActivity(cameraIntent, CAMERA_PIC_REQUEST);
        }
    }

是否可以为此打印日志。我在敲我的头,我仍然找不到结果。在这种情况下寻求帮助。先感谢您。

4

1 回答 1

1

You can create a filter for Logcat so that every log with a specific TAG gets grouped together for quick and easy viewing. Just open up the Logcat view and to the left there is a button (green plus sign) for adding new filters.

And its convention to declare a constant in the class to be used as a log tag, for example private static final string TAG = TAG_camActivity.

If the log isn't showing up then that if statement in all likelihood isn't being evaluated to true.

于 2012-05-26T11:26:00.007 回答