在onReceive中调用一个方法

时间:2017-01-07 11:56:52

标签: android broadcastreceiver

无法在onReceive()中调用cameraImage()方法。

   private BroadcastReceiver dataReceiver = new BroadcastReceiver() {
    @Override
    public void onReceive(Context context, Intent i) {
        Log.e("Data", "Service Recieved");

        responseString = i.getStringExtra(DataRequest.EXTENDED_DATA_STATUS);
        textView.setText(responseString);

        if (Float.parseFloat(responseString) < 100) {
            cameraImage();
        }

    }
};

cameraImage()是用同一个活动编写的

public void cameraImage(){
    camera.takePicture(null, null, jpegCallback);
}

0 个答案:

没有答案