1

First thing, sorry for my bad English.

I got the APP that can open a web browser when this APP get starts up.

When app executes at the first time, it will ask user to choose whether the user want to start up by Chrome or Firefox or any other applications. And this APP will remember user's choice. Next time when user comes app will open the application which user has selected.

So here's the problem, this app can't work in Firefox, so I have to remove Firefox in the start up list, prevent that Firefox get choose by the user when it start up in the first time.

before:

=============================
You want to start up this app with?
・chrome
・firefox
・browser
=============================

after:

=============================
You want to start up this app with?
・chrome
・browser
=============================

Is it possible that I can just put some source code in this app to customize the start up list instead of changing all the start up setting in the smartphone? Because I don't want to effect other APP in the same device. And also I don't want to remove Firefox in the device.

If so, could anyone kindly tell me which method should I edit? Appreciate for your help.

Hardik Trivedi
  • 5,677
  • 5
  • 31
  • 51
Kaz
  • 165
  • 1
  • 8
  • Yes its possible but the problem is you have to gether all the supported browsers Package name and check in device whether app is installed or not. If its installed then show it in that list if not then just don't show it. And at this place you can bypass the firefox issue. – Harsh Patel Sep 29 '17 at 04:12
  • Possible duplicate of https://stackoverflow.com/q/18682833/5846135 – Zeero0 Sep 29 '17 at 04:13
  • @BabulPatel Thanks for your comment! This helped me a lot! But can you tell me the method name or where should I found this setting ? – Kaz Sep 29 '17 at 04:16
  • @Zeero0 Thanks a lot ! I will check it. – Kaz Sep 29 '17 at 04:18

1 Answers1

0

So here's my way to solve it by checking these answers:

How to exclude a specific application from ACTION_VIEW Intent?

Is it possible to hide some application in Intent AppChooser?

Iterating through a Collection, avoiding ConcurrentModificationException when removing in loop

before:

    private String mUri = "http://www.google.com";
    Intent catchIntent = getIntent();
    String uri = catchIntent.getStringExtra(Const.INTENT_TRANSITION_URL);
    mUri = uri;   
    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(mUri));
    intent.addCategory(Intent.CATEGORY_BROWSABLE);
    infoList = getPackageManager()
            .queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);

after:

    private String mUri = "http://www.google.com";
    Intent catchIntent = getIntent();
    String uri = catchIntent.getStringExtra(Const.INTENT_TRANSITION_URL);
    mUri = uri;   
    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(mUri));
    intent.addCategory(Intent.CATEGORY_BROWSABLE);
    infoList = getPackageManager()
            .queryIntentActivities(intent, 
PackageManager.MATCH_DEFAULT_ONLY);
    String excludeApplicationName = "org.mozilla.firefox";
    for(Iterator<ResolveInfo> iterator = infoList.iterator(); iterator.hasNext();){
        String string = iterator.next().activityInfo.packageName;
        if(string.equals(excludeApplicationName)){
            iterator.remove();
        }
    }

I just simply get all the list of application that can open the URL, and remove firefox from the list by using iterator. Thanks for all your help!

Kaz
  • 165
  • 1
  • 8