//xml配置<br style="word-wrap:break-word;">
<receiver android:name=".AlarmReceiver"><br style="word-wrap:break-word;">
<intent-filter><br style="word-wrap:break-word;">
<action android:name="android.intent.action.BOOT_COMPLETED" /><br style="word-wrap:break-word;">
</intent-filter><br style="word-wrap:break-word;">
</receiver><br style="word-wrap:break-word;">
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /><br style="word-wrap:break-word;">
156 android 接收系统启动完毕的broadcast的权限<br style="word-wrap:break-word;">
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /><br style="word-wrap:break-word;">
157 android 多媒体录制<br style="word-wrap:break-word;">
MediaRecorder recorder = new MediaRecorder();<br style="word-wrap:break-word;">
recorder.setVideoSource(MediaRecorder.VideoSource.CAMERA); //视频<br style="word-wrap:break-word;">
recorder.setAudioSource(MediaRecorder.AudioSource.MIC); //音频<br style="word-wrap:break-word;">
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP); <br style="word-wrap:break-word;">
recorder.setOutputFile("/sdcard/media/1.3gp");<br style="word-wrap:break-word;">
try {<br style="word-wrap:break-word;">
recorder.prepare();<br style="word-wrap:break-word;">
} catch (IllegalStateException e) {e.printStackTrace();} <br style="word-wrap:break-word;">
catch (IOException e) {e.printStackTrace();}<br style="word-wrap:break-word;">
recorder.start();<br style="word-wrap:break-word;">
158 android 视频播放<br style="word-wrap:break-word;">
VideoView videoView = new VideoView(this); <br style="word-wrap:break-word;">
setContentView(videoView); <br style="word-wrap:break-word;">
videoView.setVideoURI(Uri.parse("/sdcard/1.3gp")); <br style="word-wrap:break-word;">
videoView.requestFocus(); <br style="word-wrap:break-word;">
videoView.start();<br style="word-wrap:break-word;">
159 android 绘制文字<br style="word-wrap:break-word;">
canvas.drawText(str, 30, 30, paint); <br style="word-wrap:break-word;">
160 android 判断QWERTY键盘硬件是否滑出<br style="word-wrap:break-word;">
Configuration config = getResources().getConfiguration();<br style="word-wrap:break-word;">
if(config.hardKeyboardHidden == Configuration.KEYBOARDHIDDEN_NO)<br style="word-wrap:break-word;">
{}<br style="word-wrap:break-word;">
else if(config.hardKeyboardHidden == Configuration.KEYBOARDHIDDEN_YES)<br style="word-wrap:break-word;">
{}<br style="word-wrap:break-word;">
161 android 清除手机cookie<br style="word-wrap:break-word;">
CookieSyncManager.createInstance(getApplicationContext());<br style="word-wrap:break-word;">
CookieManager.getInstance().removeAllCookie();<br style="word-wrap:break-word;">
162 android 读写文件<br style="word-wrap:break-word;">
读:<br style="word-wrap:break-word;">
public String ReadSettings(Context context){ <br style="word-wrap:break-word;">
FileInputStream fIn = null; <br style="word-wrap:break-word;">
InputStreamReader isr = null;<br style="word-wrap:break-word;">
char[] inputBuffer = new char[255]; <br style="word-wrap:break-word;">
String data = null; <br style="word-wrap:break-word;">
try{ <br style="word-wrap:break-word;">
fIn = openFileInput("settings.dat"); <br style="word-wrap:break-word;">
isr = new InputStreamReader(fIn); <br style="word-wrap:break-word;">
isr.read(inputBuffer); <br style="word-wrap:break-word;">
data = new String(inputBuffer); <br style="word-wrap:break-word;">
Toast.makeText(context, "Settings read",Toast.LENGTH_SHORT).show(); <br style="word-wrap:break-word;">
} <br style="word-wrap:break-word;">
catch (Exception e) { <br style="word-wrap:break-word;">
e.printStackTrace(); <br style="word-wrap:break-word;">
Toast.makeText(context, "Settings not read",Toast.LENGTH_SHORT).show(); <br style="word-wrap:break-word;">
} <br style="word-wrap:break-word;">
finally { <br style="word-wrap:break-word;">
try { <br style="word-wrap:break-word;">
isr.close(); <br style="word-wrap:break-word;">
fIn.close(); <br style="word-wrap:break-word;">
} catch (IOException e) { <br style="word-wrap:break-word;">
e.printStackTrace(); <br style="word-wrap:break-word;">
} <br style="word-wrap:break-word;">
} <br style="word-wrap:break-word;">
return data; <br style="word-wrap:break-word;">
} <br style="word-wrap:break-word;">
写:<br style="word-wrap:break-word;">
public void WriteSettings(Context context, String data){ <br style="word-wrap:break-word;">
FileOutputStream fOut = null; <br style="word-wrap:break-word;">
OutputStreamWriter osw = null; <br style="word-wrap:break-word;">
try{ <br style="word-wrap:break-word;">
fOut = openFileOutput("settings.dat",MODE_PRIVATE); <br style="word-wrap:break-word;">
osw = new OutputStreamWriter(fOut); <br style="word-wrap:break-word;">
osw.write(data); <br style="word-wrap:break-word;">
osw.flush(); <br style="word-wrap:break-word;">
Toast.makeText(context, "Settings saved",Toast.LENGTH_SHORT).show(); <br style="word-wrap:break-word;">
} <br style="word-wrap:break-word;">
catch (Exception e) { <br style="word-wrap:break-word;">
e.printStackTrace(); <br style="word-wrap:break-word;">
Toast.makeText(context, "Settings not saved",Toast.LENGTH_SHORT).show(); <br style="word-wrap:break-word;">
} <br style="word-wrap:break-word;">
finally { <br style="word-wrap:break-word;">
try { <br style="word-wrap:break-word;">
Back to home |
File page
Subscribe |
Register |
Login
| N