Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/357.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java setAction()为intent做了什么_Java_Android - Fatal编程技术网

Java setAction()为intent做了什么

Java setAction()为intent做了什么,java,android,Java,Android,setAction()实际上是做什么的? 我发现 但我不明白 public void incrementWater(View view) { if (mToast != null) mToast.cancel(); mToast = Toast.makeText(this, R.string.water_chug_toast, Toast.LENGTH_SHORT); mToast.show(); Intent increm

setAction()实际上是做什么的? 我发现 但我不明白

    public void incrementWater(View view) {
        if (mToast != null) mToast.cancel();
        mToast = Toast.makeText(this, R.string.water_chug_toast, Toast.LENGTH_SHORT);
        mToast.show();
        Intent incrementWaterCountIntent = new Intent(this, WaterReminderIntentService.class);
        incrementWaterCountIntent.setAction(ReminderTasks.ACTION_INCREMENT_WATER_COUNT);
        startService(incrementWaterCountIntent);

    }

首先,你必须问问自己,你想要做什么!?操作用于描述意图执行的操作。例如,如果意图的目的是执行web搜索,则操作应为操作\u web\u搜索(最好这样做,或者可以使用简单的空新意图()。你可以看一些行动的例子。
在您发送的代码中,程序员自己创建了ACTION\u INCREMENT\u WATER\u COUNT,类型为string。

请阅读文档,以避免提出类似问题。你可以在这里找到它:。至于行动: