Giter Site home page Giter Site logo

Comments (9)

mikemee avatar mikemee commented on June 26, 2024 1

There's nothing special here. It's all standard Android. E.g. you can use standard Android style menus for the launch button, e.g. something like this to setup the menu item (with icon etc):

        MenuInflater menuInflater = activity.getMenuInflater();
        menuInflater.inflate(R.menu.about_screen_menu, menu);

and then launch it with:

            case R.id.open_about:
                AboutActivity.launch(activity);
                return true;

from android-about-box.

mikemee avatar mikemee commented on June 26, 2024 1

@Kvaibhav01 I'm afraid these are Android programming questions and really don't have much to do with this library. I'd love to help more, but there are plenty of references for this elsewhere. Good luck!

from android-about-box.

mikemee avatar mikemee commented on June 26, 2024 1

I setup AboutActivity in the initial app startup. Then, later in the app, I access it. That way, it's all configured and ready to go.

I.e. like this:

public class LogicApp extends android.app.Application {
....
   @Override
    public void onCreate() {
        super.onCreate();
...

        initAboutBox();
     }
...
    public void initAboutBox() {
        final AboutConfig aboutConfig = AboutConfig.getInstance();
        aboutConfig.appName = getString(R.string.app_name);
        aboutConfig.appIcon = R.mipmap.ic_launcher;
        aboutConfig.version = BuildConfig.VERSION_NAME + " (" + BuildConfig.VERSION_CODE + ")";
        aboutConfig.aboutLabelTitle = getString(R.string.about_egghead_games);
        aboutConfig.packageName = getApplicationContext().getPackageName();
        aboutConfig.buildType = "google".equalsIgnoreCase(BuildConfig.FLAVOR_appstore)
                ? AboutConfig.BuildType.GOOGLE : AboutConfig.BuildType.AMAZON;

        aboutConfig.logUiEventName = LOG_UI_EVENT_NAME;
        aboutConfig.facebookUserName = FACEBOOK_USER_NAME;
        aboutConfig.twitterUserName = TWITTER_USER_NAME;
        aboutConfig.webHomePage = WEB_HOME_PAGE;
        aboutConfig.appPublisher = APP_PUBLISHER;
        aboutConfig.guideHtmlPath = GUIDE_HTML_PATH;
        aboutConfig.companyHtmlPath = COMPANY_HTML_PATH;
        aboutConfig.privacyHtmlPath = PRIVACY_HTML_PATH;
        aboutConfig.acknowledgmentHtmlPath = ACKNOWLEDGMENT_HTML_PATH;

        aboutConfig.emailAddress = EMAIL_ADDRESS;
        aboutConfig.emailSubject = getResources().getString(R.string.app_name) + " Question";
        aboutConfig.emailBody = "";
        aboutConfig.shareMessage = getString(R.string.share_message);
        aboutConfig.sharingTitle = getString(R.string.sharing_title);

        aboutConfig.dialog = new IDialog() {
            @Override
            public void open(AppCompatActivity appCompatActivity, String url, String tag) {
                GuideDialog guideDialog = GuideDialog.createDialog(url, tag, true);
                guideDialog.show(appCompatActivity.getSupportFragmentManager(), tag);
            }
        };
    }

And then I can call it with the code I shared above, i.e.

AboutActivity.launch(activity);

Hope this helps!

from android-about-box.

mikemee avatar mikemee commented on June 26, 2024 1

Take a look at the source code, after you've setup with AboutConfig as shown above, you need to call AboutActivity.launch(yourActivity). This code that is already in the library will then do what you're doing above:

    public static void launch(Activity activity) {
        Intent intent = new Intent(activity, AboutActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
        activity.startActivity(intent);
    }

See https://github.com/eggheadgames/android-about-box/blob/master/library/src/main/java/com/eggheadgames/aboutbox/activity/AboutActivity.java

from android-about-box.

mikemee avatar mikemee commented on June 26, 2024 1

after you've setup with AboutConfig as shown above, you need to call AboutActivity.launch(yourActivity)

Sorry, I didn't mean immediately call AboutActivity.launch.

In the app startup, ONLY do the configuration. Later, when they tap the button, THEN call ``AboutActivity.launch(activity)`.

I.e. it is two separate things: configure at app startup, then launch when the user requests it.

Good luck!

from android-about-box.

Kvaibhav01 avatar Kvaibhav01 commented on June 26, 2024 1

It's done! 😃 I removed AboutActivity.launch from onCreate() and added the following in onOptionsItemSelected():

if (id == R.id.action_about) {
            Intent intent = new Intent(this, AboutActivity.class);
            startActivity(intent);
            return true;
        }

Everything works fine now! Thank you 😃.

from android-about-box.

Kvaibhav01 avatar Kvaibhav01 commented on June 26, 2024

Thank you for that but I'm a bit confused here.

  1. Do I need to create a new java file for implementing this? (It will contain all the code from the setup part).
  2. How do I add an icon for this in my menu bar?

from android-about-box.

Kvaibhav01 avatar Kvaibhav01 commented on June 26, 2024

So I added the relevant code to do this as:

  1. Added a new <item> in menu.xml
  2. Copied all the code of this library to a new java file named AboutActivity.java
  3. Added the following code in my MainActivity.java file in onOptionsItemSelected method:
if (id == R.id.action_about) {
            Intent intent = new Intent(this, AboutActivity.class);
            startActivity(intent);
            return true;
        }
  1. Updated the manifest by:

<activity android:name=".AboutActivity"></activity>

But when I run the app on emulator, it shows up the following screen when the action_about icon is tapped:

alt text

I have already added more informations like acknowledgements, privacy policy et cetera but it's showing something weird!

from android-about-box.

Kvaibhav01 avatar Kvaibhav01 commented on June 26, 2024

Everything is going good, I implemented the above. One thing, every time I open the app the about activity launches instead of main activity. How to solve this? I don't wan't my app users to see the about page every time they open the app, it's quite annoying.

from android-about-box.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.