disable the intent filter from android manifest programmatically

后端 未结 4 679
粉色の甜心
粉色の甜心 2020-12-16 22:27

In my activity I have a web view and in manifest.xml I have declared intent filter like this

 

        
4条回答
  •  孤城傲影
    2020-12-16 23:07

    This i achieved but faced issues when upgraded my app to Marshmallow support.

    Dynamically you can't remove the IntentFilter from the Manifest Components.

    If you are working on Marmalade/Native languages like C & C++(NDK), You can achieve disable the IntentFilter components but after platform upgrade(like Kitkat to LollyPop) it gives problem.

    This changes is not recommended by android community in any of the developer.android.com pages.

    One Solution could be,

      String packageName = getPackageName();
        try {
            PackageInfo p = getApplicationContext().getPackageManager().getPackageInfo(packageName, PackageManager.GET_ACTIVITIES);
            for (ActivityInfo activityInfo : p.activities) {
                if(log.d()) log.d("ACT " + activityInfo.name+" "+activityInfo.packageName);
            }
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
    

    Go with alias from the code "alias"

    ComponentName componentWithoutTextFiles = new ComponentName(packageName, packageName".alias");

提交回复
热议问题