放在什么地方parse.initialize() [英] Where to place the parse.initialize()

查看:124
本文介绍了放在什么地方parse.initialize()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在建设有一个小团队在两个iOS和Android应用程序,但现在我只能在Android集中。在其网站上的教程,他们说以下行相当早。

I'm currently building an app with a small team on both iOS and Android, though right now I'm only focussing on Android. On their website tutorial they say the following line fairly early.

在继续之前,从右侧的菜单中选择您解析应用程序。这些步骤是你的NameAppHere应用程序。

Before continuing, select your Parse app from the menu at the right. These steps are for your "NameAppHere" app.

从你的应用程序类的onCreate方法调用Parse.initialize设置你的应用程序ID和客户端密钥:

Call Parse.initialize from the onCreate method of your Application class to set your application id and client key:

public void onCreate() {
  Parse.initialize(this, "XXXXXX", "XXXXXX");
}

他们说我必须粘贴code的该位在应用程序类的onCreate方法,虽然没有了应用程序类或Application.java。我已经通过菜单选项的Andr​​oid工作室给了我一个模仿别人的.jar文件到项目结构。我本演练,我已经有一个现有的项目之前指定的,所以我不认为这是问题。

They say I have to paste that bit of code in the onCreate method of the Application class, though there isn't an 'Application' class or Application.java. I already copied their .jar file into the project structure through one of the menu options Android studio gives me. I specified before this walkthrough that I already have an existing project, so I don't think that's the problem.

对不起,问一个有点nooby问题,但是这是一个团体项目,所以我也不想干的事情了。

Sorry for asking a bit of a nooby question, but this is a group project, so I don't want to fuck things up.

推荐答案

您必须通过创建一个扩展应用程序中的类来创建自己的自定义应用程序类,然后覆盖的onCreate(就像你在任何活动),并将该行

You have to create your own custom Application class by creating a class that extends Application and then override onCreate (just like you would any activity) and place that line in.

public class MyApplication extends Application {
    public void onCreate() {
        Parse.initialize(this, "XXXXXX", "XXXXXX");
    }
}

您也必须告诉您正在使用的是定制的应用程序类的清单。你可以做到这一点,在你的Andr​​oidManifest.xml文件,你将不得不名称元素设置你的位置,新的应用程序类:

You also have to tell the manifest that you are using a custome application class. You can do this by, in your AndroidManifest.xml file, you will have to set the name element to the location of you new Application class:

<application
        android:name="com.packageName.example.MyApplication"
        android:label="@string/app_name"
        android:logo="@drawable/ic_launcher_no_text" >

这篇关于放在什么地方parse.initialize()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆