When I run my app it just opens a white screen and stays there, it slows my whole phone down until I'm forced to shut it down. Logcat says that the first error is "Perfoming stop of activity that is not resumed". I don't really have a onResume on my main file. Should I have a onResume or is there another way to fix this problem?
Here is the error I get when it runs:
05-13 05:13:34.124: E/ActivityThread(27498): Performing stop of activity that is not resumed: {com.example.douglas.topic/com.example.douglas.topic.LoginActivity}
05-13 05:13:34.124: E/ActivityThread(27498): java.lang.RuntimeException: Performing stop of activity that is not resumed: {com.example.douglas.topic/com.example.douglas.topic.LoginActivity}
05-13 05:13:34.124: E/ActivityThread(27498): at android.app.ActivityThread.performStopActivityInner(ActivityThread.java:3214)
05-13 05:13:34.124: E/ActivityThread(27498): at android.app.ActivityThread.handleStopActivity(ActivityThread.java:3301)
05-13 05:13:34.124: E/ActivityThread(27498): at android.app.ActivityThread.access$1100(ActivityThread.java:139)
05-13 05:13:34.124: E/ActivityThread(27498): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1237)
05-13 05:13:34.124: E/ActivityThread(27498): at android.os.Handler.dispatchMessage(Handler.java:102)
05-13 05:13:34.124: E/ActivityThread(27498): at android.os.Looper.loop(Looper.java:136)
05-13 05:13:34.124: E/ActivityThread(27498): at android.app.ActivityThread.main(ActivityThread.java:5097)
05-13 05:13:34.124: E/ActivityThread(27498): at java.lang.reflect.Method.invokeNative(Native Method)
05-13 05:13:34.124: E/ActivityThread(27498): at java.lang.reflect.Method.invoke(Method.java:515)
05-13 05:13:34.124: E/ActivityThread(27498): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
05-13 05:13:34.124: E/ActivityThread(27498): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
05-13 05:13:34.124: E/ActivityThread(27498): at dalvik.system.NativeStart.main(Native Method)
Here is the code for my main activity:
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(getApplicationContext(), "wHN7DSZyAzVXT5xs5ASDFGwOWasUExbeuePvQvL", "SsvjuJ7e97FsScI12VB7dlv8RilgSoFSw5waIOXM");
//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);
}
}
Here is the code for my Login activity:
package com.example.douglas.topic;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import com.parse.LogInCallback;
import com.parse.Parse;
import com.parse.ParseUser;
import java.text.ParseException;
/**
* Created by Douglas on 5/10/2015.
*/
public class LoginActivity extends Lorem {
protected EditText mUsername;
protected EditText mPassword;
protected Button mLoginButton;
protected Button mCreateAccountButton;
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
//initialize
mUsername = (EditText)findViewById(R.id.LoginUserName);
mPassword = (EditText)findViewById(R.id.LoginPassword);
mLoginButton = (Button)findViewById(R.id.LoginButton);
mCreateAccountButton = (Button)findViewById(R.id.LoginRegisterButton);
// Listen to when mLoginButton is clicked
mLoginButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// get the user input from the edit text and convert into string
String username = mUsername.getText().toString().trim();
String password = mPassword.getText().toString().trim();
// Login the user using Parse SDK
ParseUser.logInInBackground(username, password, new LogInCallback() {
@Override
public void done(ParseUser parseUser, com.parse.ParseException e) {
if (e == null) {
// Success, user logged in
Toast.makeText(LoginActivity.this, "Welcome Back!", Toast.LENGTH_SHORT).show();
Intent takeUserHome = new Intent(LoginActivity.this, Lorem.class);
startActivity(takeUserHome);
} else {
// Failure to Log in, advise user
AlertDialog.Builder builder = new AlertDialog.Builder(LoginActivity.this);
builder.setMessage(e.getMessage());
builder.setTitle("Sorry!");
builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// close the dialog window
dialog.dismiss();
}
});
AlertDialog dialog = builder.create();
dialog.show();
}
}
});
}
});
}
}
Thank you for your time.