Time of Update: 2018-12-05
當我們做的應用需要共用資料,但是又只想給一些特定的程式進行共用時,我們可以通過設定對應的許可權來控制別的程式無法共用資料。首先,定義資料共用的時候指定許可權: <provider android:name=".com.test.Provider" android:authorities="com.test.share.info" android:multiprocess="true"
Time of Update: 2018-12-05
package com.pocketdigi.phonelistener; import android.app.Service;import android.content.BroadcastReceiver;import android.content.Context;import android.content.Intent;import android.telephony.PhoneStateListener;import
Time of Update: 2018-12-05
1.鎖屏時間鎖屏時間控制碼位於:frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java private void loadSystemSettings(SQLiteDatabase db) { …… loadIntegerSetting(stmt, Settings.System.SCREEN_OFF_TIMEOUT,
Time of Update: 2018-12-05
通過Eclipse可以在自己的應用程式中增加一個按鈕,同時在main.xml中會自動增加如下的代碼:--- <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button"
Time of Update: 2018-12-05
android提供可以實現錄音功能的有AudioRecord和MediaRecorder,其中AudioRecord是讀取Mic的音頻流,可以邊錄音邊分析流的資料;而MediaRecorder則能夠直接把Mic的資料存到檔案,並且能夠進行編碼(如AMR,MP3等)。 首先,要將你的應用加入許可權(無論你是使用AudioRecord還是MediaRecorder): <uses-permission
Time of Update: 2018-12-05
本次項目中tabhost中使用spiner遇到的問題,總結一下。首先在頁面onCreate的時候需要改變的是:View contentView = LayoutInflater.from(getParent().getParent()).inflate(R.layout.personal_information, null);setContentView(contentView);這樣的方式來設定頁面顯示的view.personalProvinceSpinner = (Spinner)
Time of Update: 2018-12-05
使用反射:在你的setPositiveButton中添加://用於不關閉對話方塊try { Field field = dialog.getClass().getSuperclass().getDeclaredField("mShowing"); field.setAccessible(true); field.set(dialog, false);} catch (Exception e)
Time of Update: 2018-12-05
這是羽化第二篇部落格,目前依舊菜鳥一隻。最近在玩紛爭2,回想小學打FF8的時候真是感慨萬千,每當Eyes on
Time of Update: 2018-12-05
下面總結一下剛才自己遇到的問題。android退出全部activity的方法有兩種,但是在android2.2裡面必須使用下面這個方法: Intent startMain = new Intent(Intent.ACTION_MAIN); startMain.addCategory(Intent.CATEGORY_HOME); startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Time of Update: 2018-12-05
default.properties檔案加入:target=android-7proguard.config=proguard.cfg以上兩句proguard.cfg 檔案:-optimizationpasses 7-dontusemixedcaseclassnames-dontskipnonpubliclibraryclasses-dontpreverify-verbose-optimizations
Time of Update: 2018-12-05
px(pixels)——像素:不同的裝置顯示效果相同,一般我們HVGA代表320x480像素,這個用的比較多。dip(device independent pixels)——裝置獨立像素:這個和裝置硬體有關,一般哦我們為了支援WCGA、HVGA和QVGA推薦使用這個,不依賴於像素。等同於dp。sp(scaled pixels—best for text size)——帶比例的像素。pt(points)——磅:1pt =
Time of Update: 2018-12-05
<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android"> <!-- 內部顏色 --> <solid android:color="#00A5C6"/> <!-- 邊緣線條顏色 --> <stroke android:width="1.0px"
Time of Update: 2018-12-05
帶有g-sensor的Android裝置上可通過API擷取到裝置的運動加速度,應用程式通過一些假設和運算,可以從加速度計算出裝置的方向擷取裝置運動加速度的基本代碼是: SensorManager sm = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE); sm.registerListener(new SensorEventListener() { public
Time of Update: 2018-12-05
經過最近項目曆練不同手機型號已經SDK版本以後,發現上次寫的名為:android2.3選擇相簿圖片或者調用系統照相 的文章中,存在一個bug,就是在2.1的索尼手機上使用不了,並且無法擷取到圖片原生大小。下面做下最近的測試成功的記錄,主要以調用相簿和,系統攝像機為主:/** * Show Check Image Dialog */private void showheckImageDialog() {final CharSequence[] items = {
Time of Update: 2018-12-05
下面轉寄一個1920x1080解析度模擬器無法啟動的解決方案,隨便加點我的補充,原文來自:http://www.cnblogs.com/lijc1990/archive/2013/02/07/2908969.html問題的異常如下:emulator: Failed to open the HAX device!HAX is not working and emulator runs in emulation modeemulator: Open HAX device
Time of Update: 2018-12-05
此次遇到一個問題就是webView無法播放視頻,查了下Google發現可以設定setting.setPluginsEnabled(true);這個從而播放視頻,但是最新官方SDK說這個方法要放棄了,推薦使用setting.setPluginState(PluginState.ON);目前看來這兩種方法都可以,但是webview的頁面都finish了居然還能聽到視頻播放的聲音,於是有查了下發現webview的onResume方法可以繼續播放,onPause可以暫停播放,但是這兩個方法都是在Adde
Time of Update: 2018-12-05
在2.2中可以設定螢幕的方向為反轉橫屏:setRequestedOrientation(8);,因為系統沒有公開出這個參數的設定,不過在源碼裡面已經定義了SCREEN_ORIENTATION_REVERSE_LANDSCAPE這個參數,但是無法固定螢幕的方向為反轉橫屏即右橫屏。在設定螢幕方向為右橫屏的時候
Time of Update: 2018-12-05
/** *判斷當前應用程式處於前台還是後台 * * @param context * @return */ public static boolean isApplicationBroughtToBackground(final Context context) { ActivityManager am = (ActivityManager)
Time of Update: 2018-12-05
webView載入一個404的路徑時,會出現not found這樣的內容顯示出來,但是有時候我們需要在出現這樣問題後,做其他處理,所有我們要捕獲他的錯誤,但是SDK的錯誤處理方法居然不會在載入錯誤以後回調:public void onReceivedError (WebView view, int errorCode, String description, String failingUrl)Since: API Level 1Report an error to the host
Time of Update: 2018-12-05
用 Heap監測應用進程使用記憶體情況的步驟如下:1. 啟動eclipse後,切換到DDMS透視圖,並確認Devices視圖、Heap視圖都是開啟的;2. 將手機通過USB連結至電腦,連結時需要確認手機是處於“USB調試”模式,而不是作為“Mass Storage”;3. 連結成功後,在DDMS的Devices視圖中將會顯示手機裝置的序號,以及裝置中正在啟動並執行部分進程資訊;4. 點擊選中想要監測的進程,比如system_process進程;5.