代码改变世界

android学习笔记

2014-11-20 13:10  anjsoft  阅读(156)  评论(0编辑  收藏  举报

db shell dmesg  会打印出内核的调试信息

可以设置任意的端口号,做为主机向模拟器或设备的请求端口。如:

adb forward tcp:5555 tcp:8000

adb bugreport

db shell logcat -b radio  记录无线通讯日志 

db get-product   adb get-serialno 设备ID和序列号

db shell sqlite3

Bitmap myBmp= BitmapFactory.decodeResource() 

myBmp.getHeight()/getWidth() ;//获取图片高和宽

xImageView.setImageDrawble(getResources().getDrawable(R.drawable.xxx);//设置图片给imageView

getResources().getString(R.string.xxx);//取字符串

requestWindowFeature(Window.FEATURE_NO_TITLE);//设置全屏

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);//设置全屏

new Date(System.currentTimeMillis()); //系统时间

am = (AudioManager)getSystemService(Content.AUDIO_SERVICE);

volume= am.getStreamVolume(AudioManager.STREAM_RING);//声音大小

xxProgress.setProgress(volume);

am.setRingerMode(AudioManager.RINGER_MODE_SILENT);//静音

am.adjustVolume(AudioManager.ADJUST_LOWER,0);//设置音量调小格 ADJUST_RAISE 调大

* 播放MP3

mp = new MediaPlayer();

mp = MediaPlayer.create(xx.this,R.raw.xxx);

mp.prepare();

mp.start();stop() pause();

*录音机

Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED); //sdcard是否存在

myRecAudioDir = Environment.getExternalStorageDirectory();//sdcard目录

myRecAudioFile = File.creaetTempFile(strTempFile,".amr",myRecAudioDir);//创建录音文件

mr = new MediaRecorder();

mr.setAudioSource(MediaRecorder.AudioSource.MIC);

mr.setOutputFormat(MediaRecorder.OutputFormat.DEFAULT);

mr.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT);

mr.setOutputFile(mRecAudioFile.getAbsolutePath());

mr.prepare();

mr.start(); stop ;release();

*拍照

*视频播放

ViewView 

*优化

<merge/>

Runtime.getRuntime().totalMemory();

Runtime.getRuntime().freeMemory();