我一直在使用解析试图使登录和注册系统正常工作,并且暂时似乎正在运行。我开始尝试添加一种制作帖子的方法,现在当我运行应用程序时,我得到一个空白的白色屏幕,它在那里冻结,在一分钟左右后,我能够摆脱它,随时我尝试访问它再次冻结并坐在那里。当我在模拟器上运行它而不是我的手机时,整个计算机都崩溃了。有谁知道发生了什么?我将发布我的主要活动,但如果您需要更多信息,请告诉我并添加该代码。
编辑:当我点击主页按钮时会出现登录页面,当我离开它时整个手机都很奇怪,移动的背景不再出现了。
主要活动:
package com.example.douglas.topic;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import com.example.douglas.topic.LoginActivity;
import com.example.douglas.topic.PostActivity;
import com.example.douglas.topic.PostAdapter;
import com.example.douglas.topic.PostDataProvider;
import com.example.douglas.topic.R;
import com.parse.Parse;
import com.parse.ParseObject;
import com.parse.ParseUser;
public class Lorem extends ActionBarActivity {
//private static final String="POST";
ListView listView;
int[] pic_thumbnail_resource = {R.mipmap.ic_launcher, R.mipmap.ic_launcher, R.mipmap.ic_launcher, R.mipmap.ic_launcher,
R.mipmap.ic_launcher, R.mipmap.ic_launcher,};
String[] post_ratings;
String[] post_titles;
PostAdapter adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
// Parse
// Enable Local Datastore.
//Parse.enableLocalDatastore(this);
Parse.initialize(this, "wHN7DSZyAzVXT5xs5ABNHUVBwOWasUExbeuePvQvL", "SsvjuJ7e97FsRLNMH2XI7dlv8RilgSoFSw5waIOXM");
//ParseObject testObject = new ParseObject("TestObject");
//testObject.put("foo", "bar");
//testObject.saveInBackground();
ParseUser currentUser = ParseUser.getCurrentUser();
if (currentUser != null) {
// do stuff with the user
} else {
// show the signup or login screen
Intent takeUsertoLogin = new Intent(this, LoginActivity.class);
startActivity(takeUsertoLogin);
}
// End Parse
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_lorem);
listView = (ListView)findViewById(R.id.list_view);
post_ratings = getResources().getStringArray(R.array.post_ratings);
post_titles = getResources().getStringArray(R.array.post_titles);
//populateListView();
registerClickCallback();
int i = 0;
adapter = new PostAdapter(getApplicationContext(),R.layout.row_layout);
listView.setAdapter(adapter);
for(String titles: post_titles)
{
PostDataProvider dataProvider = new PostDataProvider(pic_thumbnail_resource[i], titles, post_ratings[i]);
adapter.add(dataProvider);
i++;
}
}
private void registerClickCallback(){
ListView list = (ListView) findViewById(R.id.list_view);
list.setOnItemClickListener(new AdapterView.OnItemClickListener(){
@Override
public void onItemClick(AdapterView<?> parent, View viewClicked, int position, long id){
TextView textView = (TextView) viewClicked;
String message = "You clicked # " + position + ",which is string: " + textView.getText().toString();
Toast.makeText(Lorem.this, message, Toast.LENGTH_LONG).show();
}
});
}
/*
@Override
public void onActivityResult(String requestCode, String resultCode, Intent data){
if (requestCode == "POST")
{
myItems.add
}
super.onActivityResult(requestCode, resultCode, data);
}
*/
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_lorem, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
super.onOptionsItemSelected(item);
switch (item.getItemId()){
case R.id.post:
aboutItemPost();
break;
case R.id.location:
aboutItemLocation();
break;
case R.id.topic:
aboutItemTopic();
break;
case R.id.sort:
aboutItemSort();
break;
case R.id.login:
aboutItemLogin();
case R.id.Register:
aboutItemRegister();
case R.id.Logout:
aboutItemLogout();
}
return true;
}
private void aboutItemPost(){
Intent intent = new Intent(getApplicationContext(), PostActivity.class);
startActivityForResult(intent, 0);
}
private void aboutItemLocation(){
Intent intent = new Intent(getApplicationContext(), LocationActivity.class);
startActivityForResult(intent, 0);
}
private void aboutItemTopic(){
Intent intent = new Intent(getApplicationContext(), TopicActivity.class);
startActivityForResult(intent, 0);
}
private void aboutItemSort(){
new AlertDialog.Builder(this)
.setTitle("Sort")
.setMessage("This is where the user will sort what they want to see")
.setNeutralButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
}).show();
}
private void aboutItemLogin(){
Intent takeUsertoLogin = new Intent(this, LoginActivity.class);
startActivity(takeUsertoLogin);
}
private void aboutItemRegister(){
Intent intent = new Intent(getApplicationContext(), RegisterActivity.class);
startActivityForResult(intent, 0);
}
private void aboutItemLogout() {
// log the user out
ParseUser.logOut();
// take the user back to log in screen
Intent takeUsertoLogin = new Intent(this, LoginActivity.class);
startActivity(takeUsertoLogin);
}
答案 0 :(得分:0)
Parse.initialize(getApplicationContext(), "wHN7DSZyAzVXT5xs5ABNHUVBwOWasUExbeuePvQvL", "SsvjuJ7e97FsRLNMH2XI7dlv8RilgSoFSw5waIOXM");
它需要Context
Application
。