dial_action不能得到解决或不是字段 [英] dial_action cannot be resolved or is not a field

查看:394
本文介绍了dial_action不能得到解决或不是字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图执行一个示例应用意向,但我得到的Java文件这些错误:


  

DIAL_ACTION不能得到解决或不是字段搜索
  NEW_TASK_LAUNCH不能得到解决或不是一个字段


下面是我的code:

 包android_programmers_guide.AndroidTeleDial;进口android.app.Activity;
进口android.os.Bundle;
进口android.content.Intent;
进口android.net.Uri;
公共类AndroidTeleDial延伸活动{
    / **当第一次创建活动调用。 * /
    @覆盖
    公共无效的onCreate(捆绑savedInstanceState){
        super.onCreate(savedInstanceState);
        的setContentView(R.layout.main);
        意图DialIntent =新意图(Intent.DIAL_ACTION,Uri.parse(电话:5551212));
        DialIntent.setLaunchFlags(Intent.NEW_TASK_LAUNCH);
        startActivity(DialIntent);
    }
}


解决方案

这是的 Intent.ACTION_DIAL

要避免这种错误,如果你使用Eclipse,使用自动完成功能:同时键入一个单词,preSS Ctrl +空格键,它就会打开尽可能完整的列表

这种方式,试图自动完成 Intent.DIAL ,你会发现,有没有这样的成员意图

I have tried to execute a sample Intent application, but I am getting these errors in the java file:

DIAL_ACTION cannot be resolved or is not a field
NEW_TASK_LAUNCH cannot be resolved or is not a field

Here's my code:

package android_programmers_guide.AndroidTeleDial;

import android.app.Activity;
import android.os.Bundle;
import android.content.Intent;
import android.net.Uri;


public class AndroidTeleDial extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        Intent DialIntent=new Intent(Intent.DIAL_ACTION,Uri.parse("tel:5551212"));
        DialIntent.setLaunchFlags(Intent.NEW_TASK_LAUNCH);
        startActivity(DialIntent);
    }
}

解决方案

It's Intent.ACTION_DIAL.

To avoid this kind of errors, if you're using eclipse, use the auto-completion feature: while typing a word, press ctrl+space and it will open a list of possible completions.

This way, trying to auto complete Intent.DIAL you would find that there's no such member in Intent class.

这篇关于dial_action不能得到解决或不是字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆