robert_hly

踩坑填坑记录...

导航

android 获取Asset中Properties文件配置的键值对

1 获取 AssetManager

   AssetManager assetManager =  context.getApplicationContext().getAssets();

2 获取流

    String confFile = "abc.properties";

    Properties conf = new Properties();

    InputStream stream = assetManager.open(confFile);

    conf.load(new InputStreamReader(stream, "utf-8"));

3 属性值键值对获取

   String key1Value  =  conf.getProperty("key1");

  

 

音频文件 一般放在 res/raw下

 

1 获取音频管理者  

    AudioManager am = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);

2 MediaPlayer

    MediaPlayer player = MediaPlayer.create(context,R.raw.sound1);

    player.setLooping(false);//不循环播放

    player.start();//开始播放

    player.release();//在合适的地方调用 释放资源

 

posted on 2017-03-04 08:35  robert_hly  阅读(331)  评论(0)    收藏  举报