Aviary SDK安装说明
1、准备工作
a、Aviary-Android-SDK.zip(https://developers.aviary.com/docs/android)
b、Aviary API key and secret(从developers.aviary.com/apps免费获得)
c、在本机系统中已安装配置好Android SDK
2、版本要求
Aviary Android SDK支持Android的最低版本是Android2.3+(API LEVEL 9),但是编译版本必须用Android4.3(API LEVEL 18)
3、导入Aviary Android SDK并将其添加为library.设置编译SDK为4.3
4、设置配置文件manifest.xml,
设置版本:
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="18" />
添加API KEY:
在<application>标签中添加以下代码:
<meta-data
android:name="com.aviary.android.feather.v1.API_KEY"
android:value="your_api_key_here"/>
添加权限:
必加权限:
<uses-permissionandroid:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
如果需要添加振动的反馈,须添加以下权限:
<uses-permissionandroid:name="android.permission.VIBRATE" />
5、添加实体
在application标签中添加以下实体:
<activity
android:name="com.aviary.android.feather.FeatherActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:screenOrientation="unspecified"
android:hardwareAccelerated="true"
android:largeHeap="true"
android:process=":aviarysdk"
android:theme="@style/AviaryTheme" />
说明:必须将FeatherActivity的默认样式定义为 @style/AviaryTheme
<!-- Alert -->
<activity
android:name="com.aviary.android.feather.AlertActivity"
android:launchMode="standard"
android:noHistory="true"
android:theme="@style/AviaryTheme.Dialog">
<intent-filter>
<action android:name="aviary.intent.action.ALERT"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<!-- CDS Content Service -->
<service
android:process=":aviarycds"
android:name="com.aviary.android.feather.cds.AviaryCdsService"
android:exported="false">
<intent-filter>
<actionandroid:name="aviary.intent.action.CDS_DOWNLOAD_START"/>
<action android:name="aviary.intent.action.CDS_RESTORE_USER_ITEMS"/>
</intent-filter>
</service>
<!--
Cds Content Provider,
NOTEthat the "authorities" value MUST be formatted in this way:
android:authorities="{your.packagename}.AviaryCdsProvider"
-->
<provider
android:name="com.aviary.android.feather.cds.AviaryCdsProvider"
android:authorities="{your.package.name}.AviaryCdsProvider"
android:process=":aviarycds"
android:exported="false"
android:syncable="true" />
说明: AviaryCdsProvider实体有一个属性android:authorities值为{your.package.name}.
用在配置文件manifest文件中定义的包名代替{your.package.name}
<!-- CDS Download Receiver -->
<receiver
android:name="com.aviary.android.feather.cds.AviaryCdsReceiver"
android:process=":aviarycds" >
<intent-filter>
<actionandroid:name="android.intent.action.DOWNLOAD_COMPLETE" />
</intent-filter>
</receiver>
6、调用Aviary编辑器
IntentnewIntent = new Intent( this, FeatherActivity.class );
newIntent.setData(Uri.parse("content://media/external/images/media/32705") );
newIntent.putExtra(Constants.EXTRA_IN_API_KEY_SECRET, "your api secret" );
startActivityForResult( newIntent, 1);
说明:图片Uri有以下几种形式:
(1)ContentResolver.SCHEMEFILE: 本地文件绝对路径 ( "file:///mnt/ sdcard/download/image.jpg" )
(2)本地文件绝对路径: ("/mnt/sdcard/bla/image.jpg" ) (3)ContentResolver.SCHEMECONTENT: 数据库保存路径:("content://media/external/images/media/112232" )
(4)"http" or "https": 远程图片文件
还有一些可选Intent参数
7、结果参数
@Override
public void onActivityResult( intrequestCode, int resultCode, Intent data ) {
if( resultCode == RESULT_OK ) {
switch( requestCode ) {
case 1:
// output image path
Uri mImageUri = data.getData();
Bundle extra =data.getExtras();
if( null != extra ) {
// image has been changedby the user?
boolean changed =extra.getBoolean ( Constants.EXTRA_OUT_BITMAP_CHANGED );
}
break;
}
}
}