Android Intent 使用(Call_action 和 new_task_launch)
我在运行我的应用程序时遇到以下错误。 我的应用程序的代码是
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
final Button callButton = (Button) findViewById(R.id. callButton);
callButton.setOnClickListener(new Button.OnClickListener()
{
public void onClick(View v)
{
Intent callIntent = new Intent(Intent.CALL_ACTION,Uri.parse("tel:123456789"));
callIntent.setLaunchFlags(Intent.NEW_TASK_LAUNCH);
startActivity(callIntent);
}
});
}
我面临的问题是 CALL_ACTION
和 NEW_TASK_LAUNCH
给我一个错误,通知我它们不是字段。有人可以解决这个问题吗?
I have faced the following error while running my application.
The code of my app is
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
final Button callButton = (Button) findViewById(R.id. callButton);
callButton.setOnClickListener(new Button.OnClickListener()
{
public void onClick(View v)
{
Intent callIntent = new Intent(Intent.CALL_ACTION,Uri.parse("tel:123456789"));
callIntent.setLaunchFlags(Intent.NEW_TASK_LAUNCH);
startActivity(callIntent);
}
});
}
The problem that I am facing is the CALL_ACTION
and the NEW_TASK_LAUNCH
are giving me an error informing me that they are not fields. Could anyone please resolve this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你只是写错了,显然,它不是一个字段。您的 IDE 中没有收到错误消息吗?
CALL_ACTIVITY
应为ACTION_CALL
,NEW_TASK_LAUNCH
应为FLAG_ACTIVITY_NEW_TASK
。请先阅读文档。You simply write it wrong, obviously, it's not a field. Aren't you getting error message in your IDE?
CALL_ACTIVITY
should beACTION_CALL
andNEW_TASK_LAUNCH
should beFLAG_ACTIVITY_NEW_TASK
. Please read the Documentation first.