Hi all,
New to this group and also new to app development. Following the tutorial on developer.android.com which was mainly prepared for Eclipse, but I am working the code out on Android Studio. Finished the first section, but when executing it says "Local path doesn't exist". Also the code shows some errors too.
The code from the MainActitivty class:
public class MainActivity extends Activity {
public final static String EXTRA_MESSAGE = "com.sumchans.myfirstapp.MESSAGE";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void sendMessage(View v){
Intent intent = new Intent(this, DisplayMessageActivity.class);
EditText editText = (EditText)findViewById(R.id.edit_message);
String message = editText.getText().toString();
intent.putExtra(EXTRA_MESSAGE,message);
startActivity(intent);
}
The underlined part of the code on top has a green line under it.
Code from the DisplayMessageActivity class:
public class DisplayMessageActivity extends Activity {
@SuppressLint("NewApi")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_display_message);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB){
getActionBar().setDisplayHomeAsUpEnabled(true);
}
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()){
case android.R.id.home:
NavUtils.navigateUpFromSameTask(this);
return true;
}
return super.onOptionsItemSelected(item);
}
}
The underlined part of the code says: "Gradle: error: cannot find symbol variable NavUtils"
File is also attached.
Somebody please advise.
Thank you.
New to this group and also new to app development. Following the tutorial on developer.android.com which was mainly prepared for Eclipse, but I am working the code out on Android Studio. Finished the first section, but when executing it says "Local path doesn't exist". Also the code shows some errors too.
The code from the MainActitivty class:
public class MainActivity extends Activity {
public final static String EXTRA_MESSAGE = "com.sumchans.myfirstapp.MESSAGE";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void sendMessage(View v){
Intent intent = new Intent(this, DisplayMessageActivity.class);
EditText editText = (EditText)findViewById(R.id.edit_message);
String message = editText.getText().toString();
intent.putExtra(EXTRA_MESSAGE,message);
startActivity(intent);
}
The underlined part of the code on top has a green line under it.
Code from the DisplayMessageActivity class:
public class DisplayMessageActivity extends Activity {
@SuppressLint("NewApi")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_display_message);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB){
getActionBar().setDisplayHomeAsUpEnabled(true);
}
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()){
case android.R.id.home:
NavUtils.navigateUpFromSameTask(this);
return true;
}
return super.onOptionsItemSelected(item);
}
}
The underlined part of the code says: "Gradle: error: cannot find symbol variable NavUtils"
File is also attached.
Somebody please advise.
Thank you.