//xml配置<br style="word-wrap:break-word;">
&lt;receiver android:name=".AlarmReceiver"&gt;<br style="word-wrap:break-word;">
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;intent-filter&gt;<br style="word-wrap:break-word;">
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &lt;action android:name="android.intent.action.BOOT_COMPLETED" /&gt;<br style="word-wrap:break-word;">
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;/intent-filter&gt;<br style="word-wrap:break-word;">
&lt;/receiver&gt;<br style="word-wrap:break-word;">
&lt;uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /&gt;<br style="word-wrap:break-word;">
156 android 接收系统启动完毕的broadcast的权限<br style="word-wrap:break-word;">
&lt;uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /&gt;<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);&nbsp;<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();}&nbsp;<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);&nbsp;<br style="word-wrap:break-word;">
setContentView(videoView);&nbsp;<br style="word-wrap:break-word;">
videoView.setVideoURI(Uri.parse("/sdcard/1.3gp"));&nbsp;<br style="word-wrap:break-word;">
videoView.requestFocus();&nbsp;<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);&nbsp;<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){&nbsp;<br style="word-wrap:break-word;">
&nbsp; &nbsp;&nbsp; &nbsp;FileInputStream fIn = null;&nbsp;<br style="word-wrap:break-word;">
&nbsp; &nbsp;&nbsp; &nbsp;InputStreamReader isr = null;<br style="word-wrap:break-word;">
&nbsp;&nbsp;char[] inputBuffer = new char[255];&nbsp;<br style="word-wrap:break-word;">
&nbsp;&nbsp;String data = null;&nbsp;<br style="word-wrap:break-word;">
&nbsp;&nbsp;try{&nbsp;<br style="word-wrap:break-word;">
&nbsp;&nbsp;fIn = openFileInput("settings.dat");&nbsp;&nbsp;<br style="word-wrap:break-word;">
&nbsp; &nbsp;isr = new InputStreamReader(fIn);&nbsp;<br style="word-wrap:break-word;">
&nbsp; &nbsp; isr.read(inputBuffer);&nbsp;<br style="word-wrap:break-word;">
&nbsp; &nbsp; data = new String(inputBuffer);&nbsp;<br style="word-wrap:break-word;">
&nbsp; &nbsp; Toast.makeText(context, "Settings read",Toast.LENGTH_SHORT).show();&nbsp;<br style="word-wrap:break-word;">
&nbsp; &nbsp;}&nbsp;<br style="word-wrap:break-word;">
&nbsp; &nbsp; catch (Exception e) {&nbsp; &nbsp;&nbsp;<br style="word-wrap:break-word;">
&nbsp; &nbsp; e.printStackTrace();&nbsp;<br style="word-wrap:break-word;">
&nbsp; &nbsp;&nbsp;&nbsp;Toast.makeText(context, "Settings not read",Toast.LENGTH_SHORT).show();&nbsp;<br style="word-wrap:break-word;">
&nbsp; &nbsp;&nbsp;&nbsp;}&nbsp;<br style="word-wrap:break-word;">
&nbsp; &nbsp; finally {&nbsp;<br style="word-wrap:break-word;">
&nbsp;&nbsp;try {&nbsp;<br style="word-wrap:break-word;">
&nbsp; &nbsp;&nbsp; &nbsp; isr.close();&nbsp;<br style="word-wrap:break-word;">
fIn.close();&nbsp;<br style="word-wrap:break-word;">
} catch (IOException e) {&nbsp;<br style="word-wrap:break-word;">
e.printStackTrace();&nbsp;<br style="word-wrap:break-word;">
}&nbsp;<br style="word-wrap:break-word;">
}&nbsp;<br style="word-wrap:break-word;">
return data;&nbsp;<br style="word-wrap:break-word;">
}&nbsp;<br style="word-wrap:break-word;">
写:<br style="word-wrap:break-word;">
public void WriteSettings(Context context, String data){&nbsp;<br style="word-wrap:break-word;">
FileOutputStream fOut = null;&nbsp;<br style="word-wrap:break-word;">
OutputStreamWriter osw = null;&nbsp;<br style="word-wrap:break-word;">
try{&nbsp;<br style="word-wrap:break-word;">
fOut = openFileOutput("settings.dat",MODE_PRIVATE);&nbsp; &nbsp;<br style="word-wrap:break-word;">
&nbsp;&nbsp;osw = new OutputStreamWriter(fOut);&nbsp;<br style="word-wrap:break-word;">
&nbsp;&nbsp;osw.write(data);&nbsp;<br style="word-wrap:break-word;">
&nbsp; &nbsp;osw.flush();&nbsp;<br style="word-wrap:break-word;">
&nbsp; &nbsp;Toast.makeText(context, "Settings saved",Toast.LENGTH_SHORT).show();&nbsp;<br style="word-wrap:break-word;">
&nbsp; &nbsp;}&nbsp;<br style="word-wrap:break-word;">
&nbsp; &nbsp;catch (Exception e) {&nbsp;&nbsp;<br style="word-wrap:break-word;">
&nbsp; &nbsp;e.printStackTrace();&nbsp;<br style="word-wrap:break-word;">
&nbsp; &nbsp;Toast.makeText(context, "Settings not saved",Toast.LENGTH_SHORT).show();&nbsp;<br style="word-wrap:break-word;">
&nbsp; &nbsp;}&nbsp;<br style="word-wrap:break-word;">
&nbsp;&nbsp;finally {&nbsp;<br style="word-wrap:break-word;">
&nbsp; &nbsp;try {&nbsp;<br style="word-wrap:break-word;">

Prev | Next
Pg.: 1 ... 5 6 7 8 9 10 11 12


Back to home | File page

Subscribe | Register | Login | N