0

How can I open a dialog with some html formatting and hypertext link support (open that link in default browser), when I click on item: "ABOUT" in my dynamically created menu? Also, how I can make SHARE function, so that if anybody click on: "SHARE" item, it will either share link to that APK, or send it over bluetooth?

This is what I have in MainActivity:

private static final int NEW_MENU_ID=Menu.FIRST+1;
@Override
    public boolean onCreateOptionsMenu(Menu menu) {
        super.onCreateOptionsMenu(menu);

        menu.add(0, NEW_MENU_ID, 0, "ABOUT");
        menu.add(0, NEW_MENU_ID, 0, "SHARE");

        return true;
    }

And this is how it should look like: template

Thanks for help!

Wroclai
  • 26,835
  • 7
  • 76
  • 67
Martin Eliáš
  • 387
  • 1
  • 5
  • 11

2 Answers2

1

Actually, there's two big and completely different questions and too little code presented.

First of all You should give different options id in onCreateOptionsMenu (let them be ID_ABOUT == 0 and ID_SHARE == 1) override onOptionsItemSelected() like this:

@Override
public boolean onOptionsItemSelected (MenuItem item) {
    switch(item.getItemId()) {
    case ID_ABOUT:
        handleAbout();
        break;

    case ID_SHARE:
        handleShare();
        break;
    }
}

No handleAbout() and handleShare() should be defined (that's your questions about):

  • ABOUT: probably, the easiest way is to create additional activity which would contain only one WebView. First activity would just start AboutActivity from handleAbout();
  • SHARE: it's quite common task. Please, refer to android documentation here and for example, to this question
Community
  • 1
  • 1
sandrstar
  • 12,503
  • 8
  • 58
  • 65
1
1. how could I open dialog with some html formatting and hypertext link support (open that link in default browser), when I click on item: "ABOUT" in my dynamically created menu?

Look at this SO Question: Android hyperlinks on TextView in custom AlertDialog not clickable

2. how I can make SHARE function, so that if anybody click on: "SHARE" item, it will either share link to that APK, or send it over bluetooth?

Use Android Intent with Intent.ACTION_SEND. Which will share the link of .apk file on available application on device which handle SHARE Intent.

and to send APK via Bluetooth .. either use same Intent with ACTION_SEND action or You have to implement Bluetooth file transfer code..

Look at this SO Question: bluetooth file transfer in android

Community
  • 1
  • 1
user370305
  • 108,599
  • 23
  • 164
  • 151