• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

App Inventor Google developers website issue

Please Post a solution for that

  • Corrected code

    Votes: 0 0.0%
  • Any changes in code segments

    Votes: 0 0.0%

  • Total voters
    0
Error in google official website for learning Basics of Android Studio.I saw your previous solution but the solution you have provided is same as my code. Here is my code where I am getting error

1.This is my DisplayMessageActivity code

package com.example.myapplication;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.TextView;



public class DisplayMessageActivity extends AppCompatActivity {

@override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_display_message);

Intent intent = getIntent();
String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);
TextView textView = findViewById(R.id.textView);
textView.setText(message);
}
}








2.This is my Main activity code





package com.example.myapplication;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;

import static android.provider.AlarmClock.EXTRA_MESSAGE;




public class MainActivity extends AppCompatActivity {


@override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void sendMessage(View view) {
Intent intent = new Intent(this, DisplayMessageActivity.class);
EditText editText = (EditText) findViewById(R.id.editText);
String message = editText.getText().toString();
intent.putExtra(EXTRA_MESSAGE, message);
startActivity(intent);
}
}
 
Error in google official website for learning Basics of Android Studio.I saw your previous solution but the solution you have provided is same as my code. Here is my code where I am getting error

If I may suggest, you can make your code format better in your post by using [ code ] tags to wrap it, like this:
[ code ]
void myFunc() {
// code
}
[ /code ]
- leave out the spaces inside the square brackets for it to actually work.

that will give you:
Code:
void myFunc() {
    // code
}

What is the error that you are seeing?
 
Actually I'm getting Error 1: cannot find symbol variable EXTRA_MESSAGE
Error 2 : cannot find symbol variable textView

I'm no expert, but it looks to me like EXTRA_MESSAGE is not defined in MainActivity (you are importing it, not defining it as a property of MainActivity), so there's nothing for it to find.

You don't provide your XML, but you need to be sure that textView is defined in your activity_displaymessage.xml - maybe you didn't set the ID for the element?
 
Back
Top Bottom