-
Notifications
You must be signed in to change notification settings - Fork 298
feat: android tutorial #190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
05e7ac4
feat: android tutorial
loks0n 27af8fd
fix: missing groovy highlighting
loks0n 94f6354
feat: add groovy highlighting
loks0n 3d2ba86
chore: vincent review fixes
loks0n e490e85
fix: svelte -> android
loks0n 366725b
Fix style and typos
f7adebd
chore: vincent feedback
loks0n 0a60351
Merge branch 'main' of https://github.com/appwrite/website into feat-…
loks0n f7832de
chore: review feedback
loks0n 6e9a41f
feat: error handling
loks0n de383d2
Merge branch 'main' into feat-android-tutorial
dd357ef
Fix more merge isues
6e32958
Updated Android tutorial, confirmed it works heehee
4741bb3
Merge branch 'feat-nuxt-tutorial' into feat-android-tutorial
bc653c5
Fix mistake in merge with main
2231e89
Apply suggestions from code review
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,18 +1,24 @@ | ||
| --- | ||
| layout: tutorial | ||
| title: Coming soon | ||
| title: Build an ideas tracker with Android | ||
| description: Learn to build an Android app with no backend code using an Appwrite backend. | ||
| framework: Android | ||
| category: Mobile and native | ||
| step: 1 | ||
| draft: true | ||
| --- | ||
|
|
||
| Improve the docs, add this guide. | ||
| **Idea tracker**: an app to track all the side project ideas that you'll start, but probably never finish. | ||
| In this tutorial, you will build Idea tracker with Appwrite and Android. | ||
|
|
||
| We still don't have this guide in place, but we do have some great news. | ||
| The Appwrite docs, just like Appwrite, is completely open sourced. | ||
| This means, anyone can help improve them and add new guides and tutorials. | ||
| # Concepts {% #concepts %} | ||
| This tutorial will introduce the following concepts: | ||
|
|
||
| If you see this page, **we're actively looking for contributions to this page**. | ||
| Follow our contribution guidelines, open a PR to [our Website repo](https://github.com/appwrite/website), and collaborate with our core team to improve this page. | ||
| 1. Setting up your first project | ||
| 2. Authentication | ||
| 3. Databases and collections | ||
| 4. Queries and pagination | ||
| 5. Storage | ||
|
|
||
| # Prerequisites {% #prerequisites %} | ||
| 1. Basic knowledge of Kotlin and Android development. | ||
| 2. Have [Android Studio](https://developer.android.com/studio) installed on your computer. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| --- | ||
| layout: tutorial | ||
| title: Create app | ||
| description: Create a Android app project using Appwrite. | ||
| step: 2 | ||
| --- | ||
|
|
||
| # Create Android project {% #create-android-project %} | ||
|
|
||
| Create a Android app with the Android Studio **New Project** wizard. Select **Empty Activity** as the template. | ||
|
|
||
| # Add dependencies {% #add-dependencies %} | ||
|
|
||
| Install the Android Appwrite SDK. | ||
|
|
||
| Add the following to your dependencies in the `app/build.gradle` file: | ||
|
|
||
| ```groovy | ||
| implementation("io.appwrite:sdk-for-android:4.0.1") | ||
| ``` | ||
|
|
||
| In case you need to create OAuth 2 sessions in the future, the following activity needs to be added inside the `<application>` tag, along side the existing `<activity>` tags in your [AndroidManifest.xml](https://developer.android.com/guide/topics/manifest/manifest-intro). | ||
| Be sure to replace the **<PROJECT_ID>** string with your actual Appwrite project ID. | ||
| You can find your Appwrite project ID in you project settings screen in your Appwrite Console. | ||
|
|
||
| ```xml | ||
| <manifest ...> | ||
| ... | ||
| <application ...> | ||
| ... | ||
| <!-- Add this inside the `<application>` tag, along side the existing `<activity>` tags --> | ||
| <activity android:name="io.appwrite.views.CallbackActivity" android:exported="true"> | ||
| <intent-filter android:label="android_web_auth"> | ||
| <action android:name="android.intent.action.VIEW" /> | ||
| <category android:name="android.intent.category.DEFAULT" /> | ||
| <category android:name="android.intent.category.BROWSABLE" /> | ||
| <data android:scheme="appwrite-callback-[PROJECT_ID]" /> | ||
| </intent-filter> | ||
| </activity> | ||
| </application> | ||
| </manifest> | ||
| ``` | ||
|
|
||
| # Using the emulator {% #using-the-emulator %} | ||
|
|
||
| Run your app on the [Android emulator](https://developer.android.com/studio/run/emulator). | ||
| You can use the emulator to test your app on different versions of the Android platform and different screen sizes without the need to use physical devices. | ||
| For now, you should see a blank screen. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| --- | ||
| layout: tutorial | ||
| title: Set up Appwrite | ||
| description: Initialize Appwrite in your Android project. | ||
| step: 3 | ||
| --- | ||
|
|
||
| # Create project {% #create-project %} | ||
|
|
||
| Head to the [Appwrite Console](https://cloud.appwrite.io/console). | ||
|
|
||
| {% only_dark %} | ||
|  | ||
| {% /only_dark %} | ||
| {% only_light %} | ||
|  | ||
| {% /only_light %} | ||
|
|
||
| If this is your first time using Appwrite, create an account and create your first project. | ||
|
|
||
| Then, under **Add a platform**, add an **Android app**. The **Package Name** should be the same as the one you used when creating your app. | ||
|
|
||
| {% only_dark %} | ||
|  | ||
| {% /only_dark %} | ||
| {% only_light %} | ||
|  | ||
| {% /only_light %} | ||
|
|
||
| You can skip optional steps. | ||
|
|
||
| # Initialize Appwrite SDK {% #init-sdk %} | ||
|
|
||
| To use Appwrite in our Android app, we'll need to find our project ID. Find your project's ID in the **Settings** page. | ||
|
|
||
| {% only_dark %} | ||
|  | ||
| {% /only_dark %} | ||
| {% only_light %} | ||
|  | ||
| {% /only_light %} | ||
|
|
||
| Create a new file `services/Appwrite.kt` to hold our Appwrite related code. | ||
| Only one instance of the `Client` class should be created per app. | ||
| Add the following code to it, replacing `<YOUR_PROJECT_ID>` with your project ID. | ||
|
|
||
| ```kotlin | ||
| package <YOUR_ROOT_PACKAGE_HERE>.services | ||
|
|
||
| import android.content.Context | ||
| import io.appwrite.Client | ||
|
|
||
| object Appwrite { | ||
| private const val ENDPOINT = "https://cloud.appwrite.io/v1" | ||
| private const val PROJECT_ID = "<YOUR_PROJECT_ID>" | ||
|
|
||
| private lateinit var client: Client | ||
|
|
||
| fun init(context: Context) { | ||
| client = Client(context) | ||
| .setEndpoint(ENDPOINT) | ||
| .setProject(PROJECT_ID) | ||
| } | ||
| } | ||
| ``` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.