在API 10显影Android应用程序 - 将它仍然在设备上使用API​​ 7上运行?将它、应用程序、设备、API

2023-09-07 11:42:36 作者:历劫低潮

我是一种新到Android的世界,有一个简单的问题。

I am kind of new to Android world and have a simple question.

如果我开发一个应用程序的使用的API 13(或API10)库的将这个程序仍然在Android手机而运行只有API 7 的安装?

If I develop an app using libraries on API 13 (or API10) will this app still run on Android phones which have only API 7 installed?

当我尝试使用API​​ 7我的Andr​​oid手机上运行我的Eclipse当前应用程序,我得到的的错误消息我的应用程序需要至少API 10 的 - 所以恐怕在API 13开发

When I try to run my current app with EClipse on my Android phone with API 7 I get an error message that my app requires at least API 10 - so I am afraid to develop on API 13.

我应该更好的只是坚持API 7,而不是使用新的功能?

最新最好的事情在这种情况下怎么办?

Whats the best thing to do in this situation?

非常感谢

推荐答案

,如果你不使用来自任何API10函数,它是不是在旧的API present会工作。

It will work if you are not using any function from API10 which is not present in the older APIs.

您仍然可以使用这些新功能与反思。首先检查是否功能是可用的,然后用反射执行它。

You can still use the new functions with reflection. First check if the function is available, then execute it with reflection.

例如:

    // try to override the transition animation
    if (VERSION.SDK_INT > android.os.Build.VERSION_CODES.DONUT) {
      try {
        Method method = getClass().getMethod("overridePendingTransition",
            new Class[]{int.class, int.class});
        method.invoke(this, 0, 0);
      } catch (Throwable e) {
        // can not override transition animation, so do nothing
      }
    }

另外,还要确保你的android设置:的minSdkVersion

Also make sure you set android:minSdkVersion.