Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8560163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:12:55+00:00 2026-06-11T16:12:55+00:00

Consider this code snippet that prompts the user to rate the app on the

  • 0

Consider this code snippet that prompts the user to rate the app on the market:

private void backToMainActivity() {
    Intent i = new Intent(mActivity, MainActivity.class);
    i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    mActivity.startActivity(i);

    mActivity.finish();
}

...

if (mRateToast.leftClicked(x, y)) {
    setRate(true);

    Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + GameGlobals.PACKAGE_NAME));
    i.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET | Intent.FLAG_ACTIVITY_NEW_TASK);
    mActivity.startActivity(i);

    backToMainActivity();
} else if (mRateToast.rightClicked(x, y)) {
    setRate(false);
    backToMainActivity();
}

What this does is detect what button was pressed (Rate or Later), set a flag accordingly and run the market app if needed. No matter which button is pressed, I want to return to the main menu (this is a game activity, 1 activity away from the main menu activity).

On Android 4.1, this works fine – the market opens to the app’s page, and on return from the market, I am on the main menu. On android <= 2.3, the market does not open, I am just returned directly to the main menu. It does, however, open if I comment the i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); in the backToMainActivity method. This causes other problems though, such as the back button going back to the wrong activity instead of exiting the app, so is not a solution.

How can I run the market, return to main menu and have the main menu activity be at the top of the activity stack?

Note: I haven’t tried it, but removing the finish is also not really an option. My game activity can also be started by external applications directly, and in that case, if I remove the finish call, for some reason CLEAR_TOP will not work, and pressing the back button on the main menu activity will return to the game activity instead of exiting the application.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T16:12:56+00:00Added an answer on June 11, 2026 at 4:12 pm

    I solved this by removing Intent.FLAG_ACTIVITY_NEW_TASK and using startActivityForResult as described by MoshErsan in his answer. Apparently starting the market as a new task does not play well with CLEAR_TOP in android <= 2.3.

    If someone can explain why the original approach wasn’t working or offer a better solution, I will accept that answer in one or two days, if not I will accept mine.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider the following code snippet private void ProcessFile(string fullPath) { XmlTextReader rdr = new
Consider this code snippet: class MyClass{ private List myList; //... public List getList(){ return
Consider this code snippet: public static class ApplicationContext { private static Func<TService> Uninitialized<TService>() {
consider this code snippet void make(int n) { std::string user_input; std::istringstream iss(user_input); char letter;
Consider this code snippet: public static void main(String[] args) { int z1 = 0;
Consider the following code snippet that takes user input (a date) and format it
Consider this snippet of code: public static class MatchCollectionExtensions { public static IEnumerable<T> AsEnumerable<T>(this
Consider this code: new Ajax.Request('?service=example', { parameters : {tags : 'exceptions'}, onSuccess : this.dataReceived.bind(this)
Consider this code: public <T> List<T> meth(List<?> type) { System.out.println(type); // 1 return new
Consider this code: int main() { int e; prn(e); return 0; } void prn(double

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.