以编程方式读取android:scheme的值

时间:2023-01-18 09:04:12

I want to know if it is possible to read the value of android:scheme from the Android-manifest-file (example below) programmatically.

我想知道是否可以通过编程方式从Android-manifest-file(下面的示例)中读取android:scheme的值。

<intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="zxtest" />
    </intent-filter>

Thanks and Regards, Sascha

谢谢和问候,Sascha

2 个解决方案

#1


0  

I'm assuming you mean that the intent has been called and you're trying to find the scheme from your activity's code?

我假设你的意思已被调用,你试图从你的活动代码中找到该方案?

In your activity's onCreate method, you can do the following:

在您的活动的onCreate方法中,您可以执行以下操作:

Intent intent = getIntent();
Uri data = intent.getData();
String scheme = data.getScheme(); // "zxtest"

#2


0  

You should be able to get this information from the PackageManager:

您应该能够从PackageManager获取此信息:

PackageManager pm = getPackageManager();
ActivityInfo activityInfo = pm.getActivityInfo(component,
        PackageManager.GET_INTENT_FILTERS);

#1


0  

I'm assuming you mean that the intent has been called and you're trying to find the scheme from your activity's code?

我假设你的意思已被调用,你试图从你的活动代码中找到该方案?

In your activity's onCreate method, you can do the following:

在您的活动的onCreate方法中,您可以执行以下操作:

Intent intent = getIntent();
Uri data = intent.getData();
String scheme = data.getScheme(); // "zxtest"

#2


0  

You should be able to get this information from the PackageManager:

您应该能够从PackageManager获取此信息:

PackageManager pm = getPackageManager();
ActivityInfo activityInfo = pm.getActivityInfo(component,
        PackageManager.GET_INTENT_FILTERS);