Android Intent 使用(Call_action 和 new_task_launch)

发布于 2024-12-21 03:17:37 字数 659 浏览 1 评论 0原文

我在运行我的应用程序时遇到以下错误。 我的应用程序的代码是

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_ACTIONNEW_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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

雨夜星沙 2024-12-28 03:17:37

你只是写错了,显然,它不是一个字段。您的 IDE 中没有收到错误消息吗? CALL_ACTIVITY 应为 ACTION_CALLNEW_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 be ACTION_CALL and NEW_TASK_LAUNCH should be FLAG_ACTIVITY_NEW_TASK. Please read the Documentation first.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文