Quantcast
Channel: Android Mode - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 941

Issues with migrating to P3 in Eclipse

$
0
0

I am migrating my project from P2 to P3 in Eclipse and experiencing a few issues. As such I have a few questions:

1: Is the following still the correct way to declare the MainActivity class?

    public class MainActivity extends PApplet{
    }

2: Eclipse is telling me that the following method is apparently final and so I cannot override it to set the right renderer:

    public String sketchRenderer() {
    return OPENGL;
    }

How, then, do I set the right renderer?

3: Eclipse is telling me:

The method getSharedPreferences(String, int) is undefined for the type MainActivity

for the following snippet:

    SharedPreferences sharedPref = getSharedPreferences("Data",
                    Context.MODE_PRIVATE);

This was not the case for P2. All other methods within MainActivity that worked with P2 that were called like this from MainActivity:

this.method();

give the same error in P3. The error disappears when I modify the code to the following:

        SharedPreferences sharedPref = getActivity().getSharedPreferences("Data",
                Context.MODE_PRIVATE);

Will this solve the issue?

4: Using P2, I was able to override Android's onStart() method using:

@Override
    protected void onStart() {
        super.onStart();
}

This is no lnger possible, since Eclipse is telling me:

Cannot reduce the visibility of the inherited method from PApplet

Changing it to:

@Override
        public void onStart() {
            super.onStart();
    }

solves the issue, but why could I override the method in P2 and not in P3?

Thank you in advance for your answers.


Viewing all articles
Browse latest Browse all 941

Trending Articles