-1

I'm trying to launch a new activity from an Air Native Extension for Android function:

public FREObject call(FREContext context, FREObject[] args)
{

    try {
        Context contextApp = context.getActivity().getApplicationContext();

        Intent intent = new Intent(contextApp, DumbActivity.class);

        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        contextApp.startActivity(intent);

    }

The activity is launched successfully, but the MouseEvent.Click I added to the air app stage stopped working. I also tried to launched it using context.getActivity().startActivity(); same results.

UPDATE: Ok, so I understand I have to use the current activity. Problem is that I'm trying to use YouTube API to display the player. In many of their examples you need to extend an activity to use it.

So that's what I implemented to avoid using a new activity:

        playerView = new FrameLayout(activity.getApplicationContext());
        playerView.setId(R.id.player_view);

        playerFragment = YouTubePlayerFragment.newInstance();
        playerFragment.initialize(DeveloperKey.DEVELOPER_KEY, this);
        activity.getFragmentManager().beginTransaction().add(R.id.player_view, playerFragment).commit();

        container.addView(playerView, 640, 360);

It works OK when I launch it from native, but with the ANE, when I hit the play button on the player, it doesn't display the video, only sound.

With the separate activity the player worked fine but no Air interaction :\

mik
  • 799
  • 9
  • 31
  • Not sure I understand, are you trying to capture the mouse events `in` Air/ActionScript from a custom ANE started native activity? – SushiHangover Dec 10 '15 at 14:54
  • Your app got a Android Activity on top of it so it can't catche any interaction anymore. – BotMaster Dec 10 '15 at 15:51
  • Sushi: The ANE just displays a YouTubeAPI Activity. The actual clip does not occupy the rest of the screen, so I want to build an Air GUI around it. In another ANE that doesn't start a new activity the click/touch events of adobe air still work. – mik Dec 10 '15 at 17:24

2 Answers2

1

When you launch another Activity, that Activity will take over the input and occupy the entire screen.

If you are looking to keep functionality of the existing AIR application then you shouldn't launch another Activity but look into adding a View to the current Activity.

To add a View v, using LayoutParams params to the AIR application you can use something like the following:

ViewGroup fl = (ViewGroup)context.getActivity().findViewById(android.R.id.content);
fl.addView( v, params );
Michael
  • 3,776
  • 1
  • 16
  • 27
  • Have you got hardware acceleration enabled on your application? Manifest additions: – Michael Dec 11 '15 at 01:43
  • Added that. didn't help. The player is visible, the content is white. It's something with the activity or the way I define the player as it worked with a new activity (not same code though, as it was not suitable). Can't believe there isn't a way of display and interacting with the youtube player API and Air. :\ Frustrating. – mik Dec 11 '15 at 11:05
  • Any information in the device logs at all? I haven't tried the Youtube SDK in particular, but there's usually some helpful information in logcat. – Michael Dec 13 '15 at 22:17
0

Try this:

getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL, WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);

It work fine if you using Dialog Theme for your Activity

Januartha
  • 139
  • 2
  • 7