Reputation: 9072
Example:
try {
// some code
} catch (Throwable t) {
t.printStackTrace();
}
For example, need to catch errors as follows, and any others
01-21 02:52:49.665: W/System.err(20407): java.lang.RuntimeException: You must call Parse.initialize(context, oauthKey, oauthSecret) before using the Parse library.
01-21 02:52:49.670: W/System.err(20407): at com.parse.ParseUser.checkApplicationContext(ParseUser.java:1196)
01-21 02:52:49.670: W/System.err(20407): at com.parse.ParseUser.getCurrentUser(ParseUser.java:970)
01-21 02:52:49.670: W/System.err(20407): at com.parse.ParseUser.getCurrentSessionToken(ParseUser.java:1041)
01-21 02:52:49.670: W/System.err(20407): at com.parse.ParsePush.sendInBackground(ParsePush.java:365)
Upvotes: 0
Views: 70
Reputation: 3468
This exception is straight forward and doesn't really need to be caught, the solution to the problem can be found here or below.
First extend Application with your own class.
import com.parse.Parse;
import android.app.Application;
public class App extends Application {
@Override
public void onCreate() {
super.onCreate();
Parse.initialize(this, PARSE_APPLICATION_ID, PARSE_CLIENT_KEY);
}
}
Make sure to declare it in the manifest as well
<application
android:name="yourpackagename.App"
.
.
.
</application>
Upvotes: 2