Pergunta

I have an ANE (Adobe Native Extension) auto launched after BOOT_COMPLETED. It runs as a service listening for phone status changes. Everything works fine until I need bring the main AIR activity to front to get user input. I know how to get the context from the service but not the FREContext. I have tried this:

    myANEContextClass myANEContext = new myANEContextClass ();
    Activity myAIRActivity = myANEContext .getActivity();
    Intent in = new Intent(myAIRActivity,myAIRActivity.getClass()); 
    in.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);

but it is not working and I am getting error :

E/AndroidRuntime( 3451): java.lang.UnsatisfiedLinkError: Native method not found: com.adobe.fre.FREContext.getActivity:()Landroid/app/Activity;

E/AndroidRuntime( 3451): at com.adobe.fre.FREContext.getActivity(Native Method)

But I think the process is there because later I get :

I/ActivityManager( 368): Process air.myANEApp (pid 3451) (adj 5) has died.

so must be a way to get the FREContext from the process

Foi útil?

Solução

To make it a bit more generic you should use something like the following:

PackageManager pm = context.getPackageManager();
Intent mainAppIntent = pm.getLaunchIntentForPackage( context.getPackageName() );
mainAppIntent.addFlags( Intent.FLAG_ACTIVITY_REORDER_TO_FRONT );
context.startActivity( mainAppIntent );

This way it pulls the package from the context, which should be the application that the ANE is packaged in. So that it will launch the application that the ANE was packaged in rather than the hardcoded application.

Outras dicas

I solved it re-launching the application like this:

 Intent in = arg0.getPackageManager().getLaunchIntentForPackage("air.myANEApp");
 in.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT
            |Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT
            |Intent.FLAG_ACTIVITY_NEW_TASK);

 arg0.startActivity(in)

I don't think you should be creating the Extension class on your own. There's someone here dealing with the same issue apparently but the solution looks a bit more safe/clear ...

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top