### Initializing Parse Twitter Utils in Android Application Source: https://github.com/parse-community/parse-sdk-android/blob/master/twitter/README.md This Java snippet demonstrates how to initialize the Parse Twitter Utils with your Twitter consumer key and secret. This setup is typically performed once during the application's startup, for example, within the `Application.onCreate()` method. ```Java // in Application.onCreate(); or somewhere similar ParseTwitterUtils.initialize("YOUR CONSUMER KEY", "YOUR CONSUMER SECRET"); ``` -------------------------------- ### Adding Jitpack Repository to root build.gradle (Older Android Studio) Source: https://github.com/parse-community/parse-sdk-android/blob/master/README.md This Gradle snippet configures the Jitpack Maven repository within the `allprojects` block of the root `build.gradle` file. This setup is specifically for older Android Studio versions (e.g., Arctic Fox | 2020.3.1 or older) to ensure the Parse Android SDK dependencies can be resolved. ```gradle allprojects { repositories { ... maven { url "https://jitpack.io" } } } ``` -------------------------------- ### Registering Custom Application Class in AndroidManifest.xml Source: https://github.com/parse-community/parse-sdk-android/blob/master/README.md This XML snippet shows how to register a custom `Application` class (e.g., `.App`) in the `AndroidManifest.xml` file by setting the `android:name` attribute within the `` tag. This registration ensures that the custom `Application` class, where Parse is initialized, is instantiated when the application process starts. ```xml ... ``` -------------------------------- ### Signing Up ParseUser - Kotlin Source: https://github.com/parse-community/parse-sdk-android/blob/master/coroutines/README.md Provides an example of registering a new Parse user asynchronously using `suspendSignUp()` within a coroutine. It demonstrates setting user properties like username, password, and email before initiating the sign-up process. ```Kotlin launch { // Coroutine builder user = ParseUser().apply { setUsername("my name") setPassword("my pass") setEmail("email@example.com") }.also { suspendSignUp() } } ``` -------------------------------- ### Initializing Parse SDK in Android Application Class (Java) Source: https://github.com/parse-community/parse-sdk-android/blob/master/README.md This Java code demonstrates how to initialize the Parse SDK within a custom `Application` class. The `onCreate` method is overridden to call `Parse.initialize` with a `Parse.Configuration.Builder`, requiring `applicationId`, `clientKey` (optional), and `server` address to connect the Android app to a Parse Server instance. ```java import com.parse.Parse; import android.app.Application; public class App extends Application { @Override public void onCreate() { super.onCreate(); Parse.initialize(new Parse.Configuration.Builder(this) .applicationId("YOUR_APP_ID") // if desired .clientKey("YOUR_CLIENT_KEY") .server("https://your-server-address/parse/") .build() ); } } ``` -------------------------------- ### Adding Parse Android SDK and Optional Modules to Module build.gradle Source: https://github.com/parse-community/parse-sdk-android/blob/master/README.md This Gradle snippet defines the Parse Android SDK version and includes the core SDK along with various optional modules (Google, Facebook, Twitter, FCM, Kotlin extensions, Coroutines, RxJava) as `implementation` dependencies in the module-level `build.gradle` file. Users should replace `latest.version.here` with the desired SDK version to integrate Parse functionalities and its extensions into their Android application. ```gradle ext { parseVersion = "latest.version.here" } dependencies { implementation "com.github.parse-community.Parse-SDK-Android:parse:$parseVersion" // for Google login/signup support (optional) implementation "com.github.parse-community.Parse-SDK-Android:google:$parseVersion" // for Facebook login/signup support (optional) implementation "com.github.parse-community.Parse-SDK-Android:facebook:$parseVersion" // for Twitter login/signup support (optional) implementation "com.github.parse-community.Parse-SDK-Android:twitter:$parseVersion" // for FCM Push support (optional) implementation "com.github.parse-community.Parse-SDK-Android:fcm:$parseVersion" // for Kotlin extensions support (optional) implementation "com.github.parse-community.Parse-SDK-Android:ktx:$parseVersion" // for Kotlin coroutines support (optional) implementation "com.github.parse-community.Parse-SDK-Android:coroutines:$parseVersion" // for RxJava support (optional) implementation "com.github.parse-community.Parse-SDK-Android:rxjava:$parseVersion" } ``` -------------------------------- ### Adding Jitpack Repository to settings.gradle (Modern Android Studio) Source: https://github.com/parse-community/parse-sdk-android/blob/master/README.md This Gradle snippet adds the Jitpack Maven repository to the `dependencyResolutionManagement` block in the `settings.gradle` file. This is required for Android Studio versions that use the new Gradle plugin architecture, enabling the resolution of Parse Android SDK dependencies hosted on Jitpack. ```gradle dependencyResolutionManagement { repositories { maven { url 'https://www.jitpack.io' } } } ``` -------------------------------- ### Executing ParseQuery with launchQuery() - Kotlin Source: https://github.com/parse-community/parse-sdk-android/blob/master/coroutines/README.md Illustrates using the `launchQuery()` function as a coroutine builder to execute Parse query operations. This provides a flexible and concise way to perform find, get, first, and count operations on a ParseQuery object within a coroutine context. ```Kotlin launchQuery(query) { // doing operations like find, get, first and count } ``` -------------------------------- ### Logging In with Parse and RxJava Single (Kotlin) Source: https://github.com/parse-community/parse-sdk-android/blob/master/rxjava/README.md This Kotlin example shows how to use RxJava with Parse Android to handle asynchronous login operations. It converts a `ParseTwitterUtils.logInInBackground` Task into an RxJava `Single`, subscribes on an I/O scheduler, observes on the main thread, and handles success and error outcomes for user login. ```kotlin ParseTwitterUtils.logInInBackground(this) .toSingle() .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe({ Timber.d("Logged in with user ${it.objectId}" }, { Timber.e(it) }) ``` -------------------------------- ### Converting Parse Task to RxJava Completable (Java) Source: https://github.com/parse-community/parse-sdk-android/blob/master/rxjava/README.md This Java example demonstrates how to explicitly convert a Parse `Task` (such as from `user.saveInBackground()`) into an RxJava `Completable` using `ParseRxJavaUtils.toCompletable`. This is useful when integrating Parse asynchronous operations into existing Java RxJava flows. ```java ParseUser user = ParseUser.getCurrentUser(); Completable completable = ParseRxJavaUtils.toCompletable(user.saveInBackground()); ``` -------------------------------- ### Logging In/Signing Up with Google (Java) Source: https://github.com/parse-community/parse-sdk-android/blob/master/google/README.md This Java snippet demonstrates how to initiate a Google login or signup process using ParseGoogleUtils.logInWithReadPermissionsInBackground. It takes the current activity context, requested permissions, and a LogInCallback to handle the asynchronous result, indicating whether the user cancelled, signed up, or logged in successfully. ```java ParseGoogleUtils.logInWithReadPermissionsInBackground(this, permissions, new LogInCallback() { @Override public void done(ParseUser user, ParseException err) { if (user == null) { Log.d("MyApp", "Uh oh. The user cancelled the Google login."); } else if (user.isNew()) { Log.d("MyApp", "User signed up and logged in through Google!"); } else { Log.d("MyApp", "User logged in through Google!"); } } }); ``` -------------------------------- ### Initializing Parse Google Utils (Java) Source: https://github.com/parse-community/parse-sdk-android/blob/master/google/README.md This Java snippet shows how to initialize the Parse Google Utils library, typically within the Application.onCreate() method. It requires a web configured OAuth 2.0 API client ID, which can be retrieved from resources or directly provided, to set up Google authentication. ```java // in Application.onCreate(); or somewhere similar ParseGoogleUtils.initialize(getString(R.string.default_web_client_id)); ``` -------------------------------- ### Linting Code with Gradle Spotless - Shell Source: https://github.com/parse-community/parse-sdk-android/blob/master/CONTRIBUTING.md This command applies code formatting and linting rules defined by the Spotless plugin to ensure code style consistency across the Parse Android SDK project. It helps maintain a clean and readable codebase by automatically fixing formatting issues. ```Shell ./gradlew spotlessApply ``` -------------------------------- ### Initializing Parse Facebook Utils in Android Application Source: https://github.com/parse-community/parse-sdk-android/blob/master/facebook/README.md This code initializes the Parse Facebook Utils library. It should be called early in your application's lifecycle, typically within the Application.onCreate() method, to set up the necessary Facebook SDK components for Parse integration. ```Java // in Application.onCreate(); or somewhere similar ParseFacebookUtils.initialize(context); ``` -------------------------------- ### Adding Parse Google Utils Dependency (Gradle) Source: https://github.com/parse-community/parse-sdk-android/blob/master/google/README.md This snippet demonstrates how to add the Parse Google Utils library as a dependency in an Android project's build.gradle file using JitPack. It specifies the implementation configuration for the google module of the Parse Android SDK. ```gradle dependencies { implementation "com.github.parse-community.Parse-SDK-Android:google:latest.version.here" } ``` -------------------------------- ### Logging In ParseUser with Twitter in Android Source: https://github.com/parse-community/parse-sdk-android/blob/master/twitter/README.md This Java code illustrates how to initiate a Twitter login process for a ParseUser using `ParseTwitterUtils.logIn`. It includes a `LogInCallback` to handle different outcomes such as user cancellation, a new user signing up, or an existing user logging in. ```Java ParseTwitterUtils.logIn(this, new LogInCallback() { @Override public void done(ParseUser user, ParseException err) { if (user == null) { Log.d("MyApp", "Uh oh. The user cancelled the Twitter login."); } else if (user.isNew()) { Log.d("MyApp", "User signed up and logged in through Twitter!"); } else { Log.d("MyApp", "User logged in through Twitter!"); } } }); ``` -------------------------------- ### Adding Parse SDK Android KTX Dependency - Gradle Source: https://github.com/parse-community/parse-sdk-android/blob/master/ktx/README.md This snippet shows how to add the Parse SDK Android KTX module as a dependency in a Gradle build file. It requires JitPack to be included in the project's repositories. Replace 'latest.version.here' with the actual latest version. ```Gradle dependencies { implementation "com.github.parse-community.Parse-SDK-Android:ktx:latest.version.here" } ``` -------------------------------- ### Adding RxJava Dependency for Parse Android (Gradle) Source: https://github.com/parse-community/parse-sdk-android/blob/master/rxjava/README.md This snippet demonstrates how to add the RxJava 3 support library for Parse Android as a dependency in a Gradle build file. It specifies the `rxjava` module from the `parse-community.Parse-SDK-Android` repository, requiring JitPack to be included in the project's repositories. ```gradle dependencies { implementation "com.github.parse-community.Parse-SDK-Android:rxjava:latest.version.here" } ``` -------------------------------- ### Logging In ParseUser - Kotlin Source: https://github.com/parse-community/parse-sdk-android/blob/master/coroutines/README.md Demonstrates how to log in an existing Parse user using `parseLogIn()` within a coroutine. This simplifies the authentication process by providing a suspendable function for user login. ```Kotlin launch { // Coroutine builder val user = parseLogIn("username", "password") } ``` -------------------------------- ### Executing ParseQuery with suspendFind() - Kotlin Source: https://github.com/parse-community/parse-sdk-android/blob/master/coroutines/README.md Demonstrates how to perform a Parse query using the `suspendFind()` extension function within a Kotlin coroutine. This enables synchronous-style data retrieval, eliminating the need for traditional callbacks and simplifying asynchronous code flow. ```Kotlin launch { // Coroutine builder val cat = ParseQuery.getQuery(...).suspendFind() // get cats without callback } ``` -------------------------------- ### Adding Parse Twitter Utils Dependency to Gradle Source: https://github.com/parse-community/parse-sdk-android/blob/master/twitter/README.md This snippet shows how to add the Parse Twitter Utils library as a dependency in your Android project's `build.gradle` file, assuming JitPack is already included in your project's repositories. ```Gradle dependencies { implementation "com.github.parse-community.Parse-SDK-Android:twitter:latest.version.here" } ``` -------------------------------- ### Using ParseQuery Extensions with Property Delegates - Kotlin Source: https://github.com/parse-community/parse-sdk-android/blob/master/ktx/README.md This Kotlin snippet demonstrates how to use ParseQuery extensions with property delegates for more secure and refactor-friendly queries. It shows querying a 'Cat' object by its 'name' property using a type-safe reference ('Cat::name') instead of hardcoded string keys, which allows IDE refactoring tools to update queries automatically. ```Kotlin @ParseClassName("Cat") class Cat : ParseObject() { var age by intAttribute() } val query = ParseQuery.getQuery(Cat::class.java) // Use this syntax query.whereEqualTo(Cat::name, 1) // instead of query.whereEqualTo("age", 1) // or query.whereEqualTo(Cat::age.name, 1) ``` -------------------------------- ### Adding Parse Coroutines Dependency - Gradle Source: https://github.com/parse-community/parse-sdk-android/blob/master/coroutines/README.md This snippet shows how to include the Parse SDK Android Coroutines module in a Gradle project's dependencies, allowing access to coroutine-based Parse operations. Ensure JitPack is configured in your project's repositories. ```Gradle dependencies { implementation "com.github.parse-community.Parse-SDK-Android:coroutines:latest.version.here" } ``` -------------------------------- ### Handling Google Login Activity Result (Java) Source: https://github.com/parse-community/parse-sdk-android/blob/master/google/README.md This Java snippet illustrates how to properly handle the activity result for Google login within an Android Activity. It ensures that ParseGoogleUtils processes the result, which is crucial for completing the authentication flow after a user interacts with the Google sign-in prompt. ```java @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); ParseGoogleUtils.onActivityResult(requestCode, resultCode, data); } ``` -------------------------------- ### ParseObject Subclass Definition With Property Delegation - Kotlin Source: https://github.com/parse-community/parse-sdk-android/blob/master/ktx/README.md This Kotlin snippet demonstrates how to define a 'Cat' ParseObject subclass using property delegation provided by the KTX module. It significantly reduces boilerplate by using delegates like 'stringAttribute()' and 'intAttribute()' for properties, automatically handling the get/put logic for Parse object fields. ```Kotlin @ParseClassName("Cat") class Cat : ParseObject() { var name: String by stringAttribute() // That's it var legs: Int by intAttribute("cat-legs") } ``` -------------------------------- ### Performing Anonymous Login with Task Wrapper - Kotlin Source: https://github.com/parse-community/parse-sdk-android/blob/master/coroutines/README.md Shows how to perform an anonymous Parse login using `ParseAnonymousUtils.logInInBackground().suspendGet()`. This wraps a traditional Parse `Task` into a suspend function, making it compatible with coroutines and simplifying error handling. ```Kotlin suspend fun anonymousLogin() { try { val user = ParseAnonymousUtils.logInInBackground().suspendGet() Timber.d("Logged in with user ${user.objectId}") } catch (e: ParseException) { Timber.e(e) } } ``` -------------------------------- ### ParseObject Subclass Definition Without Property Delegation - Kotlin Source: https://github.com/parse-community/parse-sdk-android/blob/master/ktx/README.md This snippet illustrates defining a 'Cat' ParseObject subclass in Kotlin without using property delegation. It shows the boilerplate required for manually implementing a property's getter and setter using 'getString' and 'put' methods, similar to traditional Java approaches. ```Kotlin @ParseClassName("Cat") class Cat : ParseObject() { companion object { const val KEY_NAME = "name" } var name: String get() = getString(KEY_NAME) set(value) = put(KEY_NAME, value) } ``` -------------------------------- ### Adding Parse Facebook Utils Dependency in Gradle Source: https://github.com/parse-community/parse-sdk-android/blob/master/facebook/README.md This snippet shows how to add the Parse Facebook Utils library as a dependency in your Android project's build.gradle file. It specifies the 'facebook' module from the Parse-SDK-Android repository, allowing your application to use its functionalities. ```Gradle dependencies { implementation "com.github.parse-community.Parse-SDK-Android:facebook:latest.version.here" } ``` -------------------------------- ### Saving Parse User Data with RxJava Completable (Kotlin) Source: https://github.com/parse-community/parse-sdk-android/blob/master/rxjava/README.md This Kotlin snippet illustrates how to save Parse user data asynchronously using RxJava. It takes a `Task` (from `user.saveInBackground()`) and converts it into an RxJava `Completable`, subscribing on a background thread and observing on the main thread to handle the completion or error of the save operation. ```kotlin val user = ParseUser.getCurrentUser() user.put("lastLoggedIn", System.currentTimeMillis()) user.saveInBackground().toCompletable() .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe({ // yay Timber.d("user saved") }, { Timber.e(it) }) ``` -------------------------------- ### Logging In Parse User with Facebook Read Permissions Source: https://github.com/parse-community/parse-sdk-android/blob/master/facebook/README.md This code initiates the Facebook login process for a Parse user, requesting specified read permissions. It includes a LogInCallback to handle the authentication result, checking if the user cancelled, is new, or successfully logged in, and logs the outcome. ```Java ParseFacebookUtils.logInWithReadPermissionsInBackground(this, permissions, new LogInCallback() { @Override public void done(ParseUser user, ParseException err) { if (user == null) { Log.d("MyApp", "Uh oh. The user cancelled the Facebook login."); } else if (user.isNew()) { Log.d("MyApp", "User signed up and logged in through Facebook!"); } else { Log.d("MyApp", "User logged in through Facebook!"); } } }); ``` -------------------------------- ### Defining ParseObject Subclass with Manual Getters/Setters - Kotlin Source: https://github.com/parse-community/parse-sdk-android/blob/master/ktx/README.md This Kotlin snippet defines a 'Cat' class that extends 'ParseObject', demonstrating how to manually implement getters and setters for properties like 'name' and 'age'. It uses 'getString', 'getInt', 'putOrIgnore', and 'putOrRemove' methods to interact with Parse object data. This class needs to be registered with 'ParseObject.registerSubclass(Cat::class.java)'. ```Kotlin /** * A cat, ParseObject subclass. Register with ParseObject.registerSubclass(Cat::class.java) */ @ParseClassName(Cat.NAME) class Cat : ParseObject() { companion object { const val NAME = "Cat" const val KEY_NAME = "name" const val KEY_AGE = "age" } var name: String? get() = getString(KEY_NAME) set(value) = putOrIgnore(KEY_NAME, value) var age: Int? get() = getInt(KEY_AGE) set(value) = putOrRemove(KEY_AGE, value) } ``` -------------------------------- ### Handling Facebook Login Activity Result in Android Source: https://github.com/parse-community/parse-sdk-android/blob/master/facebook/README.md This snippet demonstrates how to properly handle the activity result for Facebook login within your Android Activity. It ensures that the ParseFacebookUtils library processes the result from the Facebook SDK, which is crucial for completing the authentication flow. ```Java @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); ParseFacebookUtils.onActivityResult(requestCode, resultCode, data); } ``` -------------------------------- ### Updating ParseUser Last Login with Task Wrapper - Kotlin Source: https://github.com/parse-community/parse-sdk-android/blob/master/coroutines/README.md Illustrates saving a Parse object (user) asynchronously using `saveInBackground().suspendRun()`. This converts a `Task` into a `Completable` for coroutine-friendly execution, allowing for clean updates and error handling. ```Kotlin suspend fun updateUserLastLogIn() { val user = ParseUser.getCurrentUser() user.put("lastLoggedIn", System.currentTimeMillis()) try { user.saveInBackground().suspendRun() Timber.d("user saved") } catch (e: ParseException) { Timber.e(it) } } ``` -------------------------------- ### Calling Parse Cloud Function - Kotlin Source: https://github.com/parse-community/parse-sdk-android/blob/master/coroutines/README.md Shows how to invoke a Parse Cloud Function inline using `callCloudFunction()` within a coroutine. This allows for direct execution of server-side logic and immediate retrieval of results without complex callback structures. ```Kotlin launch { // Coroutine builder val catThumb = callCloudFunction("getThumbnail", mapOf("url" to "https://cat.jpg")) // get cats without callback } ``` -------------------------------- ### Adding FCM Dependency to Parse Android Project (Gradle) Source: https://github.com/parse-community/parse-sdk-android/blob/master/fcm/README.md This Gradle dependency adds the Parse FCM module to an Android project, enabling Firebase Cloud Messaging features. It should be placed within the 'dependencies' block of the 'build.gradle' file after including JitPack. ```gradle dependencies { implementation "com.github.parse-community.Parse-SDK-Android:fcm:latest.version.here" } ``` -------------------------------- ### Enabling Debug Logging for Parse SDK (Java) Source: https://github.com/parse-community/parse-sdk-android/blob/master/fcm/README.md This Java code snippet sets the Parse SDK's log level to DEBUG, which is useful for development and troubleshooting FCM registration success messages. It is recommended to disable this logging in release builds to prevent sensitive information exposure and performance overhead. ```java // be sure to disable this in the release apk Parse.setLogLevel(Parse.LOG_LEVEL_DEBUG); ``` -------------------------------- ### Registering Parse FCM Messaging Service in Android Manifest (XML) Source: https://github.com/parse-community/parse-sdk-android/blob/master/fcm/README.md This XML snippet registers the ParseFirebaseMessagingService in the Android Manifest, allowing the Parse SDK to handle Firebase Cloud Messaging events. It is crucial for receiving push notifications via FCM. ```xml ``` -------------------------------- ### Registering Parse Push Broadcast Receiver in Android Manifest (XML) Source: https://github.com/parse-community/parse-sdk-android/blob/master/fcm/README.md This XML configuration registers the ParsePushBroadcastReceiver in the Android Manifest, enabling the Parse SDK to process various push notification intents such as receiving, deleting, and opening notifications. The android:exported="false" attribute ensures the receiver is not accessible by other applications. ```xml ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.