Why am I getting the error "MyActivity is not in the class?"

I had a libgdx program that starts with the following class:

public class MyActivity extends AndroidApplication implements IActivityRequestHandler

I needed to have a class Activityto determine the screen size using Display(I cannot do this in the class AndroidApplication).

So, I added the following class as my run Activity:

public class MyActivity1 extends Activity

So, in my new class, MyActivity1I'm trying 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 part of the class

The 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?

+5
source share
1 answer

Try with this

  Intent myIntent = new Intent(MyActivity1.this, MyActivity.class);
  startActivity(myIntent);

( ) , ( ).

+19

All Articles