Small-App API ベースのアプリケーションは、既存のアプリケーションの一部にすることができます。
現在のアプリケーションで Small Apps API をサポートする場合は、次のことを行う必要があります。
Android マニフェストに次の行を追加します。
<uses-library android:name="com.sony.smallapp.framework” android:required="false" />
上記のコードにより、ライブラリをサポートしていないデバイスのアプリケーションを除外するためにライブラリが使用されないことが保証されます。次に、ランチャー アクティビティまたは別のクラスで以下のコードを使用して、クラスを動的に確認できます。
1. String checkLibrary = "com.sony.smallapp.framework";
2. try {
3. Class libraryToInvestigate = Class.forName(checkLibrary);
4. // Dynamically initiate the library
5. // Initiate constructor or methods
6. } catch (ClassNotFoundException e) {
7. // If class is not found(Small Apps API not supported), handle exception and use a home widget or normal activity as fallback
8. } catch (Exception e) {
9. // Unknown exception
10. }
Java でのリフレクションの使用に関する詳細については、次のリンクを確認してください: http://mobile.tutsplus.com/tutorials/android/java-reflection/
Android マニフェストの uses-library については、次のリンクを確認してください:
http://developer.android.com/guide/topics/manifest/uses-library-element.html