編輯:關於Android編程
Android設備系統正常工作時,很多Service運行在後台,只用在系統內存不夠使用時候,才會自動kill掉後台Service
Android OTT盒子項目開發中,網絡機頂盒運行內存512M/1G 內存不夠使用,為了提高系統的流暢性,編譯固件時加入app黑白名單功能。
Android系統開機後會發出BroadcastReceiver開機廣播,
在設置app 添加BootCompletedReceiverAML.java
public class BootCompletedReceiverAML extends BroadcastReceiver {
public static final String TAG = "BootCompletedReceiverAML";
public void onReceive(Context context, Intent intent) {
initScreenSaver();
initEnableRunningBackgroudComponents();
initEnableAutoRunningComponents();
initLauncherComponents();
}
//設置進入屏保黑白名單
private void initScreenSaver() {
Settings.System.putInt(mContext.getContentResolver(),
Settings.System.BOOT_GUIDE_COMPLETED, 1);
IDreamManager mDreamManager = IDreamManager.Stub.asInterface(ServiceManager.getService(DreamService.DREAM_SERVICE));
ComponentName dream = newComponentName("com.mipt.screensaver",
"com.mipt.screensaver.ScreenSaverService");
try {
ComponentName[] dreams = { dream };
mDreamManager.setDreamComponents(dream == null ? null : dreams);
}
catch (RemoteException e) {
}
String dreamEnableComponentNames = "com.skyworthdigital.filexplorer/com.skyworthdigital.weather.main/com.skyworthdigital.ihome.settings/com.study.pumpkinstudy/com.android.dreams.phototable";
Settings.System.putString(mContext.getContentResolver(),
Settings.System.DREAM_ENABLE_COMPONENT,dreamEnableComponentNames);
try {
long currentTimeout = Settings.System.getLong(
mContext.getContentResolver(), SCREEN_OFF_TIMEOUT);
if (currentTimeout < 0) {
Settings.System.putInt(mContext.getContentResolver(),
SCREEN_OFF_TIMEOUT, 2147483646);
}
currentTimeout = Settings.System.getLong(
mContext.getContentResolver(), SCREEN_DREAM_TIMEOUT, -1);
if (currentTimeout < 0) {
Settings.System.putInt(mContext.getContentResolver(),
SCREEN_DREAM_TIMEOUT, 240000);
}
} catch (SettingNotFoundException e) {
e.printStackTrace();
}
}
// 使能自動運行在後台service
private void initEnableRunningBackgroudComponents() {
Settings.Secure.putString(mContext.getContentResolver(),
Settings.Secure.ENABLE_RUNNING_BACKGROUD_COMPONENTS,
"android/system/com.android/com.mipt/com.skyworth/com.google.android/com.skydigital/com.sky/com.starcor.hunan/com.explorer/com.slanissue.tv.erge/eu.chainfire.perfmon");
}
//開機自動運行
private void initEnableAutoRunningComponents() {
Settings.Secure.putString(mContext.getContentResolver(),
Settings.Secure.ENABLE_AUTO_LAUNCH_COMPONENTS,
"com.android/android/system/com.mipt/com.skyworth/com.mipt.metro.launcher/com.skydigital/com.sky/com.starcor.hunan");
}
//開機Launcher
private void initLauncherComponents() {
Settings.Secure.putString(mContext.getContentResolver(),
Settings.Secure.ENABLE_LAUNCHER_COMPONENTS,
"com.mipt.metro.launcher");
}
}
實現原理是使用RecyclerView的OnTouchListener方法監聽滑動 在adapter裡面增加兩項footview 其中date.size為顯示的加載條,可
第4節 Button按鈕是需要與用戶進行互動的控件。Button繼承自TextView,凡是TextView有的特定,它都有。public class Button ex
Android 切圓圖效果圖如下:MyView 類public class MyView extends View { Bitmap bmp; Paint paint
(1)布局文件沒有做更改 (2)在res--menu目錄下的main.xml文件中代碼如下: