2
I have a class with extends PApplet
and I want to migrate from it to another with extends Activity
I tried through a Intent
but I couldn’t.
Body of the Papplet class:
public class CamMain extends PApplet {
public void setup() {
//ESCOPO . . .
}
public void draw() {
//ESCOPO . . .
}
public void onCameraPreviewEvent() {
//ESCOPO. . .
}
public void mousePressed() {
//ESCOPO . . .
}
public void teste(){
// CRIEI PRA TESTAR MIGRAÇÃO POR INTENT, MAS NÃO FUNCIONOU. . .
//Intent intent = new Intent(this, Teste.class);
//startActivity(intent);
}
}
Papplet is called by an Activity as shown in the example below
Activity that calls Papplet:
package processing.test.camMain;
import android.app.Activity;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.view.ViewGroup.LayoutParams;
import android.app.FragmentTransaction;
import processing.core.PApplet;
public class MainActivity extends Activity {
PApplet fragment;
private static final String MAIN_FRAGMENT_TAG = "main_fragment";
int viewId = 0x1000;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Window window = getWindow();
requestWindowFeature(Window.FEATURE_NO_TITLE);
window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN,WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
FrameLayout frame = new FrameLayout(this);
frame.setId(viewId);
setContentView(frame, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
if (savedInstanceState == null) {
fragment = new CamMain();
FragmentTransaction ft = getFragmentManager().beginTransaction();
ft.add(frame.getId(), fragment, MAIN_FRAGMENT_TAG).commit();
} else {
fragment = (PApplet) getFragmentManager().findFragmentByTag(MAIN_FRAGMENT_TAG);
}
}
@Override
public void onBackPressed() {
fragment.onBackPressed();
super.onBackPressed();
}
}
What this builder expects is a
context
. Without seeing the rest of the class that contains this code, you can’t know if it was meant to work. Show the rest of the class, please.– Pablo Almeida
Hello, I put the body of the rest in question.
– CristianCotrena