Android開機自啟動程序
背景知識:當Android啟動時,會發出一個系統廣播,內容為ACTION_BOOT_COMPLETED,它的字
符串常量表示為 android.intent.action.BOOT_COMPLETED。只要在程序中“捕捉”到這個消息,再啟動之
即可。記住,Android框架說:Don\"\"t call me, I\"\"ll call you back。我們要做的是做好接收這個消息的準備,而
實現的手段就是實現一個BroadcastReceiver。
1、界面Activity,BootStartDemo.java文件
?1234567891011121314151617181920212223242526public class BootStartDemo extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // 無title requestWindowFeature(Window.FEATURE_NO_TITLE); // 全屏 getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.main); new Thread() { public void run() { try { /* 8秒后關閉頁面*/ sleep(10000); } catch (Exception e) { e.printStackTrace(); } finally { finish(); // 關閉頁面 } } }.start(); }}這段代碼很簡單,當Activity 啟動時,會顯示TextView,用它顯示你想顯示的字樣,并且這個頁面只顯示10秒后消失。
2、接收廣播消息:BootBroadcastReceiver.java
?1234567891011121314public class BootBroadcastReceiver extends BroadcastReceiver { static final String action_boot=";android.intent.action.BOOT_COMPLETED";; @Override public void onReceive(Context context, Intent intent) { if (intent.getAction().equals(action_boot)){ Intent ootStartIntent=new Intent(context,BootStartDemo.class); ootStartIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(ootStartIntent); } } }該類繼續自 BroadcastReceiver,覆載方法 onReceive 中,檢測接收到的 Intent 是否符合
BOOT_COMPLETED,如果符合,則啟動BootStartDemo這個Activity。
3、配置文件
(1)AndroidManifest.xml :
?1234567891011121314151617181920212223<?xml version=";1.0"; encoding=";utf-8";?><!-- 這是一個開機自啟動程序 --><manifest xmlns:android="/apk/res/android"; package=";com.ajie.bootstartdemo"; android:versionCode=";1"; android:versionName=";1.0";> <application android:icon=";@drawable/icon"; android:label=";@string/app_name";> <activity android:name=";.BootStartDemo"; android:label=";@string/app_name";> <intent-filter> <action android:name=";android.intent.action.MAIN"; /> <category android:name=";android.intent.category.LAUNCHER"; /> </intent-filter> </activity> <SPAN style=";COLOR: #ff00ff";><receiver android:name=";.BootBroadcastReceiver";> <intent-filter> <action android:name=";android.intent.action.BOOT_COMPLETED"; /> <category android:name=";android.intent.category.HOME"; /> </intent-filter> </receiver> </SPAN> </application><SPAN style=";COLOR: #ff00ff";><STRONG><uses-permission android:name=";android.permission.RECEIVE_BOOT_COMPLETED";></uses-permission></STRONG> </SPAN></manifest>注意其中顏色標紅那一部分,該節點向系統注冊了一個 receiver,子節點 intent-filter 表示接收
android.intent.action.BOOT_COMPLETED 消息。并且還要配置android.permission.RECEIVE_BOOT_COMPLETED權限。
(2)Layout文件,main.xml
?1234567891011121314151617<?xml version=";1.0"; encoding=";utf-8";?><LinearLayout xmlns:android="/apk/res/android"; android:orientation=";vertical"; android:layout_width=";fill_parent"; android:layout_height=";fill_parent"; ><TextView android:layout_width=";fill_parent"; android:layout_height=";fill_parent"; android:text=";@string/boottext"; android:textColor=";#5F2DD2"; android:background=";#FFFFFF"; android:textSize=";60px"; android:gravity=";center_horizontal"; /></LinearLayout>完成后,編譯出apk包,安裝到模擬器或手機中。關機,重新開機,就會顯示BootStartDemo這個Activity顯示出來的頁面。
Android文本框橫屏狀態下彈出輸入法
Android文本框橫屏狀態下輸入法會跳轉到另一個全屏頁面,很多內容少的文本輸入不是特別方便
所以,我們可以在文本框屬性中添加如下代碼
android:imeOptions=";flagNoExtractUi";
技術員聯系楊小霞QQ:102258616
PC700產品三星210版本開發的軟件,如何**升級到MTK6572版本
很多客戶較早使用的PC700產品是三星210(S5PV210)方案的,已經開發好了自己的管理軟件,但是后期采購了MTK6572方案的設備,軟件部分功能無法直接通用,所以這里做一個簡單的升級提示
拍照錄像
該功能直接通用,都是使用Android標準API即可,*做任何修改
打印功能
三星210方案上使用的打印串口名稱是/dev/ttySAC3,波特率為115200,MTK6572方案上只需修改串口名稱為/dev/ttySAC0
RFID讀寫
三星210方案上使用是RFID芯片,通過串口通訊的,MTK6572上升級成NFC芯片,同時兼容RFID讀寫,所以這里改動比較大,NFC是Google標準API,所以需要參照官方DEMO或者我們提供的NFC的DEMO程序進行修改
包裝清單 : 電源 ;
發票 : 報價不含稅票 ;
質保 : 一年(年) ;
售后類型 : 一年保修 ;
較快出貨時間 : 3 ;
是否支持代理* : 支持 ;
OEM : 可OEM ;
重量 : 1(kg) ;
用途 : 打印服務 ;
內存容量 : 2GB ;
接口類型 : 串口 ;
磁盤陣列 : 其他 ;
支持內存容量 : 4 ;
內存類型 : flash ;
較大CPU個數 : 1個 ;
標配CPU個數 : 1個 ;
CPU主頻 : 1(GHz) ;
CPU : A8 ;
服務器類型 : 終端類 ;
類型 : 工作站 ;
貨源類別 : ** ;
上市時間 : 2015 ;
型號 : PC700 ;
** : 智谷電 ;