I've an activity which has a meta data tag associated with it.
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data
android:name="type"
android:value="a" />
</activity>
At any point of time from my activity I need to know whether my activity is associated with the meta data tag of type 'a' or not. How to achieve this. I tried something like
Intent intent = mCurrentActivity.getIntent();
Bundle bundle = (intent != null) ? intent.getExtras() : null;
String value = (bundle != null) ? bundle.getString("type") : null;
but this is always returning me null not a
. Am I missing something here?
Use this for getting metadata:
ActivityInfo activityInfo = getPackageManager()
.getActivityInfo(getComponentName(), PackageManager.GET_META_DATA);
Bundle bundle = activityInfo.metaData;
String value = bundle.getString("type");