Time of Update: 2018-12-06
在Android群裡,經常會有人問我,Android Log是怎麼用的,今天我就把從網上以及SDK裡東拼西湊過來,讓大家先一睹為快,希望對大家入門Android Log有一定的協助.android.util.Log常用的方法有以下5個:Log.v() Log.d() Log.i() Log.w() 以及 Log.e() 。根據首字母對應VERBOSE,DEBUG,INFO, WARN,ERROR。1、Log.v
Time of Update: 2018-12-06
main.xml <?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"
Time of Update: 2018-12-06
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); findViewById(R.id.button1).setOnClickListener(new Button.OnClickListener() {
Time of Update: 2018-12-06
1.使用VedioView VideoView videoView = (VideoView)findViewById(R.id.video); String src = "rtsp://v6.cache7.c.youtube.com/CjYLENy73wIaLQlSNwWysTZuKRMYESARFEIJbXYtZ29vZ2xlSARSBXdhdGNoYP6mvvezrYeZTgw=/0/0/0/video.3gp";
Time of Update: 2018-12-06
項目中需要對使用者輸入的資訊進行儲存,然後在後續程式中讀取使用,利用到了SharedPreferences類。儲存操作通常會在onPause()方法中進行Preferences的儲存操作。public SharedPreferences getSharedPreferences (String name, int mode)其中name為Preferences的檔案名稱mode有以下三種:MODE_PRIVATE 表示當下應用程式專用MODE_WORLD_READABLE
Time of Update: 2018-12-06
參考網頁:http://www.njpro.cn/forum.php?mod=viewthread&tid=111http://stackoverflow.com/questions/2604727/how-can-i-connect-to-android-with-adb-over-tcphttp://forum.xda-developers.com/showthread.php?t=1071584 方法一:利用USB連接線進行串連1.
Time of Update: 2018-12-06
使用系統內建瀏覽器可以成功播放flash,可是利用自己開發的就無法播放。代碼如下:browser = (WebView) findViewById(R.id.webview);browser.getSettings().setJavaScriptEnabled(true);browser.getSettings().setPluginsEnabled(true);browser.getSettings().setAllowFileAccess(true);browser.getSettings(
Time of Update: 2018-12-06
一種是使用ScrollView和HorizontalScrollView結合。 這種方式的話,斜向滑動會有先後次序,一般將ScrollView放在外層第二種,使用onTouchEvent方法,監聽移動事件,進行處理。 如果只是監聽移動事件,圖片可以移出指定地區之外,可以通過控制邊界來進行限制在一定範圍內移動。 簡單解決方案代碼如下: container.setOnTouchListener(new OnTouchListener() { @
Time of Update: 2018-12-06
在之前處理過一個問題在任意視窗前彈出rss更新提醒對話方塊,如下頁面:http://www.cnblogs.com/sipher/articles/2502092.html利用上面的方法可以快顯視窗,不過沒有辦法在視窗中啟動一個activity。於是最近看有沒有其他辦法可以實現,想到在alertDialog中無法啟動,那就還是彈出一個activity類比視窗,再在其中啟動activity。代碼如下:private void showRssUpateRemindDialog() {
Time of Update: 2018-12-06
Android 中有幾個重要的組件,其中之一就是Service,這是沒有UI的組件,可以做為背景服務,當然可以使用Intent來啟動。同時也可以綁定到宿主對象(調用者,常是Activity)來使用,注意:一,Android中的Service與調用者在同一線程,所以要是耗時的操作要在Service中新開線程。二,Android的Service中,主要是實現其onCreate,onStart, onDestroy,onBind,onUnBind幾個函數,來實現我們所需要的功能。簡單的調用:
Time of Update: 2018-12-06
偶爾地,你可能想要確保你的應用程式在某一個確定的方向上面顯示,橫屏模式或豎屏模式。例如,你可能會開發一款只在橫屏模式下面啟動並執行遊戲。在這種情況下,可以通過編寫代碼,強制把Activity的方向設定為橫向,這需要使用Activity類的setRequestOrientation()方法。[java] view plaincopyimport android.content.pm.ActivityInfo; @Override public void onCreate(Bundle
Time of Update: 2018-12-06
MediaPlayer類提供了播放、暫停、停止、和重複播放等方法,每次只能播放一個音頻檔案,適合播放較大檔案,用法:1、從資源檔中播放,[java] view plaincopyMediaPlayer player1 = new MediaPlayer().create(this,R.raw.message); player1.start(); 2、從檔案系統播放,[java] view plaincopy MediaPlayer player = new
Time of Update: 2018-12-06
布局特別之處://與上一控制項底部的距離android:layout_marginTop="10dp"代碼階段分析://返回可畫的視圖,並用向下轉型為Bitmap的可畫視圖BitmapDrawable bitmapDrawable = (BitmapDrawable) image1.getDrawable();//如果圖片還未回收,先強制回收該圖片if (!bitmapDrawable.getBitmap().isRecycled()) { bitmapDrawable.getBitmap().
Time of Update: 2018-12-06
必須在AndroidManifest中設定相應的許可權:android:name="android.permission.RECORD_AUDIO" 1. 首先判定是否存在SD卡,並得到相應的路徑 /* 檢測是否存在SD卡 */ if (Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED)) {/* 得到SD卡得路徑 */ mRecAudioPath =
Time of Update: 2018-12-06
Wifi網卡狀態: WIFI_STATE_DISABLED : WIFI網卡不可用 WIFI_STATE_DISABLING : WIFI正在關閉 WIFI_STATE_ENABLED : WIFI網卡可用 WIFI_STATE_ENABLING : WIFI網卡正在開啟 WIFI_STATE_UNKNOWN : 未知網卡狀態 第一步: 通過WifiManager manager =
Time of Update: 2018-12-06
1. 首先在res/raw中匯入檔案dictionary.db/Files/lee0oo0/dictionary.rar2.
Time of Update: 2018-12-06
一個簡訊就是一個SmsMessage對象,一個SmsMessage對象通過一個byte[]來建立,一個byte[]數組就是一個object對象;在實際中有可能一條簡訊的內容太長,就會分成幾條簡訊,所以此時就對應著一個byte[][]的二維數組。//Android中簡訊封裝的形式是pdusObject[] object = (Object[]) intent.getSerializableExtra("pdus");byte[][] pdus = new byte[object.length][]
Time of Update: 2018-12-06
因為此代碼裡面有解釋,因此直接上代碼:public class ChangeBitmapPixel extends Activity { private Button btn; private Bitmap photo; private ImageView image; FileOutputStream fos = null; BufferedOutputStream bos = null; private ByteArrayOutputStream baos
Time of Update: 2018-12-06
Tab LayoutTo create a tabbed UI, you need to use a TabHost and a TabWidget. The TabHost must be the root node for the layout, which contains both the TabWidget for displaying the tabs and aFrameLayout for displaying the tab content.You can implement
Time of Update: 2018-12-06
在AndroidManifest中註冊相應的許可權:<uses-permission android:name="android.permission.FLASHLIGHT" /> <uses-permission android:name="android.permission.CAMERA"/> <uses-feature android:name="android.hardware.camera" /><uses-feature