Renegade
Renegade

Reputation: 157

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 onClick(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?

Logcat error

Upvotes: 0

Views: 474

Answers (3)

Pratik
Pratik

Reputation: 30855

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);

Upvotes: 0

user874649
user874649

Reputation:

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.

Upvotes: 1

Rasel
Rasel

Reputation: 15477

I think the problem is in PolicyEntry and ViewPolicy Activity.Please check onCreate method of these Activity

Upvotes: 0

Related Questions