I want to set app meta data using code. Is it possible in Android ? Trying to set Facebook app id into code not inside manifest.
meta-data android:name=\"co
for add any metadata dynamically you can use this code:
try {
ApplicationInfo applicationInfo = getPackageManager().getApplicationInfo(getPackageName(), PackageManager.GET_META_DATA);
applicationInfo.metaData.putString("Your Key", "Your Value");
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
Hello all i know above answer is right for older sdk version, but in
facebook sdk 4+
there is no Session class
You can simply do it by using this single line code:
FacebookSdk.setApplicationId(APP_ID);
Thanks!
I want to set app meta data using code.Is it possible in android ?
No, it's not possible. The manifest get's parsed at compile time -> you can't add meta-data at runtime.