android - Android Intent使用情况(Call_action和new_task_launch)

标签 android compiler-errors

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

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给我一个错误,通知我它们不是字段。谁能解决这个问题?

最佳答案

您只需写错了,显然,这不是一个字段。您没有在IDE中收到错误消息吗? CALL_ACTIVITY应该是ACTION_CALL,而NEW_TASK_LAUNCH应该是FLAG_ACTIVITY_NEW_TASK。请先阅读Documentation

关于android - Android Intent使用情况(Call_action和new_task_launch),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8517523/

相关文章:

android - 通知从 Android 应用程序发送的 HTTP 请求

php - 如何将json数组数据插入mysql?

c++ - boost::spirit::qi 编译器错误:没有转换运算符无法将 'const some_stuff::return_type' 转换为 'unsigned int'

android - Android Studio Gradle编译时间错误

c - ADS v1.2 错误 C2304E : <command> expected but found 'int'

java - SQLiteBindORColumnindexoutofrange异常

android - 如果包含 RatingBar,列表项将变得不可点击?

Android - ScrollView 内的 TabHost

c# - 为什么在使用 Environment.Exit() 时需要返回,而不是抛出的异常?

ios - Xcode 8.0 Command/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc 失败,退出代码为 1