package com.example.demoservice.extensions;
import android.content.ComponentName;
import android.util.Log;
import com.adobe.fre.FREContext;
import com.adobe.fre.FREFunction;
import com.adobe.fre.FREObject;
public class IapTstoreStartServiceFunction implements FREFunction {
private static String TAG = IapTstoreStartServiceFunction.class.getSimpleName();
public FREObject call( FREContext context, FREObject[] args ) {
Log.d( TAG, "0 : " );
try {
Intent intent = new Intent( "com.example.demoservice.DemoService" );
ComponentName cn = context.getActivity().startService( intent );
Log.d( TAG, "1 : " + cn ); // <---- cn is null ******
}
catch( Exception e )
{
Log.d( TAG, "2 : " + e );
}
Log.d( TAG, "3 : " + cn );
return null;
}
}
当调用上面的函数时,startService()返回null(cn为null)并且不调用DemoService的onStartCommand。但DemoService在本机android活动调用时正确启动。我无法在ANE AIR启动DemoService。任何人都可以帮助我如何解决这个问题?
答案 0 :(得分:1)
您应该将您的服务添加到AIR应用程序描述符的android部分:
<application android:enabled="true">
<service android:name="com.example.demoservice.DemoService"/>
</application>