简体   繁体   English

android-如何以编程方式读取清单的意图?

[英]android - How to programmatically read manifest intents?

I'm trying to make a piece of code that will work across multiple apps. 我正在尝试编写一段可以在多个应用程序中使用的代码。 I can't figure out how to read this from within Java, though. 不过,我不知道如何从Java中读取此内容。 Is it possible without parsing the manifest manually? 是否可以不手动解析清单? I want to grab scheme1 and scheme2 out with a few lines of code. 我想用几行代码来获取scheme1和scheme2。

<activity android:name="urlHandlingBlah">
    <intent-filter>
        <action android:name="android.intent.action.VIEW"></action>
        <category android:name="android.intent.category.DEFAULT"></category>
        <category android:name="android.intent.category.BROWSABLE"></category>
        <data android:scheme="scheme1"></data>
        <data android:scheme="scheme2"></data>
    </intent-filter>
</activity>

Edit: I mean how would I use PackageManager to grab this info. 编辑:我的意思是我将如何使用PackageManager来获取此信息。 I don't care about the actual XML, per se. 我本身并不关心实际的XML。

No, this is not possible because once your app has been created everything gets converted to an APK, and that manifest is no longer readable at runtime. 不,这是不可能的,因为一旦创建了您的应用程序,所有内容都会转换为APK,并且该清单在运行时不再可读。 You can however read these properties interacting with the PackageManager though. 但是,您可以阅读与PackageManager交互的这些属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM