Application stop unexpectedly. ForceClose Error
Can't start activity from main activity. In main activity, i have to buttons. After clicking them, I intent to launch respective activity like this;
final Intent entryIntent = new Intent(this,PolicyEntry.class);
final Intent retrieveIntent = new Intent(this,ViewPolicy.class);
btn1.setOnClickListener(new View.OnClickListener()
{
@Override
public void onCli开发者_Go百科ck(View v)
{
startActivity(entryIntent);
}
});
btn2.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
startActivity(retrieveIntent);
}
});
PolicyEntry and ViewPolicy are declared in manifest like this:
<activity android:name=".ACDroid" 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=".PolicyEntry" android:label="@string/app_name">
</activity>
<activity android:name=".ViewPolicy" android:label="@string/app_name">
</activity>
But whenever I click those buttons:
The application (process com...) has stopped unexpectedly. Please try again error shows.
In addition, in the Logcat, android.content.ActivityNotFoundException: Unable to find explicit activity class com.acdroid.... error occurs. What do I do?
Try adding the package in manifest, like
<activity android:name="your_package_here.PolicyEntry" android:label="@string/app_name">
and then hit Project->Clean and then run the project again.
I think the problem is in PolicyEntry and ViewPolicy Activity.Please check onCreate method of these Activity
After you declare and assign the intent, set the flag value:
entryIntent.setFlag(Intent.FLAG_ACTIVITY_NEW_TASK);
retrieveIntent.setFlag(Intent.FLAG_ACTIVITY_NEW_TASK);
精彩评论