I had a libgdx program which starts with the following class:
public class MyActivity extends AndroidApplication implements IActivityRequestHandler
I needed to have an Activity
class to detect screen size using Display
(I can't do that in an AndroidApplication
class).
So I added the following class as my launcher Activity
:
public class MyActivity1 extends Activity
So in my new class MyActivity1
I try to run my old class MyActivity
:
Intent myIntent = new Intent(MyActivity.this, MyActivity.class);
startActivity(myIntent);
But I got the following compilation error: MyActivity is not an enclosing class
Manifest is as follows
<activity android:name=".MyActivity1"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".MyActivity"/>
Why am I getting this error?
Try with this
Intent myIntent = new Intent(MyActivity1.this, MyActivity.class);
startActivity(myIntent);
The new Intent requires the current activity's context (first param) and the class which you want initializate (second param).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With