• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Android [SOLVED] startActivity (Java) not running

A

AMAAAAAR

Guest
EDIT: I succeeded! All I had to do was change
startActivity(intent)
to
RunnerActivity.CurrentActivity.startActivity(intent)
I hope this helps others who get stuck on this.


I'm trying to create an Android extension that allows the user to share their score.
I found this code online, and put it in a Java extension. Here is the function:
Code:
public void share(String str)
    {
        Intent sendIntent = new Intent();
        sendIntent.setAction(Intent.ACTION_SEND);
        sendIntent.putExtra(Intent.EXTRA_TEXT, str);
        sendIntent.setType("text/plain");
        startActivity(sendIntent);
    }
The problem is that when the code gets to the startActivity line, it doesn't run and this appears in the log:
Can't find method on external class:null
When I put this code into an Android app (not with gamemaker, with AIDE (an android IDE)), it worked perfectly.
Can someone who is experienced in making Android extensions with Java help me please? Does anyone have the function startActivity working at all?
 
Last edited by a moderator:

kamiyasi

Member
How are you calling the java code? When you import the .js file under extentions, you have to right click it and add a call event that points to the function in the javascript you want to run.
 
A

AMAAAAAR

Guest
Well, somehow hours of googling yesterdey didn't help, but a quick google today told me how to fit it.
What I needed to do was add
RunnerActivity.CurrentActivity.
infront of my
startActivity
A quick fix, but it was hard to find. I'll edit my first post so if anyone else ever has this problem they'll know what to do.
 
Top