Skip to content

CommunicationOut

Ahmed Khalil edited this page Apr 25, 2018 · 3 revisions

This activity class is in charge of taking a picture and uploading it to Twitter. This activity extends AppCpmpatActivity for basic layout functionality and implements CameraFragmentResultListener, which enables the image taking process.

onCreate

Here the activity's layout is inflated and the camera fragment is initialized. Afterwards, by a delay of 3 seconds, the takeAPicture() method is called upon to take the image.

takeAPicture()

This method uses the camera fragment to obtain an image. The image is saved to file.

onPhotoTaken(byte[] bytes, String filePath)

This is a method implemented by CameraFragmentResultListener, it is called immediately once a picture is captured on a camera fragment. This method calls postToTwitter() and sends to it the image's file path. Furthermore, this method creates an intent for CentralHub and starts it after a delay of 3 seconds. The delay allows the app enough time to upload the image prior to returning to the app's main activity.

  • Parameters:
    • byte[] bytes: this contains the image information.
    • String filepath: this contains the image's file address and is sent to postToSlack().

public void onVideoRecorded(String filePath)

A similar function to onPhotoTaken(), although only triggered when a video is recorded. This method is not used in this project scope, but is present due to the CameraFragmentResultListener implementation.

postToSlack(String filepath, String channel)

This method posts an image to Slack with a caption.

  • Parameters:
    • String filePath: the image's file address for retrieval.
    • String channel: Slack channel to post on.