[英]creating app using parse.com lib.when i close app n reopen it ,it says unfortunately stopped
I have created activities such as splash screen, login page, register page and homepage, but when I close my app and try to reopen, it shows error unfortunately stopped . 我已经创建了活动,例如初始屏幕,登录页面,注册页面和主页,但是当我关闭我的应用程序并尝试重新打开时, 不幸地显示了错误停止 。
Below is my splash screen activity code: 以下是我的启动画面活动代码:
import android.app.Activity;
import android.content.Intent;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import com.parse.Parse;
import com.parse.ParseUser;
public class Splash extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
Parse.enableLocalDatastore(this);
Parse.initialize(this, "app. id.(i can't show this privacy purpose :))",
"Clint key(same here for privecy i will not show) ");
Thread timer=new Thread(){
public void run(){
try{
sleep(5000);
}catch (Exception e){
e.printStackTrace();
}finally {
ParseUser currentUser = ParseUser.getCurrentUser();
if (currentUser != null) {
// do stuff with the user
Intent taketohome=new Intent(Splash.this,HomepageActivity.class);
startActivity(taketohome);
} else {
// show the signup or login screen
Intent taketologinpage=new Intent(Splash.this, LoginActivity.class);
startActivity(taketologinpage);
}
}
}
};timer.start();
}
@Override
protected void onPause() {
super.onPause();
finish();
}
}
Actually this is happening because you are doing Parse.intailize in onCreate method of activity. 实际上发生这种情况是因为您正在活动的onCreate方法中执行Parse.intailize。 Instead you can make an application class and intialize Parse there.
相反,您可以创建一个应用程序类并在那里初始化Parse。 Hope it explains well
希望它能很好地解释
Caused by: java.lang.IllegalStateException: ParsePlugins is already initialized 引起原因:java.lang.IllegalStateException:ParsePlugins已经初始化
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.