I downloaded a database from the internet and i'm trying to build my app on top of it. It's tested and it works. The problems begin when I try to open a new activity
I have a button called "New" on my main layout which is supposed to open a new window in my app (just open a new activity for now), but it crashes immediately on call. My current activity is DatabaseExampleActivity(my main) and I want the new one to be NewAssignmentActivity.
Here are the relevant code sections:
//the function that is called when "new" button is pressed
public void newAssignment(View view) {
Intent i = new Intent(DatabaseExampleActivity.this, NewAssignmentActivity.class);
startActivity(i);
}
//The manifest
<activity
android:name=".DatabaseExampleActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".NewAssignmentActivity"
android:label="@string/title_activity_new_assignment" >
</activity>
//the new activity code
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
public class NewAssignmentActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_newassignment);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.new_assignment, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
consol writes in red : ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.anotherandroidblog.tools.database/.DatabaseExampleActivity }
ActivityManager: Warning: Activity not started, its current task has been brought to the front
The logCat also gives tons of errors too
No comments:
Post a Comment