Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Mobile Development
  3. Android
  4. Get error when passing data using Intent

Get error when passing data using Intent

Scheduled Pinned Locked Moved Android
helpjavaandroidcomxml
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    tan873
    wrote on last edited by
    #1

    Any problem for my coding? Please help, thanks.

    xml code

    MyActivity.java
    package com.example.user.myapplication;

    import android.app.Activity ;
    import android.content.Intent;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.Button;
    import android.widget.EditText;

    import static com.example.user.myapplication.R.*;

    public class MyActivity extends Activity implements View.OnClickListener {
    EditText mtext;
    Button mbutton;

    [@Override](http://www.codeproject.com/Members/OverRide)
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(layout.activity\_my);
    
        mtext   = (EditText)findViewById(id.medittext);
        mbutton = (Button)findViewById(id.btnsubmit);
        mbutton.setOnClickListener(this);
    }
    
    [@Override](http://www.codeproject.com/Members/OverRide)
    public void onClick(View v) {
        // Do something in response to button
        Intent intent = new Intent(this, ViewActivity.class);
        String message = mtext.getText().toString();
        intent.putExtra("mtext",message);
        startActivity(intent);
    
    }
    

    }

    ViewActivity.java
    package com.example.user.myapplication;

    import android.app.Activity;
    import android.content.Intent;
    import android.os.Bundle;
    import android.widget.TextView;
    /**

    Richard DeemingR D 2 Replies Last reply
    0
    • T tan873

      Any problem for my coding? Please help, thanks.

      xml code

      MyActivity.java
      package com.example.user.myapplication;

      import android.app.Activity ;
      import android.content.Intent;
      import android.os.Bundle;
      import android.view.View;
      import android.widget.Button;
      import android.widget.EditText;

      import static com.example.user.myapplication.R.*;

      public class MyActivity extends Activity implements View.OnClickListener {
      EditText mtext;
      Button mbutton;

      [@Override](http://www.codeproject.com/Members/OverRide)
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(layout.activity\_my);
      
          mtext   = (EditText)findViewById(id.medittext);
          mbutton = (Button)findViewById(id.btnsubmit);
          mbutton.setOnClickListener(this);
      }
      
      [@Override](http://www.codeproject.com/Members/OverRide)
      public void onClick(View v) {
          // Do something in response to button
          Intent intent = new Intent(this, ViewActivity.class);
          String message = mtext.getText().toString();
          intent.putExtra("mtext",message);
          startActivity(intent);
      
      }
      

      }

      ViewActivity.java
      package com.example.user.myapplication;

      import android.app.Activity;
      import android.content.Intent;
      import android.os.Bundle;
      import android.widget.TextView;
      /**

      Richard DeemingR Offline
      Richard DeemingR Offline
      Richard Deeming
      wrote on last edited by
      #2

      Can you just move your head slightly to the left? You're in the way of the hidden camera we've installed behind you, and we can't see the error details on your screen. :rolleyes: Oh, wait; we don't have a camera pointing at your screen. We also don't have remote access to your computer, nor telepathy. If you don't tell us what the error is, how do you think anyone will be able to fix it?


      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

      1 Reply Last reply
      0
      • T tan873

        Any problem for my coding? Please help, thanks.

        xml code

        MyActivity.java
        package com.example.user.myapplication;

        import android.app.Activity ;
        import android.content.Intent;
        import android.os.Bundle;
        import android.view.View;
        import android.widget.Button;
        import android.widget.EditText;

        import static com.example.user.myapplication.R.*;

        public class MyActivity extends Activity implements View.OnClickListener {
        EditText mtext;
        Button mbutton;

        [@Override](http://www.codeproject.com/Members/OverRide)
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(layout.activity\_my);
        
            mtext   = (EditText)findViewById(id.medittext);
            mbutton = (Button)findViewById(id.btnsubmit);
            mbutton.setOnClickListener(this);
        }
        
        [@Override](http://www.codeproject.com/Members/OverRide)
        public void onClick(View v) {
            // Do something in response to button
            Intent intent = new Intent(this, ViewActivity.class);
            String message = mtext.getText().toString();
            intent.putExtra("mtext",message);
            startActivity(intent);
        
        }
        

        }

        ViewActivity.java
        package com.example.user.myapplication;

        import android.app.Activity;
        import android.content.Intent;
        import android.os.Bundle;
        import android.widget.TextView;
        /**

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        No error checking, no try/catch clauses, and the name of the extra differs between the put (mtext) and the get (abc). :rolleyes: How exactly are we supposed to help you? :confused:

        "One man's wage rise is another man's price increase." - Harold Wilson

        "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

        "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups