android 获取本地图片或音乐

public void getLoaclBackPicAndMu(int kind_type, int requestCode) {
		
		Intent intent = new Intent();
		/* 开启Pictures画面Type设定为image */
		if (kind_type == 1)
			intent.setType("audio/*");
		else
			intent.setType("image/*");
		/* 使用Intent.ACTION_GET_CONTENT这个Action */
		intent.setAction(Intent.ACTION_GET_CONTENT);
		/* 取得相片后返回本画面 */
		startActivityForResult(intent, requestCode);
	}

	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		
		if (resultCode == RESULT_OK) {
			Uri uri = data.getData();
			Log.i("W" ,"uri: "+ uri.toString());

		}
		super.onActivityResult(requestCode, resultCode, data);
	}

 

你可能感兴趣的:(android)