《木雨音乐》 项目开发 参考自参考马剑威老师项目开发实践
(项目代码已经基本完成,粘贴代码为完整代码)
项目名称:音乐播放器(木雨音乐)
实现功能:
1、可实现本地音乐播放和在线音乐下载
2、播放列表控制
3、收藏喜欢的音乐及最近播放记录
4、播放界面显示歌词
5、删除列表歌曲和本地音乐
6、设置铃声
7、通知栏实现播放,下一曲,退出功能
8、启动页面
可能用到的第三方技术:
PagerSlidingTabStrip 、xUtils 、OpenLRC 、Jsoup 、Okhttp 等
开发环境:
windows10 64位操作系统
jdk-8u77-windows-x64.exe
android-studio-bundle-2.1.2-windows.exe
build.grade(Module:app) 如下:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.haoxue.zixueplayer"
minSdkVersion 17
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile project(':library:PagerSlidingTabStrip')
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:support-v4:23.4.0'
compile 'com.jiechic.library:xUtils:2.6.14'
compile 'org.jsoup:jsoup:1.9.2'
compile 'com.squareup.okhttp3:okhttp:3.4.1'
compile 'com.github.userswlwork:pull-to-refresh:1.0.0'
compile 'junit:junit:4.12'
}
因为我用的手机是华为手机,系统为android 6.0 ,
android6.0加强了对权限的管理,敏感权限都需要在程序运行时进行动态获取,
所以我暂时把
targetSdkVersion 23改为 targetSdkVersion 22 否则访问sd卡权限错误,也可以用下面方法解决:
在当前Activity中添加以下代码,代码的作用是检查是否已经获取到所需要的权限,如果没有则再次请求权限
// Check whether we have write permission int permission = ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE); if (permission != PackageManager.PERMISSION_GRANTED) { // We don't have permission so prompt the user ActivityCompat.requestPermissions( this, PERMISSIONS_STORAGE,//需要请求的所有权限,这是个数组String[] REQUEST_EXTERNAL_STORAGE//请求码 ); }详情请见: http://blog.csdn.net/dovar_66/article/details/51993145