目标api级别(android)

时间:2012-10-19 00:31:17

标签: android api

我创建了一个应用程序,它在某个api级别以上的设备上运行良好,但是当我在API级别为7的手机上运行它时,它无法正常工作。它虽然没有崩溃。如果我更改清单中的min或target api值,应用程序仍会运行,并且我在eclipse中没有得到任何错误/警告。所以我的问题是如何在不安装每个Android API的情况下告诉使用什么API级别,创建模拟器并查看它是否正确运行。当我使用以下代码时发生错误 当我使用以下代码时:

 ' cal = Calendar.getInstance();
             cal.set(year, month, day, hour,minute);
            current time

             intent = new Intent(this, AlarmReceiver.class);
             intent.putExtra("vns", 1);


             sender = PendingIntent.getBroadcast(this, 192837, intent,
             PendingIntent.FLAG_UPDATE_CURRENT);
            // Get the AlarmManager service
             am = (AlarmManager) getSystemService(ALARM_SERVICE);
             am.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), sender);' 

它没有正确设置事件而是什么都不做

1 个答案:

答案 0 :(得分:0)

支持多个API时,始终使用最低的API进行编码。

要找出你不应该使用的东西:

对于您有疑问的类/方法,请注意文档弹出窗口,它告诉最低API级别,例如: 自:API级别1

转到Android developer API reference,搜索包,然后选择API级别,将标记不受支持的包成员。