㈠ android 4.4系統安卓ART模式是什麼有什麼功能作用
ART模式編輯
ART模式英文全稱為:Android runtime,谷歌Android 4.4系統新增的一種應用運行模式,與傳統的Dalvik模式不同,ART模式可以實現更為流暢的安卓系統體驗,對於大家來說,只要明白ART模式可讓系統體驗更加流暢,不過只有在安卓4.4以上系統中採用此功能。
D
Dalvik模式編輯
如果要解釋清楚什麼是ART模式,我們就需要從Android系統的應用編譯模式說起,我們都知道Android系統是以Linux系統為底層構建的,Android系統是開源(源代碼公開)的,Android系統勢必會適配到不同硬體配置的設備上,因此谷歌為了降低應用的開發難度在Linux底層之上構築了一個名為「Dalvik」的虛擬機。
因為Dalvik虛擬機的存在,Android系統的開發者只需使用谷歌提供的SDK(軟體開發工具包)即可較為輕松的按照一套「規則」創建APP,不用顧忌硬體、驅動等問題,在每次執行應用的時候Dalvik虛擬機都會將程序的語言由高級語言編譯為機器語言,這樣當前設備才能夠運行這一應用。
有的朋友可能注意到了,筆者特意強調了「每次」二字,以往的Android系統為了兼容性做出了妥協,在每次運行應用時都需要一次編譯,這樣程序的執行效率大大下降。同時也是為什麼安兔兔為了照顧體驗方面的得分在4.0版本之後特意加入了Dalvik虛擬機一項,如果該項得分越高證明該機的軟體執行效率越高,在使用時的實際體驗就會更加流暢、順滑。[1]
2ART模式是什麼編輯
了解了Dalvik模式之後,我們便要了解一下Android4.4中新加入的ART模式,該模式的完整名稱是Androidruntime,事實上谷歌的這次優化源於前不久其收購的一家名為Flexycore的公司,該公司一直致力於Android系統的優化,而ART模式也是在該公司的優化方案上演進而來。
ART模式與Dalvik模式最大的不同在於,在啟用ART模式後,系統在安裝應用的時候會進行一次預編譯,在安裝應用程序時會先將代碼轉換為機器語言存儲在本地,這樣在運行程序時就不會每次都進行一次編譯了,執行效率也大大提升。
從這方面來看,ART模式確實能夠改善Android平台一直以來在兼容性方面的妥協,但另一方面,應用經過預編譯後的容量,以及應用是否兼容該模式也是需要重點考慮的問題。
㈡ 安卓系統桌面循環滾動桌面設置的
1、手機設置」的「輔助功能」中有選擇是否「桌面循環」。
2、在原生的android源碼上添加這一功能。
思路:先把界面做出來,再將是否選擇的值存到系統的(adb shell進入)data/data/com.android.providers.settings/databases/settings.db資料庫中的system表中,
然後在Launch2的源碼中取得資料庫中是否選擇循環桌面來執行相關代碼。
先做UI:
在settings源碼中的accessibility_settings.xml文件中添加一個checkbox:
java代碼
android:key="launch_repeat"
android:title="@string/launch_repeat_title"
android:persistent="false"/>
在settings源碼的res中添加相關的代碼:
在values/string.xml中添加(英文顯示):
Launch Repeat
在values-zh-rCN/string.xml中添加(中文顯示):
"循環桌面"
在settings源碼的AccessibilitySettings.java中的OnCreate中添加:
java代碼
/*****************************************/
mLaunchRepeat=(CheckBoxPreference) findPreference(
LAUNCH_REPEAT);
int LaunchRepeat=Settings.System.getInt(this.getContentResolver(),
"launch_repeat",0);//取出是否被選擇
if(LaunchRepeat==1)//如果被選擇,那麼下次打開setting時就勾選
mLaunchRepeat.setChecked(true);
else
mLaunchRepeat.setChecked(false);//如果沒被選擇,那麼下次打開setting時就不勾選
/*****************************************/
當然還要定義幾個量:
private final String LAUNCH_REPEAT =
"launch_repeat";
private CheckBoxPreference mLaunchRepeat;
在onPreferenceTreeClick函數中添加:
java代碼
//add by xxnan
if(LAUNCH_REPEAT.equals(key))
{
Settings.System.putInt(getContentResolver(),
"launch_repeat",
((CheckBoxPreference) preference).isChecked()?
1:0);//將是否選擇存到系統的system表中
}
//add by xxnan
如果做好了之後當點擊選擇「桌面循環時」可以到(adb shell進入)data/data/com.android.providers.settings/databases下的settings.db資料庫(sqlite3 settings.db)的system
表中看到33|launch_repeat|1(select * from system;)。
到這里就完成了將數據存到系統system表中以及UI,接下來就是在Launch2源碼中去取這個值(是否循環)。
到Launcher2源碼中去找到Workspace.java文件,在裡面有相應的修改:
在onTouchEvent中,之前有修改循環,如下:
java代碼
case MotionEvent.ACTION_UP:
if (mTouchState == TOUCH_STATE_SCROLLING) {
final VelocityTracker velocityTracker = mVelocityTracker;
velocityTracker.computeCurrentVelocity(1000, mMaximumVelocity);
final int velocityX = (int)
velocityTracker.getXVelocity(mActivePointerId);
final int screenWidth = getWidth();
final int whichScreen = (mScrollX + (screenWidth / 2)) / screenWidth;
final float scrolledPos = (float) mScrollX / screenWidth;
Log.i("velocityX","velocityX="+velocityX+"whichScreen="+whichScreen);
/***********************************************/
//modifided by xxnan
if (velocityX > SNAP_VELOCITY) {
// Fling hard enough to move left.
// Don't fling across more than one screen at a time.
Log.i("numscreen","numscreen="+mCurrentScreen);
/* final int bound = scrolledPos < whichScreen ?
( (mCurrentScreen+ getChildCount()) - 1 )% getChildCount():
mCurrentScreen;*/
final int bound =( (mCurrentScreen+ getChildCount()) - 1 )% getChildCount()
;
Log.i("numscreen","bound="+bound);
snapToScreen( bound, velocityX, true);
} else if (velocityX < -SNAP_VELOCITY ) {
// Fling hard enough to move right
// Don't fling across more than one screen at a time.
/*final int bound = scrolledPos > whichScreen ?
( mCurrentScreen + 1 )% getChildCount(): mCurrentScreen;*/
final int bound = ( mCurrentScreen + 1 )% getChildCount() ;
snapToScreen(bound, velocityX, true);
} else {
snapToScreen(whichScreen, 0, true);
}
/***********************************************/
//下面是原生代碼
/*if (velocityX > SNAP_VELOCITY && mCurrentScreen > 0) {
// Fling hard enough to move left.
// Don't fling across more than one screen at a time.
final int bound = scrolledPos < whichScreen ?
mCurrentScreen - 1 : mCurrentScreen;
snapToScreen(Math.min(whichScreen, bound), velocityX, true);
} else if (velocityX < -SNAP_VELOCITY && mCurrentScreen <
getChildCount() - 1) {
// Fling hard enough to move right
// Don't fling across more than one screen at a time.
final int bound = scrolledPos > whichScreen ?
mCurrentScreen + 1 : mCurrentScreen;
snapToScreen(Math.max(whichScreen, bound), velocityX, true);
} else {
snapToScreen(whichScreen, 0, true);
}*/
}
mTouchState = TOUCH_STATE_REST;
mActivePointerId = INVALID_POINTER;
releaseVelocityTracker();
break;
那麼就要在修改的地方加一個判斷,如果system中取得的值是1,就可以循環,如果是0,就不能。
代碼修改如下:
java代碼
case MotionEvent.ACTION_UP:
if (mTouchState == TOUCH_STATE_SCROLLING) {
final VelocityTracker velocityTracker = mVelocityTracker;
velocityTracker.computeCurrentVelocity(1000, mMaximumVelocity);
final int velocityX = (int)
velocityTracker.getXVelocity(mActivePointerId);
final int screenWidth = getWidth();
final int whichScreen = (mScrollX + (screenWidth / 2)) / screenWidth;
final float scrolledPos = (float) mScrollX / screenWidth;
Log.i("velocityX","velocityX="+velocityX+"whichScreen="+whichScreen);
/***********************************************/
//modifided by xxnan 2013-1-9
launch_repeat=Settings.System.getInt(mContext.getContentResolver(),
"launch_repeat",0);//取出system表中「launch_repeat」的值
Log.i(" launch_repeat"," launch_repeat="+ launch_repeat);
if(launch_repeat==1)//如果是1,就循環,也就是之前已經改好的
{
if (velocityX > SNAP_VELOCITY) {
// Fling hard enough to move left.
// Don't fling across more than one screen at a time.
Log.i("numscreen","numscreen="+mCurrentScreen);
/* final int bound = scrolledPos < whichScreen ?
( (mCurrentScreen+ getChildCount()) - 1 )% getChildCount():
mCurrentScreen;*/
final int bound =( (mCurrentScreen+ getChildCount()) - 1 )% getChildCount()
;
Log.i("numscreen","bound="+bound);
snapToScreen( bound, velocityX, true);
} else if (velocityX < -SNAP_VELOCITY ) {
// Fling hard enough to move right
// Don't fling across more than one screen at a time.
/*final int bound = scrolledPos > whichScreen ?
( mCurrentScreen + 1 )% getChildCount(): mCurrentScreen;*/
final int bound = ( mCurrentScreen + 1 )% getChildCount() ;
snapToScreen(bound, velocityX, true);
} else {
snapToScreen(whichScreen, 0, true);
}
}
else//如果是0,那麼就是原生代碼,不循環
{
if (velocityX > SNAP_VELOCITY && mCurrentScreen > 0) {
// Fling hard enough to move left.
// Don't fling across more than one screen at a time.
final int bound = scrolledPos < whichScreen ?
mCurrentScreen - 1 : mCurrentScreen;
snapToScreen(Math.min(whichScreen, bound), velocityX, true);
} else if (velocityX < -SNAP_VELOCITY && mCurrentScreen <
getChildCount() - 1) {
// Fling hard enough to move right
// Don't fling across more than one screen at a time.
final int bound = scrolledPos > whichScreen ?
mCurrentScreen + 1 : mCurrentScreen;
snapToScreen(Math.max(whichScreen, bound), velocityX, true);
} else {
snapToScreen(whichScreen, 0, true);
}
}
/***********************************************/
//下面是原生代碼
/*if (velocityX > SNAP_VELOCITY && mCurrentScreen > 0) {
// Fling hard enough to move left.
// Don't fling across more than one screen at a time.
final int bound = scrolledPos < whichScreen ?
mCurrentScreen - 1 : mCurrentScreen;
snapToScreen(Math.min(whichScreen, bound), velocityX, true);
} else if (velocityX < -SNAP_VELOCITY && mCurrentScreen <
getChildCount() - 1) {
// Fling hard enough to move right
// Don't fling across more than one screen at a time.
final int bound = scrolledPos > whichScreen ?
mCurrentScreen + 1 : mCurrentScreen;
snapToScreen(Math.max(whichScreen, bound), velocityX, true);
} else {
snapToScreen(whichScreen, 0, true);
}*/
}
mTouchState = TOUCH_STATE_REST;
mActivePointerId = INVALID_POINTER;
releaseVelocityTracker();
break;
當然這裡面也要定義幾個量,以及導入幾個包:
導入包:
//add by xxnan
import android.content.ContentResolver;//從system表中取數據
import android.provider.Settings;
定義變數:
private int launch_repeat;//取得是否循環的值
到這里就全部修改好了,還有就是編譯一下源碼中的package/apps的Launch2和Settings的源碼,將生成的out/target/。。。/system/app下的
Launch2.apk和Settings.apk替換手機里system/app的這兩個apk就可以了。
㈢ 如何在安卓系統下構建c++編譯環境
這個有點難,現在安卓能用的(我知道的)只有一個軟體C4droid可以在android系統中編譯c/c++:
編譯界面:
㈣ 怎麼更改安卓系統手機程序桌面圖標
可以按照如下方式操作:
1、打開apk編輯器。
1、APK是AndroidPackage的縮寫,即Android安裝包(apk)。APK是類似Symbian Sis或Sisx的文件格式。通過將APK文件直接傳到Android模擬器或Android手機中執行即可安裝。
2、apk文件和sis一樣,把android sdk編譯的工程打包成一個安裝程序文件,格式為apk。 APK文件其實是zip格式,但後綴名被修改為apk,通過UnZip解壓後,可以看到Dex文件,Dex是DalvikVM executes的簡稱,即Android Dalvik執行程序。
3、Java ME的位元組碼而是Dalvik位元組碼。Android在運行一個程序時首先需要UnZip,然後類似Symbian那樣直接,和Windows Mobile中的PE文件有區別。