3

I'm trying to start and activity from a FREFunction to use facebooks's SSO on my flex application.

I did in my FREFunction:

    @Override
    public FREObject call(FREContext context, FREObject[] args) {
         Intent myIntent = new Intent(context.getActivity(), FacebookSSO.class);
         context.getActivity().startActivity(myIntent);
         return null;
    }

I get with logcat:

I/ActivityManager( 1322): Starting activity: 
Intent{ cmp=air.testapp/com.test.android.ane.activity.FacebookSSO } from pid...

But my log calls in the onCreate method of are FacebookSSO.java are not displayed:

 @Override
 public void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);
     //setContentView(R.layout.main);
     Log.d("FacebookSSO", "onCreate BEGIN.");
     Log.d("FacebookSSO", "onCreate END.");
 }

I tried creating myIntent in different ways, like using setClass. What am I doing wrong?

Melladric
  • 81
  • 3
  • 8
  • Have you figured this out by any chance? I am trying to do the exact same thing. Though, I am running through Flash Builder, so I actually don't know how to get any Logcat information as it seems to connect to a Flash debugger only. – Tylo May 23 '12 at 16:15
  • Nope. Trying to do it from scratch cause this project does the same thing and it worked for me: http://blog.immanuelnoel.com/2011/12/07/new-actionscript-native-extension-speech-recognition/ – Melladric May 24 '12 at 17:44
  • Damn. Yes I noticed that project too. I tried their method of making a SpeechHandler Activity, but I think they did that as some kind of work around for starting the true speech activity with a return result. Sadly I couldn't get the SpeechHandler to spawn my Activity either. Let me know if you get it working. – Tylo May 25 '12 at 15:02
  • It's working. Like I said I did it from scratch, after importing the Speech project on my own and displaying its string result in my application label... I really have no clue what might have been. But one of the things I neglected was registering the activity on my Flex's manifest and NOT only on the original android manifest. – Melladric May 28 '12 at 18:54
  • 1
    Sadly I had done both, and it still never worked. – Tylo Jun 01 '12 at 14:06

2 Answers2

1

Did you solve this problem?

Have you tried adding the class into the manifest additions in your application descriptor?

<android>
    <manifestAdditions><![CDATA[
        <manifest android:installLocation="auto">
            <uses-permission android:name="android.permission.INTERNET"/>
            <application>
                <activity android:name="com.test.android.ane.activity.FacebookSSO"></activity>
            </application>
        </manifest>
    ]]></manifestAdditions>
</android>
Michael
  • 3,776
  • 1
  • 16
  • 27
0

The Intent constructor you are using is expecting a Context as its parameter (remember that Activity is a Context also.)

Because the constructor is expecting a Context and you are starting with a context there should be no need to call getActivity(). Also startActivity() is a method of Context, So you shouldn't need the getActivity() in the second line either. However I don't know if that would result in the error you are seeing.

Try your code this way:

Intent myIntent = new Intent(context, FacebookSSO.class);
context.startActivity(myIntent);
FoamyGuy
  • 46,603
  • 18
  • 125
  • 156
  • Thank you for the answer. But that won't work cause context is of type FREContext which means undefined constructor error. Is any sort of cast possible? – Melladric May 22 '12 at 21:19
  • Ahh, sorry I got nothing then. Am not familiar with the Air platform, didn't realize it had its own version of Context. – FoamyGuy May 22 '12 at 21:26