应用程序意外停止。强制关闭错误
无法从主要活动开始活动。 在主要活动中,我必须按钮。 单击它们后,我打算像这样启动相应的活动;
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 和 ViewPolicy 在清单中声明如下:
<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>
但每当我单击这些按钮时:
应用程序(进程com...)已意外停止。请重试,错误显示。
另外,在Logcat中,出现android.content.ActivityNotFoundException: Unable to find Explicit Activity class com.acdroid....错误。 我该怎么办?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
尝试在清单中添加包,
然后点击“项目”->“清理”,然后再次运行该项目。
Try adding the package in manifest, like
and then hit Project->Clean and then run the project again.
我认为问题出在PolicyEntry和ViewPolicy Activity中。请检查这些Activity的onCreate方法
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: