Android:meta-data

meta-data用于定义组件的元信息,在程序中可以获取

Android:meta-data_第1张图片


ActivityInfo activityInfo = this.getPackageManager().getActivityInfo(

                    new ComponentName(this, MainActivity.class), PackageManager.GET_META_DATA);
            Bundle bundle = activityInfo.metaData;
            String name = bundle.getString("cn.itcast.name");
            String app = bundle.getString("cn.itcast.app");
            int age = bundle.getInt("cn.itcast.age");
            int sourceid = bundle.getInt("cn.itcast.id");
            
            Toast.makeText(this, "name="+ name+ ",age="+ age
                    + ",app="+ app+ ",sourceid="+ sourceid, 1).show();

你可能感兴趣的:(Android:meta-data)