Reputation: 139
Hello I have 2 activities on my app and I want to be able to switch between them by clicking button when I tried my code I got error:
03-27 22:27:08.370: E/AndroidRuntime(9051): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.tdgame.dorbt12.MAIN }
my code is:
@Override
public void onClick(View v) {
Intent open = new Intent("com.tdgame.dorbt12.MAIN");
startActivity(open);
}
the two activities names is: Main and Must
Upvotes: 0
Views: 8134
Reputation: 15432
Use this
Intent open = new Intent(Main.this, Must.class);
startActivity(open);
Add
<activity android:name=".Must" />
before closing application
in you manifest
Upvotes: 0
Reputation: 181
Shouldn't the syntax of your intent be a little bit different? I usually write:
Intent open = new Intent(this, SecondActivity.class);
where SecondActivity
is the name of the Activity that you want to run.
Upvotes: 0
Reputation: 2042
Try the following:
Intent open = new Intent(currentActivitiy.this, destinationActivity.class);
startActivity(open);
Upvotes: 1
Reputation: 20155
You haven't added com.price.dor.MAIN
in your Manifest.
Try setting the Activity like this as you are identifying activity based on the intent filter
<activity
android:name=".Main" >
<intent-filter>
<action android:name="com.tdgame.dorbt12.MAIN" /> //required
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
you need intent filter Action tag because your passing intent using that.
Intent open = new Intent("com.tdgame.dorbt12.MAIN");
Upvotes: 3