Right now I am using a static boolean to tell when the initialization has occurred. Is there an easier way to know that I have already called initialize?
Thank you!!!
SOLVED!!!! Thank you so much for your comments. You need to initialize parse in a class that extends an application, and then add it to the manifest file as an application (not an other activity).
:)
This is my class to use Parse:
package com.example.myapp;
import com.parse.Parse;
import android.app.Application;
public class UseParse extends Application {
@Override
public void onCreate() {
super.onCreate();
Parse.initialize(this, "id", "key");
}
}
This is my android manifest file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapp"
android:versionCode="1"
android:versionName="1.0"
>
<uses-sdk android:minSdkVersion="11"
android:targetSdkVersion="14"/>
<supports-screens
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"
android:anyDensity="true"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.CALL_PHONE" android:required="false" />
<permission android:protectionLevel="signature"
android:name="com.example.myapp.permission.C2D_MESSAGE" />
<uses-permission android:name="com.example.myapp.permission.C2D_MESSAGE" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:screenOrientation="portrait"
android:label="@string/app_name"
android:name ="com.example.myapp.UseParse"
android:theme="@style/AppTheme" >
<activity
android:screenOrientation="portrait"
android:name="com.example.myapp.SplashActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="@string/app_name"
android:theme="@style/FullscreenTheme" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".LoginActivity" />
//... more
<service android:name="com.parse.PushService" />
<receiver android:name="com.parse.ParseBroadcastReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.USER_PRESENT" />
</intent-filter>
</receiver>
<receiver android:name="com.parse.GcmBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.example.myapp" />
</intent-filter>
</receiver>
</application>
</manifest>
Make a Application Class and in onCreate initialize parse.
public class YourApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
Parse.initialize(this, "id","key");
}
}
After this it wont be called again and again.
Also declare it in your manifest
<application
android:name="com.you.yourapp.YourApplication "
EDIT: This is the only place where you initialize it. And not in the Login Activity or anywhere else.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With