1. In regards to recently combined carrier specific root forums, if your device forum was affected, please see this poll/thread!

Confused by a View!


  1. javano

    javano New Member

    The scenario;

    Main.java
    [main calls otherclass with an intent]
    Code (Text):
    1. Intent intent = new Intent(TestActivity.this, Otherclass.class);
    2. startActivityForResult(intent, INT_INTENT);
    Otherclass.java
    [otherclass implements a Control and sets it as its view so I can capture input]
    Code (Text):
    1.  
    2. public void onCreate(Bundle savedInstanceState) {
    3. super.onCreate(savedInstanceState);
    4. Control = new Control(this);
    5. setContentView(Control);
    6. Control.requestFocus();
    Control.java
    Code (Text):
    1. public class Control extends View implements OnTouchListener {
    2. .....//code goes here
    3. }
    How can I from Control (which is extended the view of otherclass) kill the otherclass intent and return back to mainclass. I have been capturing input so say a double tap on the control can trigger this event but I can't seems to get it right?

    Under otherclass I had;
    Code (Text):
    1.  
    2. public void Back(){
    3. Intent returnIntent = new Intent();
    4. returnIntent.putExtra("value", "one");
    5. setResult(RESULT_OK, returnIntent);
    6. finish();
    7. }
    Which I called from Control with;
    Code (Text):
    1. new Otherclass().Back();
    But that doesn't do anything? (no errors, nothing?)

    I also changed the Back() method to the following;
    Code (Text):
    1. public void Back(){
    2.         setContentView(R.layout.main);
    3. }
    But that crashes my app?

    I am clearly lost, what have I miss-understood here?

    Advertisement

Share This Page