Reputation: 53647
I have created two classes: Example1
and Example2
, which extends activity.
Example1
contains a UI of buttons, while Example2 contains UI of TextEdit. I want to call Example2 when a button is clicked, so this code is in an onclick
method
Intent i = new Intent();
i.setClassName("com.a.ui", "com.a.ui.Example2");
startActivity(i);
So I am able to get the UI of Example2 successfully. What's an alternate way of calling intent?
Is there any alternate way to start an activity?
Upvotes: 1
Views: 286
Reputation: 3109
And remember to include the Activity in your Manifest.xml
e.g.
<activity android:name=".SampleActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
Upvotes: 0
Reputation: 16339
You can try this way.
Intent i = new Intent(com.a.ui.this, com.a.ui.Example2.class);
startActivity(i);
Upvotes: 0
Reputation: 91175
you can call like this:
startActivity(new Intent(com.a.ui.this, com.a.ui.Example2.class));
Upvotes: 1