菜单的第二个"ITEM2"是“退出”,怎么给它写退出整个程序的代码,还有关闭正在播放的音乐,让程序内用MediaPlayer调用播放的音乐停止? 现在退出时音乐还在放。music.stop();貌似不能加在case里面啊?@Override
public boolean onOptionsItemSelected(MenuItem item) {
// TODO Auto-generated method stub
switch (item.getItemId()) {
case ITEM:
Intent intent = new Intent();
intent.setClass(this, mineDear.class);
startActivity(intent);
return true;
// break;
case ITEM2: break;
default:
break;
}
return true;
}
public boolean onOptionsItemSelected(MenuItem item) {
// TODO Auto-generated method stub
switch (item.getItemId()) {
case ITEM:
Intent intent = new Intent();
intent.setClass(this, mineDear.class);
startActivity(intent);
return true;
// break;
case ITEM2: break;
default:
break;
}
return true;
}
解决方案 »
- 怎么写一个动态的TabHost
- FM与音乐播放器问题
- Qt for android原理
- android CTS版本问题
- 为什么我的android sdk里面的add-ons文件夹为空?
- 关于SimpleAdapter的问题,求助。
- android微信分享ignore wechat app signature validation这个是不是签名错误啊
- android 文件上传
- 现在想来学习Android开发,请前辈推荐下开发工具和视频教程! 先感谢前辈了!
- 请教下类似百词斩的APP的大数据下载
- android快2年了,这个问题大家给个答案吧。。。
- android 机顶盒项目 请各位大侠 指点迷津,帮我找个方向
android.os.Process.killProcess(nPid);
finish();
System.exit(0);
int sdk_Version = android.os.Build.VERSION.SDK_INT;
if (sdk_Version >= 8) {
Intent startMain = new Intent(Intent.ACTION_MAIN);
startMain.addCategory(Intent.CATEGORY_HOME);
startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(startMain);
System.exit(0);
} else if (sdk_Version < 8) {
ActivityManager activityMgr = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
activityMgr.restartPackage(getPackageName());
}更多内容欢迎访问:http://dalvik.co.cc
if (sdk_Version >= 8) {
Intent startMain = new Intent(Intent.ACTION_MAIN);
startMain.addCategory(Intent.CATEGORY_HOME);
startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(startMain);
System.exit(0);
} else if (sdk_Version < 8) {
ActivityManager activityMgr = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
activityMgr.restartPackage(getPackageName());
}
更多内容欢迎访问:http://dalvik.co.cc
if (sdk_Version >= 8) {
Intent startMain = new Intent(Intent.ACTION_MAIN);
startMain.addCategory(Intent.CATEGORY_HOME);
startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(startMain);
System.exit(0);
} else if (sdk_Version < 8) {
ActivityManager activityMgr = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
activityMgr.restartPackage(getPackageName());
}
更多内容欢迎访问:http://dalvik.co.cc