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。任何人都可以帮助我如何解决这个问题?