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

Apps Confused by a View!

javano

Lurker
Nov 5, 2010
4
0
The scenario;

Main.java
[main calls otherclass with an intent]
Code:
Intent intent = new Intent(TestActivity.this, Otherclass.class);
startActivityForResult(intent, INT_INTENT);

Otherclass.java
[otherclass implements a Control and sets it as its view so I can capture input]
Code:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Control = new Control(this);
setContentView(Control);
Control.requestFocus();

Control.java
Code:
public class Control extends View implements OnTouchListener {
.....//code goes here
}

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:
public void Back(){
Intent returnIntent = new Intent();
returnIntent.putExtra("value", "one");
setResult(RESULT_OK, returnIntent);
finish();
}

Which I called from Control with;
Code:
new Otherclass().Back();
But that doesn't do anything? (no errors, nothing?)

I also changed the Back() method to the following;
Code:
public void Back(){
    	setContentView(R.layout.main);
}

But that crashes my app?

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

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones