<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Harrison Oglesby on Medium]]></title>
        <description><![CDATA[Stories by Harrison Oglesby on Medium]]></description>
        <link>https://medium.com/@oglesby.harrison?source=rss-d167f7de6300------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*cy2K9ocd5B-PUK-TzT94Mw.png</url>
            <title>Stories by Harrison Oglesby on Medium</title>
            <link>https://medium.com/@oglesby.harrison?source=rss-d167f7de6300------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 05:28:34 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@oglesby.harrison/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Developing for SnapKit on Android: Creative Kit SDK for Snapchat]]></title>
            <link>https://medium.com/@oglesby.harrison/developing-for-snapkit-on-android-creative-kit-sdk-for-snapchat-27c34378607?source=rss-d167f7de6300------2</link>
            <guid isPermaLink="false">https://medium.com/p/27c34378607</guid>
            <category><![CDATA[snapkit]]></category>
            <category><![CDATA[snapchat]]></category>
            <category><![CDATA[snapchatapi]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Harrison Oglesby]]></dc:creator>
            <pubDate>Wed, 28 Nov 2018 21:42:05 GMT</pubDate>
            <atom:updated>2021-07-19T21:40:07.360Z</atom:updated>
            <content:encoded><![CDATA[<p>{Edit 7/19/21: this article is now very out-dated and I may or may not get around to updating it.}</p><p>Snapchat announced their developer SDK in mid-June of this year and has released their documentation <a href="https://docs.snapchat.com/docs/">here</a>. While it is clear that they are making a robust, useful API for developers to link to new or already existing apps, their documentation is still in the very early stages of development.</p><p>As such, there are no sample apps currently in their documentation or on GitHub (at least none when I started writing this article). Since I already integrated the Snap Kit SDK for my job at Poshmark, I thought I would help by writing an instructional article on integrating Snap Kit (the Creative Kit) into a small app and also posting the sample code on <a href="https://github.com/HarrisonOg/SnapKitTestApp">GitHub</a>.</p><p>This may seem lengthy but I wanted to make sure I covered the entirety of integrating basic Snapchat photo content send call into an app with an image picker including signing up for a Snap Kit client ID.</p><h3><strong>Setting up on the Snap Kit developer portal</strong></h3><p>First things first: get a client ID from the <a href="https://kit.snapchat.com/portal/">Snap Kit developer portal</a>.</p><p>Important: You will need a Snapchat account to register for the Snap Kit developer portal.</p><p>Create a Snapchat account ( I strongly advise against using your personal account for testing/development especially if you are doing this for your company) and agree to the Developer Terms of Service.</p><p>In the dashboard, click the big “+” button and create your app.</p><p>After you hit “continue”, you will be taken to your app’s dashboard.</p><p>In order to make use of the client IDs that you are given for your app, you will need to put in the package name of the app you are building, using your “dev” or testing build package name for the Development app package name.</p><p>If you do not know how to find your app package name, check out Google’s documentation <a href="https://developer.android.com/studio/build/application-id">here</a>.</p><p>Now that you have a Snap Kit client ID, it is time to start building the application.</p><p>For the sake of this simplified exercise, I have created a small sample app called “SnapKitTestApp” using the standard Android Studio flow and an empty Activity.</p><h3><strong>Importing Snapchat [and other libraries]</strong></h3><p>Put the following in the Project level build.gradle file in the “allprojects” section inside of “repositories”:</p><pre>maven {<br>    url &quot;https://storage.googleapis.com/snap-kit-build/maven&quot;<br>}</pre><p>Put the following in the module level build.gradle file in the dependencies section:</p><pre>implementation([<br>        &#39;com.snapchat.kit.sdk:creative:1.1.3&#39;,<br>        &#39;com.snapchat.kit.sdk:core:1.1.3&#39;<br>])</pre><p>[Version numbers may change, check latest <a href="https://docs.snapchat.com/docs/downloads/">documentation</a> for latest version]</p><p>This is also when we will implement the image picker library [I will be using EasyImage from <a href="https://github.com/jkwiecien/EasyImage">jkwiecien</a>] and a permissions library [I will be using EasyPermissions from <a href="https://github.com/googlesamples/easypermissions">Google Samples</a>]. There’s no point in reinventing the wheel for this short project.</p><p>Put the following in the Project level build.gradle file in the “allprojects” section inside of “repositories”:</p><pre>maven { url &#39;https://jitpack.io&#39; }</pre><p>Put the following in the module level build.gradle file in the dependencies section:</p><pre>implementation &#39;com.github.jkwiecien:EasyImage:2.1.0&#39;<br>implementation &#39;pub.devrel:easypermissions:1.2.0&#39;</pre><p>Add the following inside the &lt;application&gt; tag in the Android Manifest file below the Main Activity:</p><pre>&lt;provider            android:authorities=&quot;${applicationId}.fileprovider&quot;            android:name=&quot;android.support.v4.content.FileProvider&quot;            android:exported=&quot;false&quot;            android:grantUriPermissions=&quot;true&quot;&gt;            <br>&lt;meta-data                android:name=&quot;android.support.FILE_PROVIDER_PATHS&quot;                android:resource=&quot;@xml/filepaths&quot;                /&gt;        &lt;/provider&gt;</pre><p>After the &lt;provider&gt;, add the Snapchat Kit app id as so:</p><pre>&lt;meta-data android:name=&quot;com.snapchat.kit.sdk.clientId&quot; android:value=&quot;your-client-id-here&quot; /&gt;</pre><p>Now, sync your gradle files and we will construct the simple UI for this app.</p><h3><strong>UI</strong></h3><p>I’m not going to spend much time on the UI since this is just a sample app for demonstrating how to use an SDK to link to an external app. There is just a button for starting the send snap process and a text view.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/280/1*gxijXd4DZTC7ND3KJUl6MQ.png" /></figure><h3><strong>Linking everything up</strong></h3><p>Now we go to the MainActivity to link the Button, the image picker and the SnapKit API.<br>First, initialize the button and assign a click listener in onCreate(). We also set up the EasyImage picker.</p><pre>EasyImage.<em>configuration</em>(this)<br>        .setAllowMultiplePickInGallery(false);</pre><pre>Button <em>sendButton </em>= findViewById(R.id.<em>sendPhotoButton</em>);<br><em>sendButton</em>.setOnClickListener(new View.OnClickListener() {<br>    @Override<br>    public void onClick(View <em>v</em>) {<br>        startPhotoSend();<br>    }<br>});</pre><p>startPhotoSend() checks for permissions. If the app has the permission to write to storage, it opens the PhotoPicker. Otherwise, it asks for Permission then the user can retry.</p><pre>private void startPhotoSend() {<br>    String[] <em>perms </em>= {Manifest.permission.<em>WRITE_EXTERNAL_STORAGE</em>};<br>    if(EasyPermissions.<em>hasPermissions</em>(this, <em>perms</em>)) {<br>        //has permissions<br>        EasyImage.<em>openGallery</em>(MainActivity.this, 0);<br>        photoPicker = true;<br>    } else {<br>        //does not have permissions<br>        EasyPermissions.<em>requestPermissions</em>(this, getString(R.string.<em>app_permission_text</em>), <em>WRITE_STORAGE_PERM</em>, Manifest.permission.<em>WRITE_EXTERNAL_STORAGE</em>);<br>    }<br>}<br><br>@Override<br>public void onRequestPermissionsResult(int <em>requestCode</em>, String[] <em>permissions</em>, int[] <em>grantResults</em>) {<br>    super.onRequestPermissionsResult(<em>requestCode</em>, <em>permissions</em>, <em>grantResults</em>);<br><br>    // Forward results to EasyPermissions<br>    EasyPermissions.<em>onRequestPermissionsResult</em>(<em>requestCode</em>, <em>permissions</em>, <em>grantResults</em>, this);<br>}</pre><p>When the photo is picked (note we disabled multiple pick in gallery in the set up of the EasyImage), we handle the result in onActivityResult().</p><pre>@Override<br>protected void onActivityResult(int <em>requestCode</em>, int <em>resultCode</em>, Intent <em>data</em>) {<br>    super.onActivityResult(<em>requestCode</em>, <em>resultCode</em>, <em>data</em>);<br>    if(photoPicker) {<br>        EasyImage.<em>handleActivityResult</em>(<em>requestCode</em>, <em>resultCode</em>, <em>data</em>, this, new DefaultCallback() {<br>            @Override<br>            public void onImagePickerError(Exception <em>e</em>, EasyImage.ImageSource <em>source</em>, int <em>type</em>) {<br>                photoPicker = false;<br>                //Some error handling<br>            }<br><br>            @Override<br>            public void onImagesPicked(List&lt;File&gt; <em>imagesFiles</em>, EasyImage.ImageSource <em>source</em>, int <em>type</em>) {<br>                //Handle the images<br>                photoPicker = false;<br>                onPhotosReturned(<em>imagesFiles</em>);<br>            }<br>        });<br>    }<br>}</pre><p>Now we must set up SnapCreativeKitAPI. Inside onCreate() again:</p><pre>snapCreativeKitApi = SnapCreative.<em>getApi</em>(this);</pre><p>Then we create the onPhotosReturned(List&lt;File&gt; imageFiles) method. Note that the SnapCreativeKitAPI creates SnapPhotoFiles from File objects.</p><pre>private void onPhotosReturned(List&lt;File&gt; <em>imageFiles</em>) {<br>    Log.<em>d</em>(&quot;photo Returned&quot;, &quot;Photo returned&quot;);<br>    SnapMediaFactory <em>snapMediaFactory </em>= SnapCreative.<em>getMediaFactory</em>(this);<br>    if(<em>imageFiles</em>.size() == 1) {<br>        SnapPhotoFile <em>photoFile</em>;<br>        try {<br>            <em>photoFile </em>= <em>snapMediaFactory</em>.getSnapPhotoFromFile(<em>imageFiles</em>.get(0));<br>        } catch (SnapMediaSizeException <em>e</em>) {<br>            <em>e</em>.printStackTrace();<br>            return;<br>        }<br>        SnapPhotoContent <em>snapPhotoContent </em>= new SnapPhotoContent(<em>photoFile</em>);<br>        <em>snapPhotoContent</em>.setCaptionText(&quot;Sent from My Android App&quot;);<br>        <em>snapPhotoContent</em>.setAttachmentUrl(&quot;www.google.com&quot;);<br><br>        snapCreativeKitApi.send(<em>snapPhotoContent</em>);<br>        Log.<em>d</em>(&quot;Snapchat&quot;, &quot;Photo sent to snapchat&quot;);<br>    }<br>}</pre><p>Let’s break it down bit by bit.</p><pre>SnapMediaFactory <em>snapMediaFactory </em>= SnapCreative.<em>getMediaFactory</em>(this);</pre><p>Here we create our SnapMediaFactory which we use to create the SnapPhotoFile from the File image we get from the gallery picker.</p><pre>SnapPhotoFile <em>photoFile</em>;<br>        try {<br>            <em>photoFile </em>= <em>snapMediaFactory</em>.getSnapPhotoFromFile(<em>imageFiles</em>.get(0));<br>        } catch (SnapMediaSizeException <em>e</em>) {<br>            <em>e</em>.printStackTrace();<br>            return;<br>        }<br>        SnapPhotoContent <em>snapPhotoContent </em>= new SnapPhotoContent(<em>photoFile</em>);</pre><p>We need to put the getSnapPhotoFromFile() inside of a try-catch in order to prevent SnapMediaSizeExceptions being thrown. We then create a SnapPhotoContent to store the photo file and the content that will go with the photo (Sticker, caption and attachment urls).</p><pre><em>snapPhotoContent</em>.setCaptionText(&quot;Sent from My Android App&quot;);<br><em>snapPhotoContent</em>.setAttachmentUrl(&quot;www.google.com&quot;);<br><br>snapCreativeKitApi.send(<em>snapPhotoContent</em>);</pre><p>Finally we tell the snapCreativeKitApi to send the snapPhotoContent.</p><p>There you have it! You have integrated a fairly simple SnapPhoto sender using the SnapChat Creative Kit!</p><p>Full source code available <a href="https://github.com/HarrisonOg/SnapKitTestApp">here</a>. Feel free to reach out if you have any issues.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=27c34378607" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>