传递intent对象后不启动活动

时间:2015-04-09 09:35:48

标签: android object android-intent timepicker

我一直在努力构建这个应用程序,但由于某种原因它无法正常工作。点击下一个按钮后,它显示"不幸的是,该应用程序已停止工作"。这是代码。如果有人能帮助我,我真的很感激。我无法找到问题所在

public DatePicker picker;
public TimePicker time;
public String dt,datei;
public String timei,t;
public int hour, min;
public String format = "";

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_datetimepicker);
    btnNxt = (Button) findViewById(R.id.btnNxt2);
    time = (TimePicker)findViewById(R.id.timePicker);
    picker = (DatePicker)findViewById(R.id.datePicker);
    hour = time.getCurrentHour();
    min = time.getCurrentMinute();
    showTime(hour,min);
    t = timei;

    btnNxt.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            Intent intent = new Intent(DateTimeActivity.this,
                    PhoneNumberActivity.class);

            intent.putExtra("t",t);
            startActivity(intent);
        }
    });
}

public String showTime(int hour, int min) {
    if (hour == 0) {
        hour += 12;
        format = "AM";
    } else if (hour == 12) {
        format = "PM";
    } else if (hour > 12) {
        hour -= 12;
        format = "PM";
    } else {
        format = "AM";
    }
    StringBuilder str = new StringBuilder().append(hour).append(" : ").append(min)
            .append(" ").append(format);
    timei = str.toString();
    return timei;
}

}

此错误显示在日志文件

Note: C:\Users\Arnab PC\AndroidStudioProjects\SendGreetings\app\src\main\java\com\example\sendgreetings\PhoneNumberActivity.java uses or overrides a deprecated API.

注意:使用-Xlint重新编译:弃用以获取详细信息。

0 个答案:

没有答案