-2

I am relatively new to android and currently I am working on a complicated project for which I need to complete a requirement. I am a little stuck here.

This is the in game activity for guest users after trial ends.

public class GuestUserActivity extends Activity {
public Button mMenuButton;
public Button mRegisterButton;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.guest_user_screen);

    mMenuButton = ( Button ) findViewById( R.id.Menu);
    mRegisterButton = ( Button ) findViewById( R.id.Register);

    mMenuButton.setOnClickListener(m_MenuClicked);
    mRegisterButton.setOnClickListener(m_RegisterClicked);
}

public View.OnClickListener m_MenuClicked = new View.OnClickListener() {

    public void onClick(View v) {

        Intent intent = new Intent ( getBaseContext(), MainMenuActivity.class);
        startActivity(intent);

    }
};


public View.OnClickListener m_RegisterClicked = new View.OnClickListener() {

    public void onClick(View v) {
      //What to write here?
    }
};
}

Corresponding Layout: enter image description here

So when the user clicks the register button. I want to launch a specific activity of another application.

Pranay Gupta
  • 73
  • 2
  • 12
  • You want to go into register activity after you click a button? If yes, here's it is for you http://stackoverflow.com/questions/11815224/moving-from-one-activity-to-another-in-android. – Yuva Raj Feb 13 '15 at 06:51
  • the two activities are not part of the same program. As mentioned, my main application launches another application which in my case is a game. So from a game activity mentioned I want to go to the launcher applications register activity. – Pranay Gupta Feb 13 '15 at 06:56

2 Answers2

1
Intent launchIntent = new Intent(Intent.ACTION_MAIN);
                launchIntent.addCategory(Intent.CATEGORY_LAUNCHER);
                ComponentName cp = new ComponentName("Your App Packge Name that Contains Register Activity", "Register Activity Name");
                launchIntent.setComponent(cp);

                startActivity(launchIntent);

I hope this will help you out.

Bob
  • 1,493
  • 1
  • 16
  • 28
0

So if I understand you properly, you want to start a different app from your app? If that is the case, try:

    Intent i;
    PackageManager manager = getPackageManager();
    try {
        i = manager.getLaunchIntentForPackage("app package name");
        if (i == null)
            throw new PackageManager.NameNotFoundException();
        i.addCategory(Intent.CATEGORY_LAUNCHER);
        startActivity(i);
    } catch (PackageManager.NameNotFoundException e) {

    }

You can find more details here

Community
  • 1
  • 1
Skynet
  • 7,522
  • 5
  • 40
  • 78
  • No, this I have already achieved. I have launched the application. Now I want to exit the launched app back to a previous app's specific activity. Which in my case is a registration page. – Pranay Gupta Feb 13 '15 at 07:18